io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpClientInstrumenters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Show all versions of opentelemetry-javaagent-extension-api Show documentation
Instrumentation of Java libraries using OpenTelemetry.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.bootstrap.internal;
import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.context.propagation.TextMapSetter;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter;
import java.util.function.Consumer;
/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public final class JavaagentHttpClientInstrumenters {
private JavaagentHttpClientInstrumenters() {}
public static Instrumenter create(
String instrumentationName,
HttpClientAttributesGetter httpAttributesGetter) {
return create(
DefaultHttpClientInstrumenterBuilder.create(
instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter),
b -> {});
}
public static Instrumenter create(
String instrumentationName,
HttpClientAttributesGetter httpAttributesGetter,
TextMapSetter headerSetter) {
return create(instrumentationName, httpAttributesGetter, headerSetter, b -> {});
}
public static Instrumenter create(
DefaultHttpClientInstrumenterBuilder builder) {
return create(builder, customizer -> {});
}
public static Instrumenter create(
String instrumentationName,
HttpClientAttributesGetter httpAttributesGetter,
TextMapSetter headerSetter,
Consumer> instrumenterBuilderConsumer) {
return create(
DefaultHttpClientInstrumenterBuilder.create(
instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter, headerSetter),
instrumenterBuilderConsumer);
}
private static Instrumenter create(
DefaultHttpClientInstrumenterBuilder builder,
Consumer> builderCustomizer) {
return builder
.configure(AgentCommonConfig.get())
.setBuilderCustomizer(builderCustomizer)
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy