Skip to content

Commit

Permalink
[receiver/cloudfoundryreceiver] Refactor condition for RTR logs
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Clulow <[email protected]>
Co-authored-by: Cem Deniz Kabakci <[email protected]>
  • Loading branch information
3 people committed May 14, 2024
1 parent 262b5ef commit 9b389e3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions receiver/cloudfoundryreceiver/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func convertEnvelopeToMetrics(envelope *loggregator_v2.Envelope, metricSlice pme
func convertEnvelopeToLogs(envelope *loggregator_v2.Envelope, logSlice plog.LogRecordSlice, startTime time.Time) {
switch envelope.Message.(type) {
case *loggregator_v2.Envelope_Log:
// TODO: review log attributes and tags from the envelope
log := logSlice.AppendEmpty()
log.SetTimestamp(pcommon.Timestamp(envelope.GetTimestamp()))
log.SetObservedTimestamp(pcommon.NewTimestampFromTime(startTime))
Expand All @@ -59,13 +58,9 @@ func convertEnvelopeToLogs(envelope *loggregator_v2.Envelope, logSlice plog.LogR
log.SetSeverityText(plog.SeverityNumberError.String())
log.SetSeverityNumber(plog.SeverityNumberError)
}

copyEnvelopeAttributes(log.Attributes(), envelope)

if value, found := log.Attributes().Get("org.cloudfoundry.source_type"); found && value.AsString() == "RTR" {
parseLogTracedID(log)
}

_ = parseLogTracingFields(log)
default:
}
}

Expand All @@ -83,7 +78,10 @@ func copyEnvelopeAttributes(attributes pcommon.Map, envelope *loggregator_v2.Env
}
}

func parseLogTracedID(log plog.LogRecord) error {
func parseLogTracingFields(log plog.LogRecord) error {
if value, found := log.Attributes().Get("org.cloudfoundry.source_type"); !found || value.AsString() != "RTR" {
return nil
}
s := log.Body().AsString()
quoted := false
a := strings.FieldsFunc(s, func(r rune) bool {
Expand Down

0 comments on commit 9b389e3

Please sign in to comment.