Update Kafka producer instrumentation #2516
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Updated Kafka producer instrumentation to use modern distributed tracing APIs with W3C Trace Context support, and added an additional test to validate the
exclude_newrelic_header
configuration option.Related Github Issue
#696
Kafka instrumentation uses deprecated DT APIs that only adds the
newrelic
header. This requires customers to take manual steps for full distributed tracing functionality (see https://github.com/newrelic/newrelic-java-examples/tree/main/newrelic-java-agent/distributed-tracing/kafka-examples).Testing
Added W3C header verification to existing test:
produceConsumeTest()
Added new test:
produceConsumeTestExcludeNewRelicHeader()
:exclude_newrelic_header
: true configurationKafkaHeadersAdapter
(test-scoped adapter) to manually accept W3C headersAdded new test configuration to validate exclusion of the newrelic header in
span_events_test
.Ran through a few e2e tests to validate the following scenarios:
addDistributedTraceHeadersToKafkaRecord
function fired off byproduce()
withexclude_new_relic_header
set tofalse
. Verified consumption of the newrelic, traceparent and tracestate record headers.exclude_new_relic_header
set totrue
. Verified consumption of the traceparent and tracestate record headers.addDistributedTraceHeadersToKafkaRecord
commented out withexclude_new_relic_header
set tofalse
and verified consumption of only the newrelic record header.Checks