-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate GWT to Instrumenter API (#3146)
* Migrate GWT to Instrumenter API * TODO * instrumenter()
- Loading branch information
Anuraag Agrawal
authored
Jun 1, 2021
1 parent
c3dedbb
commit 5cbade4
Showing
5 changed files
with
106 additions
and
68 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...c/main/java/io/opentelemetry/javaagent/instrumentation/gwt/GwtRpcAttributesExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.javaagent.instrumentation.gwt; | ||
|
||
import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesExtractor; | ||
import java.lang.reflect.Method; | ||
|
||
final class GwtRpcAttributesExtractor extends RpcAttributesExtractor<Method, Void> { | ||
@Override | ||
protected String system(Method method) { | ||
return "gwt"; | ||
} | ||
|
||
@Override | ||
protected String service(Method method) { | ||
return method.getDeclaringClass().getName(); | ||
} | ||
|
||
@Override | ||
protected String method(Method method) { | ||
return method.getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/gwt/GwtSingletons.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.gwt; | ||
|
||
import io.opentelemetry.api.GlobalOpenTelemetry; | ||
import io.opentelemetry.context.ContextKey; | ||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; | ||
import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcAttributesExtractor; | ||
import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcSpanNameExtractor; | ||
import java.lang.reflect.Method; | ||
|
||
public final class GwtSingletons { | ||
|
||
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.javaagent.gwt-2.0"; | ||
|
||
public static final ContextKey<Boolean> RPC_CONTEXT_KEY = | ||
ContextKey.named("opentelemetry-gwt-rpc-context-key"); | ||
|
||
private static final Instrumenter<Method, Void> INSTRUMENTER; | ||
|
||
static { | ||
RpcAttributesExtractor<Method, Void> rpcAttributes = new GwtRpcAttributesExtractor(); | ||
INSTRUMENTER = | ||
Instrumenter.<Method, Void>newBuilder( | ||
GlobalOpenTelemetry.get(), | ||
INSTRUMENTATION_NAME, | ||
RpcSpanNameExtractor.create(rpcAttributes)) | ||
.addAttributesExtractor(rpcAttributes) | ||
// TODO(anuraaga): This should be a server span, but we currently have no way to merge | ||
// with the HTTP instrumentation's server span. | ||
.newInstrumenter(); | ||
} | ||
|
||
public static Instrumenter<Method, Void> instrumenter() { | ||
return INSTRUMENTER; | ||
} | ||
|
||
private GwtSingletons() {} | ||
} |
56 changes: 0 additions & 56 deletions
56
...2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/gwt/GwtTracer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters