Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated rocketmq setting #10125

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,21 @@
import io.opentelemetry.instrumentation.rocketmqclient.v4_8.RocketMqTelemetry;
import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig;
import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig;
import java.util.logging.Logger;
import org.apache.rocketmq.client.hook.ConsumeMessageHook;
import org.apache.rocketmq.client.hook.SendMessageHook;

public final class RocketMqClientHooks {

private static final Logger logger = Logger.getLogger(RocketMqClientHooks.class.getName());

@SuppressWarnings("deprecation") // call to deprecated method will be removed in the future
private static final RocketMqTelemetry TELEMETRY =
RocketMqTelemetry.builder(GlobalOpenTelemetry.get())
.setCapturedHeaders(ExperimentalConfig.get().getMessagingHeaders())
.setPropagationEnabled(
InstrumentationConfig.get()
.getBoolean("otel.instrumentation.rocketmq-client.propagation", true))
.setCaptureExperimentalSpanAttributes(
InstrumentationConfig.get()
.getBoolean(
"otel.instrumentation.rocketmq-client.experimental-span-attributes", false))
.build();

static {
if (InstrumentationConfig.get().getString("otel.instrumentation.rocketmq-client.propagation")
!= null) {
logger.warning(
"The \"otel.instrumentation.rocketmq-client.propagation\" configuration property has"
+ " been deprecated and will be removed in a future version."
+ " If you have a need for this configuration property, please open an issue in the"
+ " opentelemetry-java-instrumentation repository:"
+ " https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues");
}
}

public static final ConsumeMessageHook CONSUME_MESSAGE_HOOK =
TELEMETRY.newTracingConsumeMessageHook();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class RocketMqInstrumenterFactory {
static Instrumenter<SendMessageContext, Void> createProducerInstrumenter(
OpenTelemetry openTelemetry,
List<String> capturedHeaders,
boolean captureExperimentalSpanAttributes,
boolean propagationEnabled) {
boolean captureExperimentalSpanAttributes) {

RocketMqProducerAttributeGetter getter = RocketMqProducerAttributeGetter.INSTANCE;
MessageOperation operation = MessageOperation.PUBLISH;
Expand All @@ -49,18 +48,13 @@ static Instrumenter<SendMessageContext, Void> createProducerInstrumenter(
RocketMqProducerExperimentalAttributeExtractor.INSTANCE);
}

if (propagationEnabled) {
return instrumenterBuilder.buildProducerInstrumenter(MapSetter.INSTANCE);
} else {
return instrumenterBuilder.buildInstrumenter(SpanKindExtractor.alwaysProducer());
}
return instrumenterBuilder.buildProducerInstrumenter(MapSetter.INSTANCE);
}

static RocketMqConsumerInstrumenter createConsumerInstrumenter(
OpenTelemetry openTelemetry,
List<String> capturedHeaders,
boolean captureExperimentalSpanAttributes,
boolean propagationEnabled) {
boolean captureExperimentalSpanAttributes) {

InstrumenterBuilder<Void, Void> batchReceiveInstrumenterBuilder =
Instrumenter.<Void, Void>builder(
Expand All @@ -70,25 +64,16 @@ static RocketMqConsumerInstrumenter createConsumerInstrumenter(

return new RocketMqConsumerInstrumenter(
createProcessInstrumenter(
openTelemetry,
capturedHeaders,
captureExperimentalSpanAttributes,
propagationEnabled,
false),
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes, false),
createProcessInstrumenter(
openTelemetry,
capturedHeaders,
captureExperimentalSpanAttributes,
propagationEnabled,
true),
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes, true),
batchReceiveInstrumenterBuilder.buildInstrumenter(SpanKindExtractor.alwaysConsumer()));
}

private static Instrumenter<MessageExt, Void> createProcessInstrumenter(
OpenTelemetry openTelemetry,
List<String> capturedHeaders,
boolean captureExperimentalSpanAttributes,
boolean propagationEnabled,
boolean batch) {

RocketMqConsumerAttributeGetter getter = RocketMqConsumerAttributeGetter.INSTANCE;
Expand All @@ -106,10 +91,6 @@ private static Instrumenter<MessageExt, Void> createProcessInstrumenter(
builder.addAttributesExtractor(RocketMqConsumerExperimentalAttributeExtractor.INSTANCE);
}

if (!propagationEnabled) {
return builder.buildInstrumenter(SpanKindExtractor.alwaysConsumer());
}

if (batch) {
SpanLinksExtractor<MessageExt> spanLinksExtractor =
new PropagatorBasedSpanLinksExtractor<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ public static RocketMqTelemetryBuilder builder(OpenTelemetry openTelemetry) {
RocketMqTelemetry(
OpenTelemetry openTelemetry,
List<String> capturedHeaders,
boolean captureExperimentalSpanAttributes,
boolean propagationEnabled) {
boolean captureExperimentalSpanAttributes) {
rocketMqConsumerInstrumenter =
RocketMqInstrumenterFactory.createConsumerInstrumenter(
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes, propagationEnabled);
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes);
rocketMqProducerInstrumenter =
RocketMqInstrumenterFactory.createProducerInstrumenter(
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes, propagationEnabled);
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public final class RocketMqTelemetryBuilder {

private List<String> capturedHeaders = emptyList();
private boolean captureExperimentalSpanAttributes;
private boolean propagationEnabled = true;

RocketMqTelemetryBuilder(OpenTelemetry openTelemetry) {
this.openTelemetry = openTelemetry;
Expand All @@ -36,21 +35,6 @@ public RocketMqTelemetryBuilder setCaptureExperimentalSpanAttributes(
return this;
}

/**
* Sets whether the trace context should be written from producers / read from consumers for
* propagating through messaging.
*
* @deprecated if you have a need for this configuration option please open an issue in the <a
* href="https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues">opentelemetry-java-instrumentation</a>
* repository.
*/
@Deprecated
@CanIgnoreReturnValue
public RocketMqTelemetryBuilder setPropagationEnabled(boolean propagationEnabled) {
this.propagationEnabled = propagationEnabled;
return this;
}

/**
* Configures the messaging headers that will be captured as span attributes.
*
Expand All @@ -67,7 +51,6 @@ public RocketMqTelemetryBuilder setCapturedHeaders(List<String> capturedHeaders)
* RocketMqTelemetryBuilder}.
*/
public RocketMqTelemetry build() {
return new RocketMqTelemetry(
openTelemetry, capturedHeaders, captureExperimentalSpanAttributes, propagationEnabled);
return new RocketMqTelemetry(openTelemetry, capturedHeaders, captureExperimentalSpanAttributes);
}
}
Loading