Allow enabling receive telemetry in kafka library instrumentation (#9693)
This commit is contained in:
parent
48d3956bd8
commit
e7db2c0246
|
@ -30,6 +30,7 @@ public final class KafkaTelemetryBuilder {
|
|||
private List<String> capturedHeaders = emptyList();
|
||||
private boolean captureExperimentalSpanAttributes = false;
|
||||
private boolean propagationEnabled = true;
|
||||
private boolean messagingReceiveInstrumentationEnabled = false;
|
||||
|
||||
KafkaTelemetryBuilder(OpenTelemetry openTelemetry) {
|
||||
this.openTelemetry = Objects.requireNonNull(openTelemetry);
|
||||
|
@ -85,11 +86,25 @@ public final class KafkaTelemetryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to capture the consumer message receive telemetry in messaging instrumentation.
|
||||
*
|
||||
* <p>Note that this will cause the consumer side to start a new trace, with only a span link
|
||||
* connecting it to the producer trace.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public KafkaTelemetryBuilder setMessagingReceiveInstrumentationEnabled(
|
||||
boolean messagingReceiveInstrumentationEnabled) {
|
||||
this.messagingReceiveInstrumentationEnabled = messagingReceiveInstrumentationEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public KafkaTelemetry build() {
|
||||
KafkaInstrumenterFactory instrumenterFactory =
|
||||
new KafkaInstrumenterFactory(openTelemetry, INSTRUMENTATION_NAME)
|
||||
.setCapturedHeaders(capturedHeaders)
|
||||
.setCaptureExperimentalSpanAttributes(captureExperimentalSpanAttributes);
|
||||
.setCaptureExperimentalSpanAttributes(captureExperimentalSpanAttributes)
|
||||
.setMessagingReceiveInstrumentationEnabled(messagingReceiveInstrumentationEnabled);
|
||||
|
||||
return new KafkaTelemetry(
|
||||
openTelemetry,
|
||||
|
|
|
@ -50,6 +50,12 @@ public final class SpringKafkaTelemetryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to capture the consumer message receive telemetry in messaging instrumentation.
|
||||
*
|
||||
* <p>Note that this will cause the consumer side to start a new trace, with only a span link
|
||||
* connecting it to the producer trace.
|
||||
*/
|
||||
@CanIgnoreReturnValue
|
||||
public SpringKafkaTelemetryBuilder setMessagingReceiveInstrumentationEnabled(
|
||||
boolean messagingReceiveInstrumentationEnabled) {
|
||||
|
|
Loading…
Reference in New Issue