Skip to content

Commit f0df061

Browse files
authored
Adding Span Link support for distributed tracing header extractions with invalid traces (#4874)
* initial commit * updating _links and when links are created * logging * add link to instrumentation * updating integrations to include span links * fixing syntax error * fixing ci tests * updating unit test * fix ci * fixing moleculer tests * safe checking all contexts before getting links
1 parent 61c5a32 commit f0df061

17 files changed

Lines changed: 90 additions & 42 deletions

File tree

packages/datadog-plugin-amqplib/src/consumer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class AmqplibConsumerPlugin extends ConsumerPlugin {
2626
'amqp.consumerTag': fields.consumerTag,
2727
'amqp.source': fields.source,
2828
'amqp.destination': fields.destination
29-
}
29+
},
30+
extractedLinks: childOf?._links
3031
})
3132

3233
if (

packages/datadog-plugin-aws-sdk/src/services/kinesis.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Kinesis extends BaseAwsSdkPlugin {
4242
{},
4343
this.requestTags.get(request) || {},
4444
{ 'span.kind': 'server' }
45-
)
45+
),
46+
extractedLinks: responseExtraction.maybeChildOf._links
4647
}
4748
span = plugin.tracer.startSpan('aws.response', options)
4849
this.enter(span, store)

packages/datadog-plugin-aws-sdk/src/services/sqs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class Sqs extends BaseAwsSdkPlugin {
3333
{},
3434
this.requestTags.get(request) || {},
3535
{ 'span.kind': 'server' }
36-
)
36+
),
37+
extractedLinks: contextExtraction.datadogContext._links
3738
}
3839
parsedMessageAttributes = contextExtraction.parsedAttributes
3940
span = plugin.tracer.startSpan('aws.response', options)

packages/datadog-plugin-child_process/test/index.spec.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ describe('Child process plugin', () => {
6262
'span.type': 'system',
6363
'cmd.exec': JSON.stringify(['ls', '-l'])
6464
},
65-
integrationName: 'system'
65+
integrationName: 'system',
66+
links: undefined
6667
}
6768
)
6869
})
@@ -84,7 +85,8 @@ describe('Child process plugin', () => {
8485
'span.type': 'system',
8586
'cmd.shell': 'ls -l'
8687
},
87-
integrationName: 'system'
88+
integrationName: 'system',
89+
links: undefined
8890
}
8991
)
9092
})
@@ -109,7 +111,8 @@ describe('Child process plugin', () => {
109111
'cmd.exec': JSON.stringify(['echo', arg, '']),
110112
'cmd.truncated': 'true'
111113
},
112-
integrationName: 'system'
114+
integrationName: 'system',
115+
links: undefined
113116
}
114117
)
115118
})
@@ -134,7 +137,8 @@ describe('Child process plugin', () => {
134137
'cmd.shell': 'ls -l /h ',
135138
'cmd.truncated': 'true'
136139
},
137-
integrationName: 'system'
140+
integrationName: 'system',
141+
links: undefined
138142
}
139143
)
140144
})
@@ -160,7 +164,8 @@ describe('Child process plugin', () => {
160164
'cmd.exec': JSON.stringify(['ls', '-l', '', '']),
161165
'cmd.truncated': 'true'
162166
},
163-
integrationName: 'system'
167+
integrationName: 'system',
168+
links: undefined
164169
}
165170
)
166171
})
@@ -186,7 +191,8 @@ describe('Child process plugin', () => {
186191
'cmd.shell': 'ls -l /home -t',
187192
'cmd.truncated': 'true'
188193
},
189-
integrationName: 'system'
194+
integrationName: 'system',
195+
links: undefined
190196
}
191197
)
192198
})

packages/datadog-plugin-google-cloud-pubsub/src/consumer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
2222
},
2323
metrics: {
2424
'pubsub.ack': 0
25-
}
25+
},
26+
extractedLinks: childOf?._links
2627
})
2728
if (this.config.dsmEnabled && message?.attributes) {
2829
const payloadSize = getMessageSize(message)

packages/datadog-plugin-grpc/src/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class GrpcServerPlugin extends ServerPlugin {
4848
},
4949
metrics: {
5050
'grpc.status.code': 0
51-
}
51+
},
52+
extractedLinks: childOf?._links
5253
})
5354

5455
addMetadataTags(span, metadata, metadataFilter, 'request')

packages/datadog-plugin-jest/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ class JestPlugin extends CiPlugin {
219219
[COMPONENT]: this.constructor.id,
220220
...this.testEnvironmentMetadata,
221221
...testSuiteMetadata
222-
}
222+
},
223+
extractedLinks: testSessionSpanContext?._links
223224
})
224225
this.telemetry.ciVisEvent(TELEMETRY_EVENT_CREATED, 'suite')
225226
if (_ddTestCodeCoverageEnabled) {

packages/datadog-plugin-kafkajs/src/consumer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
7676
},
7777
metrics: {
7878
'kafka.partition': partition
79-
}
79+
},
80+
extractedLinks: childOf?._links
8081
})
8182
if (this.config.dsmEnabled && message?.headers) {
8283
const payloadSize = getMessageSize(message)

packages/datadog-plugin-moleculer/src/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class MoleculerServerPlugin extends ServerPlugin {
99

1010
start ({ action, ctx, broker }) {
1111
const followsFrom = this.tracer.extract('text_map', ctx.meta)
12-
1312
this.startSpan(this.operationName(), {
1413
childOf: followsFrom || this.activeSpan,
1514
service: this.config.service || this.serviceName(),
@@ -19,7 +18,8 @@ class MoleculerServerPlugin extends ServerPlugin {
1918
meta: {
2019
'resource.name': action.name,
2120
...moleculerTags(broker, ctx, this.config)
22-
}
21+
},
22+
extractedLinks: followsFrom?._links
2323
})
2424
}
2525
}

packages/datadog-plugin-rhea/src/consumer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class RheaConsumerPlugin extends ConsumerPlugin {
2828
component: 'rhea',
2929
'amqp.link.source.address': name,
3030
'amqp.link.role': 'receiver'
31-
}
31+
},
32+
extractedLinks: childOf?._links
3233
})
3334

3435
if (

0 commit comments

Comments
 (0)