Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Jul 11, 2024
1 parent a8db58f commit c08a511
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.opentelemetry.api.GlobalOpenTelemetry;
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.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory;
import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters;
import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath;
import org.restlet.Request;
Expand All @@ -17,7 +17,8 @@
public final class RestletSingletons {

private static final Instrumenter<Request, Response> INSTRUMENTER =
JavaagentHttpServerInstrumenters.create(RestletTelemetry.create(GlobalOpenTelemetry.get()));
JavaagentHttpServerInstrumenters.create(
RestletTelemetryBuilderFactory.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 @@ -11,8 +11,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletHeadersGetter;
import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletHttpAttributesGetter;
import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
Expand All @@ -25,10 +24,7 @@ public final class RestletTelemetryBuilder {
private final DefaultHttpServerInstrumenterBuilder<Request, Response> builder;

RestletTelemetryBuilder(OpenTelemetry openTelemetry) {
builder =
new DefaultHttpServerInstrumenterBuilder<>(
"io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE)
.setHeaderGetter(new RestletHeadersGetter());
builder = RestletTelemetryBuilderFactory.create(openTelemetry);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
import org.restlet.Request;
import org.restlet.util.Series;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public final class RestletHeadersGetter implements TextMapGetter<Request> {
final class RestletHeadersGetter implements TextMapGetter<Request> {

private static final MethodHandle GET_ATTRIBUTES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import org.restlet.Response;
import org.restlet.util.Series;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public enum RestletHttpAttributesGetter implements HttpServerAttributesGetter<Request, Response> {
enum RestletHttpAttributesGetter implements HttpServerAttributesGetter<Request, Response> {
INSTANCE;

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.restlet.v2_0.internal;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder;
import org.restlet.Request;
import org.restlet.Response;

/**
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
public class RestletTelemetryBuilderFactory {
private RestletTelemetryBuilderFactory() {}

public static DefaultHttpServerInstrumenterBuilder<Request, Response> create(
OpenTelemetry openTelemetry) {
return new DefaultHttpServerInstrumenterBuilder<>(
"io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE)
.setHeaderGetter(new RestletHeadersGetter());
}
}

0 comments on commit c08a511

Please sign in to comment.