All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters Maven / Gradle / Ivy

There is a newer version: 2.11.0-alpha
Show newest version
/*
 * 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.TextMapGetter;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
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 JavaagentHttpServerInstrumenters {

  private JavaagentHttpServerInstrumenters() {}

  public static  Instrumenter create(
      String instrumentationName,
      HttpServerAttributesGetter httpAttributesGetter,
      TextMapGetter headerGetter) {
    return create(instrumentationName, httpAttributesGetter, headerGetter, customizer -> {});
  }

  public static  Instrumenter create(
      DefaultHttpServerInstrumenterBuilder builder) {
    return create(builder, customizer -> {});
  }

  public static  Instrumenter create(
      String instrumentationName,
      HttpServerAttributesGetter httpAttributesGetter,
      TextMapGetter headerGetter,
      Consumer> instrumenterBuilderConsumer) {
    return create(
        DefaultHttpServerInstrumenterBuilder.create(
            instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter, headerGetter),
        instrumenterBuilderConsumer);
  }

  public static  Instrumenter create(
      DefaultHttpServerInstrumenterBuilder builder,
      Consumer> builderCustomizer) {
    return builder
        .configure(AgentCommonConfig.get())
        .setBuilderCustomizer(builderCustomizer)
        .build();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy