Skip to content

Commit

Permalink
Support true LogEvent passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
loafoe committed Nov 3, 2021
1 parent 6ba4a89 commit 5252c40
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## v1.6.0

- Support true passthrough of LogEvent

**NOTE**: `LogData.Message` field must be base64 encoded!

## v1.5.2

- Feature: support LogEvent passthrough (@rostbel)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/m4rw3r/uuid v1.0.1
github.com/opentracing/opentracing-go v1.2.0
github.com/openzipkin/zipkin-go v0.3.0
github.com/philips-software/go-hsdp-api v0.48.2
github.com/philips-software/go-hsdp-api v0.49.1
github.com/sirupsen/logrus v1.8.1
github.com/spf13/viper v1.9.0
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/philips-software/go-hsdp-api v0.48.2 h1:V+mfOylG/qnxEx6tWHVpKeKzx5aq3lK0ZVJYfy1QX7Y=
github.com/philips-software/go-hsdp-api v0.48.2/go.mod h1:+/oOyI8Equm7/YcUHJ+PO3HO4U92JcAAoOs5DYRRkIc=
github.com/philips-software/go-hsdp-api v0.49.1 h1:4pOnNIVkL9/wnduPszJCI52FWYk6p6+bQMWVusmTC7M=
github.com/philips-software/go-hsdp-api v0.49.1/go.mod h1:+/oOyI8Equm7/YcUHJ+PO3HO4U92JcAAoOs5DYRRkIc=
github.com/philips-software/go-hsdp-signer v1.4.0 h1:yg7UILhmI4xJhr/tQiAiQwJL0EZFvLuMqpH2GZ9ygY4=
github.com/philips-software/go-hsdp-signer v1.4.0/go.mod h1:/QehZ/+Aks2t1TFpjhF/7ZSB8PJIIJHzLc03rOqwLw0=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
Expand Down
5 changes: 5 additions & 0 deletions queue/deliverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package queue

import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -359,6 +360,10 @@ func wrapResource(originatingUser string, msg syslog.Message) logging.Resource {
lm.LogData.Message = *m
}

lm.ResourceType = "LogEvent"
// Base64 encode
lm.LogData.Message = base64.StdEncoding.EncodeToString([]byte(lm.LogData.Message))

return lm
}

Expand Down
4 changes: 2 additions & 2 deletions queue/deliverer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestDeliveryToResource(t *testing.T) {
assert.NotNil(t, err)
}

func TestProcessMessagePassthrough(t *testing.T) {
func TestProcessMessagePassthroughs(t *testing.T) {
var rawMessage = `{"serviceName":"5c737703-fef3-49ed-9efe-51ba3a68c3e7","transactionId":"07bdcdd6-b398-48e2-99f9-6ed6209c84f2","applicationName":"5c737703-fef3-49ed-9efe-51ba3a68c3e7","applicationInstance":"%5BAPP/PROC/WEB/0%5D","resourceType":"LogEvent","severity":"informational","logTime":"2021-11-01T11:45:22.462Z","applicationVersion":"v1.2.2-deadbeaf","originatingUser":"logproxy-wrapped","logData":{"message":"Hello world"},"eventId":"1","component":"logproxy","id":"d6c0adef-54c0-4452-ad71-65b01eb1becd","category":"ApplicationLog","custom":{"tenantId":"265a6faa-c3be-4b5a-b827-f8a8bc569064","timestampUtc":"2021-11-01T11:45:22.430Z","userId":"[email protected]","durationMs":"3000"},"serverName":"client-xxx.dev.userpreferenceservice"}`
var payload = `<14>1 2018-09-07T15:39:21.132433+00:00 suite-phs.staging.msa-eustaging appname [APP/PROC/WEB/0] - - ` + rawMessage

Expand Down Expand Up @@ -130,7 +130,7 @@ func TestProcessMessage(t *testing.T) {
assert.Equal(t, "2018-09-07T15:39:18.517Z", resource.LogTime)
assert.Equal(t, appName, resource.ApplicationName)
assert.Equal(t, hostName, resource.ServerName)
assert.Equal(t, "Starting health monitoring of container", resource.LogData.Message)
assert.Equal(t, "U3RhcnRpbmcgaGVhbHRoIG1vbml0b3Jpbmcgb2YgY29udGFpbmVy", resource.LogData.Message)
}

func TestResourceWorker(t *testing.T) {
Expand Down

0 comments on commit 5252c40

Please sign in to comment.