Skip to content

Commit

Permalink
Move experimental things out of public api
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Dec 7, 2024
1 parent 80ccda1 commit a72ae3f
Show file tree
Hide file tree
Showing 22 changed files with 611 additions and 0 deletions.
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 Down Expand Up @@ -88,7 +89,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#setEmitExperimentalHttpClientMetrics(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,51 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static java.util.logging.Level.FINE;

import io.opentelemetry.instrumentation.apachehttpclient.v4_3.ApacheHttpClientTelemetryBuilder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
// TODO (trask) update the above javadoc similar to
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
public class Experimental {

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

@Nullable
private static final Method emitExperimentalHttpClientMetricsMethod =
getEmitExperimentalHttpClientMetricsMethod();

static Method getEmitExperimentalHttpClientMetricsMethod() {
try {
return ApacheHttpClientTelemetryBuilder.class.getMethod(
"setEmitExperimentalHttpClientMetrics", boolean.class);
} catch (NoSuchMethodException e) {
logger.log(FINE, e.getMessage(), e);
return null;
}
}

public void setEmitExperimentalHttpClientMetrics(
ApacheHttpClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {

if (emitExperimentalHttpClientMetricsMethod != null) {
try {
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.log(FINE, e.getMessage(), e);
}
}
}
}
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.v5_2.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 Down Expand Up @@ -90,7 +91,11 @@ public ApacheHttpClient5TelemetryBuilder setKnownMethods(Set<String> knownMethod
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalHttpClientMetrics(ApacheHttpClient5TelemetryBuilder,
* boolean)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static java.util.logging.Level.FINE;

import io.opentelemetry.instrumentation.apachehttpclient.v5_2.ApacheHttpClient5TelemetryBuilder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
// TODO (trask) update the above javadoc similar to
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
public class Experimental {

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

@Nullable
private static final Method emitExperimentalHttpClientMetricsMethod =
getEmitExperimentalHttpClientMetricsMethod();

static Method getEmitExperimentalHttpClientMetricsMethod() {
try {
return ApacheHttpClient5TelemetryBuilder.class.getMethod(
"setEmitExperimentalHttpClientMetrics", boolean.class);
} catch (NoSuchMethodException e) {
logger.log(FINE, e.getMessage(), e);
return null;
}
}

public void setEmitExperimentalHttpClientMetrics(
ApacheHttpClient5TelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {

if (emitExperimentalHttpClientMetricsMethod != null) {
try {
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.log(FINE, e.getMessage(), e);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -201,7 +202,11 @@ public ArmeriaTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalHttpClientMetrics(ArmeriaTelemetryBuilder, boolean)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
public ArmeriaTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.armeria.v1_3.internal;

import static java.util.logging.Level.FINE;

import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetryBuilder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
// TODO (trask) update the above javadoc similar to
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
public class Experimental {

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

@Nullable
private static final Method emitExperimentalHttpClientMetricsMethod =
getEmitExperimentalHttpClientMetricsMethod();

static Method getEmitExperimentalHttpClientMetricsMethod() {
try {
return ArmeriaTelemetryBuilder.class.getMethod(
"setEmitExperimentalHttpClientMetrics", boolean.class);
} catch (NoSuchMethodException e) {
logger.log(FINE, e.getMessage(), e);
return null;
}
}

public void setEmitExperimentalHttpClientMetrics(
ArmeriaTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {

if (emitExperimentalHttpClientMetricsMethod != null) {
try {
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.log(FINE, e.getMessage(), e);
}
}
}
}
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 Down Expand Up @@ -86,7 +87,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#setEmitExperimentalHttpClientMetrics(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,51 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.httpclient.internal;

import static java.util.logging.Level.FINE;

import io.opentelemetry.instrumentation.httpclient.JavaHttpClientTelemetryBuilder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
// TODO (trask) update the above javadoc similar to
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
public class Experimental {

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

@Nullable
private static final Method emitExperimentalHttpClientMetricsMethod =
getEmitExperimentalHttpClientMetricsMethod();

static Method getEmitExperimentalHttpClientMetricsMethod() {
try {
return JavaHttpClientTelemetryBuilder.class.getMethod(
"setEmitExperimentalHttpClientMetrics", boolean.class);
} catch (NoSuchMethodException e) {
logger.log(FINE, e.getMessage(), e);
return null;
}
}

public void setEmitExperimentalHttpClientMetrics(
JavaHttpClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {

if (emitExperimentalHttpClientMetricsMethod != null) {
try {
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.log(FINE, e.getMessage(), e);
}
}
}
}
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 Down Expand Up @@ -101,7 +102,11 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalHttpClientMetrics(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,51 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

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

import static java.util.logging.Level.FINE;

import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.JettyClientTelemetryBuilder;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
// TODO (trask) update the above javadoc similar to
// https://github.com/open-telemetry/opentelemetry-java/pull/6886
public class Experimental {

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

@Nullable
private static final Method emitExperimentalHttpClientMetricsMethod =
getEmitExperimentalHttpClientMetricsMethod();

static Method getEmitExperimentalHttpClientMetricsMethod() {
try {
return JettyClientTelemetryBuilder.class.getMethod(
"setEmitExperimentalHttpClientMetrics", boolean.class);
} catch (NoSuchMethodException e) {
logger.log(FINE, e.getMessage(), e);
return null;
}
}

public void setEmitExperimentalHttpClientMetrics(
JettyClientTelemetryBuilder builder, boolean emitExperimentalHttpClientMetrics) {

if (emitExperimentalHttpClientMetricsMethod != null) {
try {
emitExperimentalHttpClientMetricsMethod.invoke(builder, emitExperimentalHttpClientMetrics);
} catch (IllegalAccessException | InvocationTargetException e) {
logger.log(FINE, e.getMessage(), e);
}
}
}
}
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 Down Expand Up @@ -101,7 +102,11 @@ public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
*
* @param emitExperimentalHttpClientMetrics {@code true} if the experimental HTTP client metrics
* are to be emitted.
* @deprecated Use {@link
* Experimental#setEmitExperimentalHttpClientMetrics(JettyClientTelemetryBuilder, boolean)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
boolean emitExperimentalHttpClientMetrics) {
Expand Down
Loading

0 comments on commit a72ae3f

Please sign in to comment.