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 experimental methods out of (to-be-public) TelemetryBuilder classes #12847

Merged
merged 8 commits into from
Dec 17, 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 @@ -7,6 +7,7 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal.Experimental;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
Expand All @@ -23,6 +24,11 @@ public final class ApacheHttpClientTelemetryBuilder {
private final DefaultHttpClientInstrumenterBuilder<ApacheHttpClientRequest, HttpResponse> builder;
private final OpenTelemetry openTelemetry;

static {
Experimental.setSetEmitExperimentalTelemetry(
(builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit));
}

ApacheHttpClientTelemetryBuilder(OpenTelemetry openTelemetry) {
builder =
DefaultHttpClientInstrumenterBuilder.create(
Expand Down Expand Up @@ -103,7 +109,11 @@ public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalTelemetry(ApacheHttpClientTelemetryBuilder, boolean)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.apachehttpclient.v4_3.internal;

import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class Experimental {

@Nullable
private static volatile BiConsumer<ApacheHttpClientTelemetryBuilder, Boolean>
setEmitExperimentalTelemetry;

public static void setEmitExperimentalTelemetry(
ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) {
if (setEmitExperimentalTelemetry != null) {
setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry);
}
}

public static void setSetEmitExperimentalTelemetry(
BiConsumer<ApacheHttpClientTelemetryBuilder, Boolean> setEmitExperimentalTelemetry) {
Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry;
}

private Experimental() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.httpclient.internal.Experimental;
import io.opentelemetry.instrumentation.httpclient.internal.HttpHeadersSetter;
import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientInstrumenterBuilderFactory;
import java.net.http.HttpRequest;
Expand All @@ -24,6 +25,11 @@ public final class JavaHttpClientTelemetryBuilder {
private final DefaultHttpClientInstrumenterBuilder<HttpRequest, HttpResponse<?>> builder;
private final OpenTelemetry openTelemetry;

static {
Experimental.setSetEmitExperimentalTelemetry(
(builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit));
}

JavaHttpClientTelemetryBuilder(OpenTelemetry openTelemetry) {
builder = JavaHttpClientInstrumenterBuilderFactory.create(openTelemetry);
this.openTelemetry = openTelemetry;
Expand Down Expand Up @@ -100,7 +106,11 @@ public JavaHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods)
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalTelemetry(JavaHttpClientTelemetryBuilder, boolean)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.httpclient.internal;

import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class Experimental {

@Nullable
private static volatile BiConsumer<JavaHttpClientTelemetryBuilder, Boolean>
setEmitExperimentalTelemetry;

public static void setEmitExperimentalTelemetry(
JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) {
if (setEmitExperimentalTelemetry != null) {
setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry);
}
}

public static void setSetEmitExperimentalTelemetry(
BiConsumer<JavaHttpClientTelemetryBuilder, Boolean> setEmitExperimentalTelemetry) {
Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry;
}

private Experimental() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.Experimental;
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.JettyHttpClientInstrumenterBuilderFactory;
import java.util.List;
import java.util.Set;
Expand All @@ -26,6 +27,11 @@ public final class JettyClientTelemetryBuilder {
private HttpClientTransport httpClientTransport;
private SslContextFactory.Client sslContextFactory;

static {
Experimental.setSetEmitExperimentalTelemetry(
(builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit));
}

JettyClientTelemetryBuilder(OpenTelemetry openTelemetry) {
builder = JettyHttpClientInstrumenterBuilderFactory.create(openTelemetry);
}
Expand Down Expand Up @@ -115,7 +121,10 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(JettyClientTelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal;

import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class Experimental {

@Nullable
private static volatile BiConsumer<JettyClientTelemetryBuilder, Boolean>
setEmitExperimentalTelemetry;

public static void setEmitExperimentalTelemetry(
JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) {
if (setEmitExperimentalTelemetry != null) {
setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry);
}
}

public static void setSetEmitExperimentalTelemetry(
BiConsumer<JettyClientTelemetryBuilder, Boolean> setEmitExperimentalTelemetry) {
Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry;
}

private Experimental() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.Experimental;
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientInstrumenterBuilderFactory;
import java.util.List;
import java.util.Set;
Expand All @@ -27,6 +28,11 @@ public final class JettyClientTelemetryBuilder {
private HttpClientTransport httpClientTransport;
private SslContextFactory sslContextFactory;

static {
Experimental.setSetEmitExperimentalTelemetry(
(builder, emit) -> builder.builder.setEmitExperimentalHttpClientMetrics(emit));
}

JettyClientTelemetryBuilder(OpenTelemetry openTelemetry) {
builder = JettyHttpClientInstrumenterBuilderFactory.create(openTelemetry);
}
Expand Down Expand Up @@ -115,7 +121,10 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(JettyClientTelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal;

import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.JettyClientTelemetryBuilder;
import java.util.function.BiConsumer;
import javax.annotation.Nullable;

/**
* This class is internal and experimental. Its APIs are unstable and can change at any time. Its
* APIs (or a version of them) may be promoted to the public stable API in the future, but no
* guarantees are made.
*/
public final class Experimental {

@Nullable
private static volatile BiConsumer<JettyClientTelemetryBuilder, Boolean>
setEmitExperimentalTelemetry;

public static void setEmitExperimentalTelemetry(
JettyClientTelemetryBuilder builder, boolean emitExperimentalTelemetry) {
if (setEmitExperimentalTelemetry != null) {
setEmitExperimentalTelemetry.accept(builder, emitExperimentalTelemetry);
}
}

public static void setSetEmitExperimentalTelemetry(
BiConsumer<JettyClientTelemetryBuilder, Boolean> setEmitExperimentalTelemetry) {
Experimental.setEmitExperimentalTelemetry = setEmitExperimentalTelemetry;
}

private Experimental() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterBuilderFactory;
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory;
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumentationFlag;
import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
Expand All @@ -26,11 +27,24 @@ public final class NettyClientTelemetryBuilder {
private final DefaultHttpClientInstrumenterBuilder<HttpRequestAndChannel, HttpResponse> builder;
private boolean emitExperimentalHttpClientEvents = false;

static {
Experimental.setSetEmitExperimentalClientTelemetry(
(builder, emit) -> {
builder.builder.setEmitExperimentalHttpClientMetrics(emit);
builder.emitExperimentalHttpClientEvents = emit;
});
}

NettyClientTelemetryBuilder(OpenTelemetry openTelemetry) {
builder =
NettyClientInstrumenterBuilderFactory.create("io.opentelemetry.netty-4.1", openTelemetry);
}

/**
* @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyClientTelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public NettyClientTelemetryBuilder setEmitExperimentalHttpClientEvents(
boolean emitExperimentalHttpClientEvents) {
Expand Down Expand Up @@ -97,7 +111,10 @@ public NettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyClientTelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public NettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel;
import io.opentelemetry.instrumentation.netty.v4.common.internal.server.HttpRequestHeadersGetter;
import io.opentelemetry.instrumentation.netty.v4.common.internal.server.NettyHttpServerAttributesGetter;
import io.opentelemetry.instrumentation.netty.v4_1.internal.Experimental;
import io.opentelemetry.instrumentation.netty.v4_1.internal.ProtocolEventHandler;
import io.opentelemetry.instrumentation.netty.v4_1.internal.server.NettyServerInstrumenterBuilderUtil;
import java.util.List;
Expand All @@ -28,6 +29,11 @@ public final class NettyServerTelemetryBuilder {
static {
NettyServerInstrumenterBuilderUtil.setBuilderExtractor(
nettyServerTelemetryBuilder -> nettyServerTelemetryBuilder.builder);
Experimental.setSetEmitExperimentalServerTelemetry(
(builder, emit) -> {
builder.builder.setEmitExperimentalHttpServerMetrics(emit);
builder.emitExperimentalHttpServerEvents = emit;
});
}

NettyServerTelemetryBuilder(OpenTelemetry openTelemetry) {
Expand Down Expand Up @@ -99,7 +105,10 @@ public NettyServerTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpServerMetrics {@code true} if the experimental HTTP server metrics
* are to be emitted.
* @deprecated Use {@link Experimental#setEmitExperimentalTelemetry(NettyServerTelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public NettyServerTelemetryBuilder setEmitExperimentalHttpServerMetrics(
boolean emitExperimentalHttpServerMetrics) {
Expand Down
Loading
Loading