Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Jun 22, 2024
1 parent 7c79383 commit 5a9814d
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
import akka.http.scaladsl.model.HttpRequest;
import akka.http.scaladsl.model.HttpResponse;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.instrumentation.akkahttp.AkkaHttpUtil;
import java.util.Optional;

public final class AkkaHttpServerSingletons {

private static final Instrumenter<HttpRequest, HttpResponse> INSTRUMENTER;

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.create(
JavaagentHttpServerInstrumenters.create(
AkkaHttpUtil.instrumentationName(),
new AkkaHttpServerAttributesGetter(),
Optional.of(AkkaHttpServerHeaders.INSTANCE));
AkkaHttpServerHeaders.INSTANCE);
}

public static Instrumenter<HttpRequest, HttpResponse> instrumenter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
package io.opentelemetry.javaagent.instrumentation.grizzly;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import java.util.Optional;
import org.glassfish.grizzly.http.HttpRequestPacket;
import org.glassfish.grizzly.http.HttpResponsePacket;

Expand All @@ -18,10 +17,10 @@ public final class GrizzlySingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
JavaagentHttpServerInstrumenters.create(
"io.opentelemetry.grizzly-2.3",
new GrizzlyHttpAttributesGetter(),
Optional.of(HttpRequestHeadersGetter.INSTANCE),
HttpRequestHeadersGetter.INSTANCE,
builder ->
builder
.addContextCustomizer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
package io.opentelemetry.javaagent.instrumentation.jetty.v12_0;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import java.util.Optional;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;

Expand All @@ -19,10 +18,10 @@ public final class Jetty12Singletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
JavaagentHttpServerInstrumenters.create(
INSTRUMENTATION_NAME,
new Jetty12HttpAttributesGetter(),
Optional.of(Jetty12TextMapGetter.INSTANCE),
Jetty12TextMapGetter.INSTANCE,
builder ->
builder.addContextCustomizer(
(context, request, attributes) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.liberty.dispatcher;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import java.util.Optional;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;

public final class LibertyDispatcherSingletons {
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher-20.0";
Expand All @@ -16,10 +15,10 @@ public final class LibertyDispatcherSingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.create(
JavaagentHttpServerInstrumenters.create(
INSTRUMENTATION_NAME,
new LibertyDispatcherHttpAttributesGetter(),
Optional.of(LibertyDispatcherRequestGetter.INSTANCE));
LibertyDispatcherRequestGetter.INSTANCE);
}

public static Instrumenter<LibertyRequest, LibertyResponse> instrumenter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.netty.common.internal.NettyErrorHolder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel;
import java.util.Optional;
import org.jboss.netty.handler.codec.http.HttpResponse;

final class NettyServerSingletons {
Expand All @@ -18,10 +17,10 @@ final class NettyServerSingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
JavaagentHttpServerInstrumenters.create(
"io.opentelemetry.netty-3.8",
new NettyHttpServerAttributesGetter(),
Optional.of(NettyHeadersGetter.INSTANCE),
NettyHeadersGetter.INSTANCE,
builder ->
builder.addContextCustomizer(
(context, requestAndChannel, startAttributes) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder;
import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver;
import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel;
import java.util.Optional;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
Expand All @@ -22,11 +21,8 @@ public class NettyClientInstrumenterBuilder
private PeerServiceResolver peerServiceResolver;

public NettyClientInstrumenterBuilder(String instrumentationName, OpenTelemetry openTelemetry) {
super(
instrumentationName,
openTelemetry,
new NettyHttpClientAttributesGetter(),
Optional.of(HttpRequestHeadersSetter.INSTANCE));
super(instrumentationName, openTelemetry, new NettyHttpClientAttributesGetter());
setHeaderSetter(HttpRequestHeadersSetter.INSTANCE);
}

@CanIgnoreReturnValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
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.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import java.util.Optional;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;

public final class NettyServerSingletons {

private static final Instrumenter<HttpRequestAndChannel, HttpResponse> INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
JavaagentHttpServerInstrumenters.create(
"io.opentelemetry.netty-4.0",
new NettyHttpServerAttributesGetter(),
Optional.of(HttpRequestHeadersGetter.INSTANCE),
HttpRequestHeadersGetter.INSTANCE,
builder ->
builder.addContextCustomizer(
(context, requestAndChannel, startAttributes) -> NettyErrorHolder.init(context)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.PekkoHttpUtil;
import java.util.Optional;
import org.apache.pekko.http.scaladsl.model.HttpRequest;
import org.apache.pekko.http.scaladsl.model.HttpResponse;

Expand All @@ -18,10 +17,10 @@ public final class PekkoHttpServerSingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.create(
JavaagentHttpServerInstrumenters.create(
PekkoHttpUtil.instrumentationName(),
new PekkoHttpServerAttributesGetter(),
Optional.of(PekkoHttpServerHeaders.INSTANCE));
PekkoHttpServerHeaders.INSTANCE);
}

public static Instrumenter<HttpRequest, HttpResponse> instrumenter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter;
import io.opentelemetry.instrumentation.restlet.v1_1.RestletTelemetry;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
import org.restlet.data.Request;
import org.restlet.data.Response;
Expand All @@ -20,7 +20,7 @@ public final class RestletSingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.create(
JavaagentHttpServerInstrumenters.create(
RestletTelemetry.builder(GlobalOpenTelemetry.get()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter;
import io.opentelemetry.instrumentation.restlet.v2_0.RestletTelemetry;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
import org.restlet.Request;
import org.restlet.Response;

public final class RestletSingletons {

private static final Instrumenter<Request, Response> INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.create(
RestletTelemetry.create(GlobalOpenTelemetry.get()));
JavaagentHttpServerInstrumenters.create(RestletTelemetry.create(GlobalOpenTelemetry.get()));

public static Instrumenter<Request, Response> instrumenter() {
return INSTRUMENTER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor;
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -51,7 +51,7 @@ public Instrumenter<ServletRequestContext<REQUEST>, ServletResponseContext<RESPO
instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter)
.setHeaderGetter(new ServletRequestGetter<>(accessor));
serverBuilder.setSpanNameExtractor(e -> spanNameExtractor);
return JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
return JavaagentHttpServerInstrumenters.create(
serverBuilder,
builder -> {
if (ServletRequestParametersExtractor.enabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
package io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.webmvc;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.CommonConfigUtil;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil;
import io.opentelemetry.instrumentation.spring.webmvc.v5_3.SpringWebMvcTelemetry;
import io.opentelemetry.instrumentation.spring.webmvc.v5_3.SpringWebMvcTelemetryBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import javax.servlet.Filter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -27,9 +25,9 @@ public class SpringWebMvc5InstrumentationAutoConfiguration {

@Bean
Filter otelWebMvcFilter(OpenTelemetry openTelemetry, ConfigProperties config) {
SpringWebMvcTelemetryBuilder builder = SpringWebMvcTelemetry.builder(openTelemetry);
DefaultHttpServerInstrumenterBuilder.unwrapAndConfigure(
CommonConfigUtil.getCommonConfig(config), builder);
return builder.build().createServletFilter();
return InstrumentationConfigUtil.configureBuilder(
config, SpringWebMvcTelemetry.builder(openTelemetry))
.build()
.createServletFilter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
package io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.webmvc;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.CommonConfigUtil;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil;
import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetry;
import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetryBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import jakarta.servlet.Filter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -27,9 +25,9 @@ public class SpringWebMvc6InstrumentationAutoConfiguration {

@Bean
Filter otelWebMvcFilter(OpenTelemetry openTelemetry, ConfigProperties config) {
SpringWebMvcTelemetryBuilder builder = SpringWebMvcTelemetry.builder(openTelemetry);
DefaultHttpServerInstrumenterBuilder.unwrapAndConfigure(
CommonConfigUtil.getCommonConfig(config), builder);
return builder.build().createServletFilter();
return InstrumentationConfigUtil.configureBuilder(
config, SpringWebMvcTelemetry.builder(openTelemetry))
.build()
.createServletFilter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
package io.opentelemetry.javaagent.instrumentation.tomcat.common;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor;
import io.opentelemetry.javaagent.instrumentation.servlet.ServletErrorCauseExtractor;
import java.util.Optional;
import org.apache.coyote.Request;
import org.apache.coyote.Response;

Expand All @@ -20,10 +19,10 @@ private TomcatInstrumenterFactory() {}

public static <REQUEST, RESPONSE> Instrumenter<Request, Response> create(
String instrumentationName, ServletAccessor<REQUEST, RESPONSE> accessor) {
return JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
return JavaagentHttpServerInstrumenters.create(
instrumentationName,
new TomcatHttpAttributesGetter(),
Optional.of(TomcatRequestGetter.INSTANCE),
TomcatRequestGetter.INSTANCE,
builder ->
builder
.setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
package io.opentelemetry.javaagent.instrumentation.undertow;

import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge;
import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers;
import io.undertow.server.HttpServerExchange;
import java.util.Optional;

public final class UndertowSingletons {
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.undertow-1.4";
Expand All @@ -19,10 +18,10 @@ public final class UndertowSingletons {

static {
INSTRUMENTER =
JavaagentHttpServerInstrumenterBuilder.createWithCustomizer(
JavaagentHttpServerInstrumenters.create(
INSTRUMENTATION_NAME,
new UndertowHttpAttributesGetter(),
Optional.of(UndertowExchangeGetter.INSTANCE),
UndertowExchangeGetter.INSTANCE,
builder ->
builder.addContextCustomizer(
(context, request, attributes) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> create(
HttpClientAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
TextMapSetter<REQUEST> headerSetter,
Consumer<InstrumenterBuilder<REQUEST, RESPONSE>> instrumenterBuilderConsumer) {
DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> DefaultHttpClientInstrumenterBuilder =
DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> defaultHttpClientTelemetryBuilder =
new DefaultHttpClientInstrumenterBuilder<>(
instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter);
if (headerSetter != null) {
DefaultHttpClientInstrumenterBuilder.setHeaderSetter(headerSetter);
defaultHttpClientTelemetryBuilder.setHeaderSetter(headerSetter);
}
return create(DefaultHttpClientInstrumenterBuilder, instrumenterBuilderConsumer);
return create(defaultHttpClientTelemetryBuilder, instrumenterBuilderConsumer);
}

private static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> create(
Expand Down
Loading

0 comments on commit 5a9814d

Please sign in to comment.