-
Notifications
You must be signed in to change notification settings - Fork 989
add Nullaway to instrumentation API #14458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5bc086e
d16707b
4d54a50
874d97a
727a0f9
112dba3
71da049
517f9ce
df0b464
8cd8645
20dbf20
2e8c988
7808663
8f19ff3
54d0023
5786c07
c3287cf
dca4806
06e0c6f
98dbb5f
67d3234
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,10 @@ | |
@State(Scope.Thread) | ||
public class InstrumenterBenchmark { | ||
|
||
private static final Instrumenter<Void, Void> INSTRUMENTER = | ||
Instrumenter.<Void, Void>builder( | ||
private static final Object REQUEST = new Object(); | ||
|
||
private static final Instrumenter<Object, Void> INSTRUMENTER = | ||
Instrumenter.<Object, Void>builder( | ||
Comment on lines
-36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why were these changes needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it passed |
||
OpenTelemetry.noop(), | ||
"benchmark", | ||
HttpSpanNameExtractor.create(ConstantHttpAttributesGetter.INSTANCE)) | ||
|
@@ -44,75 +46,76 @@ public class InstrumenterBenchmark { | |
|
||
@Benchmark | ||
public Context start() { | ||
return INSTRUMENTER.start(Context.root(), null); | ||
return INSTRUMENTER.start(Context.root(), REQUEST); | ||
} | ||
|
||
@Benchmark | ||
public Context startEnd() { | ||
Context context = INSTRUMENTER.start(Context.root(), null); | ||
INSTRUMENTER.end(context, null, null, null); | ||
Context context = INSTRUMENTER.start(Context.root(), REQUEST); | ||
INSTRUMENTER.end(context, REQUEST, null, null); | ||
return context; | ||
} | ||
|
||
enum ConstantHttpAttributesGetter implements HttpClientAttributesGetter<Void, Void> { | ||
enum ConstantHttpAttributesGetter implements HttpClientAttributesGetter<Object, Void> { | ||
INSTANCE; | ||
|
||
private static final InetSocketAddress PEER_ADDRESS = | ||
InetSocketAddress.createUnresolved("localhost", 8080); | ||
|
||
@Override | ||
public String getUrlFull(Void unused) { | ||
public String getUrlFull(Object unused) { | ||
return "https://opentelemetry.io/benchmark"; | ||
} | ||
|
||
@Override | ||
public String getHttpRequestMethod(Void unused) { | ||
public String getHttpRequestMethod(Object unused) { | ||
return "GET"; | ||
} | ||
|
||
@Override | ||
public List<String> getHttpRequestHeader(Void unused, String name) { | ||
public List<String> getHttpRequestHeader(Object unused, String name) { | ||
if (name.equalsIgnoreCase("user-agent")) { | ||
return Collections.singletonList("OpenTelemetryBot"); | ||
} | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Integer getHttpResponseStatusCode(Void unused, Void unused2, @Nullable Throwable error) { | ||
public Integer getHttpResponseStatusCode( | ||
Object unused, Void unused2, @Nullable Throwable error) { | ||
return 200; | ||
} | ||
|
||
@Override | ||
public List<String> getHttpResponseHeader(Void unused, Void unused2, String name) { | ||
public List<String> getHttpResponseHeader(Object unused, Void unused2, String name) { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public String getNetworkProtocolName(Void unused, @Nullable Void unused2) { | ||
public String getNetworkProtocolName(Object unused, @Nullable Void unused2) { | ||
return "http"; | ||
} | ||
|
||
@Override | ||
public String getNetworkProtocolVersion(Void unused, @Nullable Void unused2) { | ||
public String getNetworkProtocolVersion(Object unused, @Nullable Void unused2) { | ||
return "2.0"; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getServerAddress(Void request) { | ||
public String getServerAddress(Object request) { | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Integer getServerPort(Void request) { | ||
public Integer getServerPort(Object request) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public InetSocketAddress getNetworkPeerInetSocketAddress( | ||
Void request, @Nullable Void response) { | ||
Object request, @Nullable Void response) { | ||
return PEER_ADDRESS; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,10 @@ public static HttpRouteState create( | |
|
||
// this method is used reflectively from InstrumentationApiContextBridging | ||
public static HttpRouteState create( | ||
@Nullable String method, @Nullable String route, int updatedBySourceOrder, Span span) { | ||
@Nullable String method, | ||
@Nullable String route, | ||
int updatedBySourceOrder, | ||
@Nullable Span span) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just checking, is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just above: |
||
return new HttpRouteState(method, route, updatedBySourceOrder, span); | ||
} | ||
|
||
|
@@ -50,7 +53,10 @@ public static HttpRouteState create( | |
@Nullable private volatile Span span; | ||
|
||
private HttpRouteState( | ||
@Nullable String method, @Nullable String route, int updatedBySourceOrder, Span span) { | ||
@Nullable String method, | ||
@Nullable String route, | ||
int updatedBySourceOrder, | ||
@Nullable Span span) { | ||
this.method = method; | ||
this.updatedBySourceOrder = updatedBySourceOrder; | ||
this.route = route; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.internal; | ||
|
||
/** | ||
* See <a href="https://github.com/uber/NullAway/wiki/Supported-Annotations#initialization">NullAway | ||
* spec</a> | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public @interface Initializer {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to make the
operation
nullable?