Skip to content

Commit

Permalink
Handle jaeger errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonip committed Jan 25, 2024
1 parent b12a828 commit e24022f
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 0 deletions.
42 changes: 42 additions & 0 deletions input/otlp/test_approved/span_jaeger_data_stream.approved.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"events": [
{
"@timestamp": "2019-12-16T12:46:58.000Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "1",
"namespace": "2"
},
"event": {
"duration": 79000000000,
"outcome": "success"
},
"host": {
"hostname": "host-abc"
},
"parent": {
"id": "0000000058585858"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"span": {
"id": "0000000041414646",
"representative_count": 1,
"type": "unknown"
},
"timestamp": {
"us": 1576500418000768
},
"trace": {
"id": "00000000000000000000000046467830"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"events": [
{
"@timestamp": "2019-12-16T12:46:58.000Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "1",
"namespace": "2"
},
"event": {
"duration": 79000000000,
"outcome": "success"
},
"host": {
"hostname": "host-abc"
},
"parent": {
"id": "0000000058585858"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"span": {
"id": "0000000041414646",
"representative_count": 1,
"type": "unknown"
},
"timestamp": {
"us": 1576500418000768
},
"trace": {
"id": "00000000000000000000000046467830"
}
},
{
"@timestamp": "2019-12-16T12:46:58.000Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "3",
"namespace": "4"
},
"error": {
"exception": [
{
"message": "no connection established"
}
],
"log": {
"message": "retrying connection"
}
},
"host": {
"hostname": "host-abc"
},
"parent": {
"id": "0000000041414646"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
},
"trace": {
"id": "00000000000000000000000046467830"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"events": [
{
"@timestamp": "2019-12-16T12:46:58.000Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "1",
"namespace": "2"
},
"event": {
"outcome": "success"
},
"host": {
"hostname": "host-abc"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"timestamp": {
"us": 1576500418000768
},
"transaction": {
"representative_count": 1,
"result": "Success",
"sampled": true,
"type": "unknown"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"events": [
{
"@timestamp": "2339-03-21T22:18:14.838Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "1",
"namespace": "2"
},
"event": {
"outcome": "success"
},
"host": {
"hostname": "host-abc"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"timestamp": {
"us": 11651379494838206
},
"trace": {
"id": "00000000000000000000000046467830"
},
"transaction": {
"representative_count": 1,
"result": "Success",
"sampled": true,
"type": "unknown"
}
},
{
"@timestamp": "2019-12-16T12:46:58.000Z",
"agent": {
"name": "Jaeger",
"version": "unknown"
},
"data_stream": {
"dataset": "3",
"namespace": "4"
},
"error": {
"exception": [
{
"message": "no connection established"
}
],
"log": {
"message": "retrying connection"
}
},
"host": {
"hostname": "host-abc"
},
"service": {
"language": {
"name": "unknown"
},
"name": "unknown"
},
"span": {},
"timestamp": {
"us": 1576500418000768
},
"trace": {
"id": "00000000000000000000000046467830"
},
"transaction": {
"sampled": true,
"type": "unknown"
}
}
]
}
14 changes: 14 additions & 0 deletions input/otlp/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,20 @@ func (c *Consumer) convertJaegerErrorSpanEvent(event ptrace.SpanEvent, apmEvent
isError = stringval == "error"
case "message":
logMessage = stringval

// data_stream.*
// Note: fields are parsed but dataset will be overridden by SetDataStream because it is an error
case attributeDataStreamDataset:
if apmEvent.DataStream == nil {
apmEvent.DataStream = modelpb.DataStreamFromVTPool()
}
apmEvent.DataStream.Dataset = v.Str()
case attributeDataStreamNamespace:
if apmEvent.DataStream == nil {
apmEvent.DataStream = modelpb.DataStreamFromVTPool()
}
apmEvent.DataStream.Namespace = v.Str()

default:
setLabel(replaceDots(k), apmEvent, ifaceAttributeValue(v))
}
Expand Down
58 changes: 58 additions & 0 deletions input/otlp/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,36 @@ func TestConsumer_JaegerTransaction(t *testing.T) {
},
}},
},
{
name: "jaeger_data_stream",
spans: []*jaegermodel.Span{{
StartTime: testStartTime(),
Tags: []jaegermodel.KeyValue{
jaegerKeyValue("data_stream.dataset", "1"),
jaegerKeyValue("data_stream.namespace", "2"),
},
}},
},
{
name: "jaeger_data_stream_with_error",
spans: []*jaegermodel.Span{{
TraceID: jaegermodel.NewTraceID(0, 0x46467830),
Tags: []jaegermodel.KeyValue{
jaegerKeyValue("data_stream.dataset", "1"),
jaegerKeyValue("data_stream.namespace", "2"),
},
Logs: []jaegermodel.Log{{
Timestamp: testStartTime().Add(23 * time.Nanosecond),
Fields: jaegerKeyValues(
"event", "retrying connection",
"level", "error",
"error", "no connection established",
"data_stream.dataset", "3",
"data_stream.namespace", "4",
),
}},
}},
},
} {
t.Run(tc.name, func(t *testing.T) {
traces, err := jaegertranslator.ProtoToTraces([]*jaegermodel.Batch{{
Expand Down Expand Up @@ -1430,6 +1460,34 @@ func TestConsumer_JaegerSpan(t *testing.T) {
name: "jaeger_custom",
spans: []*jaegermodel.Span{{}},
},
{
name: "jaeger_data_stream",
spans: []*jaegermodel.Span{{
Tags: []jaegermodel.KeyValue{
jaegerKeyValue("data_stream.dataset", "1"),
jaegerKeyValue("data_stream.namespace", "2"),
},
}},
},
{
name: "jaeger_data_stream_with_error",
spans: []*jaegermodel.Span{{
Tags: []jaegermodel.KeyValue{
jaegerKeyValue("data_stream.dataset", "1"),
jaegerKeyValue("data_stream.namespace", "2"),
},
Logs: []jaegermodel.Log{{
Timestamp: testStartTime().Add(23 * time.Nanosecond),
Fields: jaegerKeyValues(
"event", "retrying connection",
"level", "error",
"error", "no connection established",
"data_stream.dataset", "3",
"data_stream.namespace", "4",
),
}},
}},
},
} {
t.Run(tc.name, func(t *testing.T) {
batch := &jaegermodel.Batch{
Expand Down

0 comments on commit e24022f

Please sign in to comment.