-
Notifications
You must be signed in to change notification settings - Fork 580
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
[4.x] - MicroProfile Telemetry Support #6493
Conversation
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/AgentDetection.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/AgentDetection.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/AgentDetection.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/AgentDetection.java
Outdated
Show resolved
Hide resolved
.../telemetry/src/main/java/io/helidon/microprofile/telemetry/HelidonTelemetryClientFilter.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/OpenTelemetryProducer.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/WithSpanInterceptor.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/WithSpanInterceptor.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/WithSpanInterceptor.java
Outdated
Show resolved
Hide resolved
WithSpan annotation = context.getMethod().getAnnotation(WithSpan.class); | ||
|
||
Context parentContext = Context.current(); | ||
Scope scope = null; |
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.
There is no point in making this variable here and setting it to null, since it is not used till line 80 and set to value directly.
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.
yep
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.
I am missing the change.
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/AgentDetection.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/OpenTelemetryProducer.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/OpenTelemetryProducer.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/OpenTelemetryProducer.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/OpenTelemetryProducer.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/main/java/io/helidon/microprofile/telemetry/TelemetryCdiExtension.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/WithSpanInterceptor.java
Outdated
Show resolved
Hide resolved
...profile/telemetry/src/test/java/io/helidon/microprofile/telemetry/TelemetryDisabledTest.java
Outdated
Show resolved
Hide resolved
microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/TelemetryTest.java
Outdated
Show resolved
Hide resolved
...tests/arquillian/src/main/java/io/helidon/microprofile/arquillian/HelidonMethodExecutor.java
Outdated
Show resolved
Hide resolved
bf6b9f3
to
33731b7
Compare
ac9b6de
to
de430ef
Compare
02f4f91
to
f5ef39c
Compare
Had to fallback to:
Otherwise fails with:
if using:
|
if (LOGGER.isLoggable(System.Logger.Level.TRACE)) { | ||
LOGGER.log(System.Logger.Level.TRACE, "Telemetry Disabled"); | ||
} | ||
openTelemetry = LazyValue.create(() -> OpenTelemetry.noop()); |
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.
Not fixed.
@PostConstruct | ||
private void init() { | ||
|
||
telemetryProperties = getTelemetryProperties(); |
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.
Is this intentional to use mutable Map here?
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.
Wrapped into Collections.unmodifiableMap
private static final String REST_RESOURCE_CLASS = "rest.resource.class"; | ||
private static final String REST_RESOURCE_METHOD = "rest.resource.method"; |
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.
I am not sure why did you mark this as resolved without any response. Are these values stored in ContainerRequestContext actually used anywhere?
/** | ||
* Provides an instance of the current OpenTelemetry Tracer. | ||
* | ||
* @param openTelemetry |
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.
missing description
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.
fixed
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.
Redundant items deleted
* Used to register {@code HelidonTelemetryContainerFilter} and {@code HelidonTelemetryClientFilter} | ||
* filers. | ||
* | ||
* @param ctx |
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.
missing description
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.
Fixed
tracing/opentelemetry/src/main/java/io/helidon/tracing/opentelemetry/HelidonOpenTelemetry.java
Outdated
Show resolved
Hide resolved
tracing/opentelemetry/src/test/java/io/helidon/tracing/opentelemetry/AgentDetectorTest.java
Outdated
Show resolved
Hide resolved
tracing/opentelemetry/src/main/java/io/helidon/tracing/opentelemetry/HelidonOpenTelemetry.java
Outdated
Show resolved
Hide resolved
...lemetry/src/main/java/io/helidon/microprofile/telemetry/HelidonTelemetryContainerFilter.java
Show resolved
Hide resolved
...lemetry/src/main/java/io/helidon/microprofile/telemetry/HelidonTelemetryContainerFilter.java
Show resolved
Hide resolved
85d6dc8
to
4c84dac
Compare
4c84dac
to
63fbd1f
Compare
private Config config; | ||
|
||
private org.eclipse.microprofile.config.Config mpConfig; |
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.
these two could be final.
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.
made final
static { | ||
CONTEXT_HEADER_INJECTOR = | ||
new TextMapGetter<>() { | ||
@Override | ||
public String get(ContainerRequestContext containerRequestContext, String s) { | ||
Objects.requireNonNull(containerRequestContext); | ||
return containerRequestContext.getHeaderString(s); | ||
} | ||
|
||
@Override | ||
public Iterable<String> keys(ContainerRequestContext containerRequestContext) { | ||
return List.copyOf(containerRequestContext.getHeaders().keySet()); | ||
} | ||
}; | ||
} |
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.
Would not this static block be better placed under the constant line it initializes?
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.
Done
private static final String HTTP_STATUS_CODE = "http.status_code"; | ||
private static final String HTTP_METHOD = "http.method"; | ||
private static final String HTTP_SCHEME = "http.scheme"; |
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.
These constants are also created in HelidonTelemetryContainerFilter
.
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.
ok
LOGGER.log(System.Logger.Level.TRACE, "Starting Span in a Client Request"); | ||
} | ||
|
||
Context parentContext = Context.current(); |
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.
Since this is not used on other places, the only usage could be replaced with Context.current() directly. This would make sense only it it was used in other places. But since on all places in this method, where Context is used, Context.current() is used instead, this is redundant.
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.
fixed
return context.proceed(); | ||
} catch (Exception e) { | ||
span.recordException(e); | ||
return context.proceed(); |
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.
This line should be throw e
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.
fixed
|
||
@Test | ||
@AddConfig(key = HelidonOpenTelemetry.OTEL_AGENT_PRESENT_PROPERTY, value = "true") | ||
void shouldBeNoOpTelemetry(){ |
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.
between ) and { should be space
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.
ok
|
||
@Test | ||
@AddConfig(key = HelidonOpenTelemetry.OTEL_AGENT_PRESENT_PROPERTY, value = "false") | ||
void shouldNotBeNoOpTelemetry(){ |
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.
between ) and { should be space
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.
ok
} | ||
|
||
@Test | ||
void checkEnvVariable(){ |
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.
between ) and { should be space
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.
ok
* If the value is not explicitly set, the detector does best effort to estimate indirect means if the agent is present. | ||
* This detector may stop working if OTEL changes the indirect indicators. | ||
*/ | ||
public static class AgentDetector { |
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.
this is basically just a util class. It has to have private constructor and it should probably be final as well.
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.
ok
} | ||
|
||
private static boolean checkContext() { | ||
return io.opentelemetry.context.Context.current().getClass().getName().contains("agent"); |
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.
Context should be imported and used without fully qualified package.
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.
Done
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.
Two more additional findings.
Resolves #5817
Currently depends on
opentelemetry-sdk-extension-autoconfigure
1.22.0-alpha.This should be fixed with OTEL MP Telemetry committee.