|
5 | 5 | import static datadog.trace.api.DDTags.SPAN_LINKS; |
6 | 6 | import static datadog.trace.bootstrap.instrumentation.api.ErrorPriorities.UNSET; |
7 | 7 | import static datadog.trace.bootstrap.instrumentation.api.ServiceNameSources.MANUAL; |
| 8 | +import static datadog.trace.core.CoreSpan.OWN_PROPAGATION_TAGS; |
| 9 | +import static datadog.trace.core.CoreSpan.ROOT_PROPAGATION_TAGS; |
| 10 | +import static datadog.trace.core.CoreSpan.STRUCTURED_EVENTS; |
| 11 | +import static datadog.trace.core.CoreSpan.STRUCTURED_LINKS; |
8 | 12 |
|
9 | 13 | import datadog.trace.api.Config; |
10 | 14 | import datadog.trace.api.DDSpanId; |
@@ -1324,72 +1328,26 @@ void earlyProcessTags(AppendableSpanLinks links) { |
1324 | 1328 | } |
1325 | 1329 | } |
1326 | 1330 |
|
1327 | | - void processTagsAndBaggage( |
1328 | | - final MetadataConsumer consumer, int longRunningVersion, DDSpan restrictedSpan) { |
1329 | | - processTagsAndBaggage( |
1330 | | - consumer, |
1331 | | - longRunningVersion, |
1332 | | - restrictedSpan, |
1333 | | - injectLinksAsTags, |
1334 | | - true, // injectEventsAsTags |
1335 | | - injectBaggageAsTags, |
1336 | | - propagationTags); |
1337 | | - } |
1338 | | - |
1339 | | - void processTagsAndBaggage( |
1340 | | - final MetadataConsumer consumer, |
1341 | | - int longRunningVersion, |
1342 | | - DDSpan restrictedSpan, |
1343 | | - boolean firstInChunk) { |
1344 | | - processTagsAndBaggage( |
1345 | | - consumer, |
1346 | | - longRunningVersion, |
1347 | | - restrictedSpan, |
1348 | | - injectLinksAsTags, |
1349 | | - true, // injectEventsAsTags |
1350 | | - injectBaggageAsTags, |
1351 | | - firstInChunk ? getPropagationTags() : null); |
1352 | | - } |
1353 | | - |
1354 | 1331 | /** |
1355 | | - * Serialize span links and span events as first-class structured data rather than tags. While |
1356 | | - * baggage tag injection keeps following the tracer configuration. |
| 1332 | + * Processes the span tags and baggage, and hands the resulting {@link Metadata} to the consumer. |
| 1333 | + * |
| 1334 | + * @param consumer The consumer of the span metadata. |
| 1335 | + * @param longRunningVersion The long-running version of the span. |
| 1336 | + * @param restrictedSpan The span to read links and events from. |
| 1337 | + * @param options The {@link CoreSpan} options describing what the serialization protocol needs. |
1357 | 1338 | */ |
1358 | | - void processTagsAndBaggageWithStructuredLinksAndEvents( |
1359 | | - final MetadataConsumer consumer, int longRunningVersion, DDSpan restrictedSpan) { |
1360 | | - processTagsAndBaggage( |
1361 | | - consumer, |
1362 | | - longRunningVersion, |
1363 | | - restrictedSpan, |
1364 | | - false, // injectLinksAsTags |
1365 | | - false, // injectEventsAsTags |
1366 | | - injectBaggageAsTags, |
1367 | | - propagationTags); |
1368 | | - } |
1369 | | - |
1370 | | - void processTagsAndBaggageWithStructuredLinksAndEvents( |
1371 | | - final MetadataConsumer consumer, |
1372 | | - int longRunningVersion, |
1373 | | - DDSpan restrictedSpan, |
1374 | | - boolean firstInChunk) { |
1375 | | - processTagsAndBaggage( |
1376 | | - consumer, |
1377 | | - longRunningVersion, |
1378 | | - restrictedSpan, |
1379 | | - false, // injectLinksAsTags |
1380 | | - false, // injectEventsAsTags |
1381 | | - injectBaggageAsTags, |
1382 | | - firstInChunk ? getPropagationTags() : null); |
1383 | | - } |
1384 | | - |
1385 | 1339 | void processTagsAndBaggage( |
1386 | | - final MetadataConsumer consumer, |
1387 | | - int longRunningVersion, |
1388 | | - DDSpan restrictedSpan, |
1389 | | - boolean injectLinksAsTags, |
1390 | | - boolean injectEventsAsTags, |
1391 | | - boolean injectBaggageAsTags, |
1392 | | - PropagationTags serializedPropagationTags) { |
| 1340 | + final MetadataConsumer consumer, int longRunningVersion, DDSpan restrictedSpan, int options) { |
| 1341 | + boolean injectLinksAsTags = this.injectLinksAsTags && (options & STRUCTURED_LINKS) == 0; |
| 1342 | + boolean injectEventsAsTags = (options & STRUCTURED_EVENTS) == 0; |
| 1343 | + PropagationTags serializedPropagationTags; |
| 1344 | + if ((options & ROOT_PROPAGATION_TAGS) != 0) { |
| 1345 | + serializedPropagationTags = getPropagationTags(); |
| 1346 | + } else if ((options & OWN_PROPAGATION_TAGS) != 0) { |
| 1347 | + serializedPropagationTags = this.propagationTags; |
| 1348 | + } else { |
| 1349 | + serializedPropagationTags = null; |
| 1350 | + } |
1393 | 1351 | // NOTE: The span is passed for the sole purpose of allowing updating & reading of the span |
1394 | 1352 | // links and events |
1395 | 1353 | // This is a compromise to avoid... |
@@ -1418,7 +1376,7 @@ void processTagsAndBaggage( |
1418 | 1376 |
|
1419 | 1377 | // Baggage |
1420 | 1378 | Map<String, String> baggageItemsWithPropagationTags; |
1421 | | - if (injectBaggageAsTags) { |
| 1379 | + if (this.injectBaggageAsTags) { |
1422 | 1380 | baggageItemsWithPropagationTags = new HashMap<>(baggageItems); |
1423 | 1381 | if (w3cBaggage != null) { |
1424 | 1382 | injectW3CBaggageTags(baggageItemsWithPropagationTags); |
|
0 commit comments