-
Notifications
You must be signed in to change notification settings - Fork 565
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 Add support for @SpanAttribute
annotation, use entire path for REST resource span name
#8216
Conversation
Signed-off-by: Tim Quinn <tim.quinn@oracle.com>
...lemetry/src/main/java/io/helidon/microprofile/telemetry/HelidonTelemetryContainerFilter.java
Outdated
Show resolved
Hide resolved
if (app == null) { | ||
return ""; | ||
} | ||
ApplicationPath applicationPath = getRealClass(app.getClass()).getAnnotation(ApplicationPath.class); |
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 you've already used things like ExtendedUriInfo
maybe there's a Jersey class that will give you whatever the @ApplicationPath
annotation ends up setting indirectly?
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 didn't see a way to do that, after quite some looking.
If you have a specific suggestion I'd welcome it but I didn't find a way to do what you suggested. The security code Tomas pointed to (in internal Slack) uses the same technique to get the Application
.
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.
Got some assignability stuff backwards, I think; have a peek
if (paramType.isAssignableFrom(String.class)) { | ||
spanBuilder.setAttribute(attrName, (String) pValue); | ||
} else if (paramType.isAssignableFrom(long.class) || paramType.isAssignableFrom(Long.class)) { | ||
spanBuilder.setAttribute(attrName, (long) pValue); | ||
} else if (paramType.isAssignableFrom(double.class) || paramType.isAssignableFrom(Double.class)) { | ||
spanBuilder.setAttribute(attrName, (double) pValue); | ||
} else if (paramType.isAssignableFrom(boolean.class) || paramType.isAssignableFrom(Boolean.class)) { | ||
spanBuilder.setAttribute(attrName, (boolean) pValue); | ||
} else { | ||
spanBuilder.setAttribute(attrName, pValue.toString()); | ||
} |
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'm pretty sure these are backwards. You want String.class.isAssignableFrom(paramType)
. Or you want to do something like:
switch (paramType) {
case Class<?> x when Long.class.isAssignableFrom(paramType): // this may? work for primitives too? can't remember if autoboxing kicks in?
spanBuilder.setAttribute(attrName, x.cast(pValue));
break;
case Class<?> x when Double.class.isAssignableFrom(paramType):
spanBuilder.setAttribute(attrName, x.cast(pValue));
break;
case Class<?> x when Boolean.class.isAssignableFrom(paramType):
spanBuilder.setAttribute(attrName, x.cast(pValue));
break;
default:
spanBuilder.setAttribute(attrName, pValue.toString());
break;
}
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.
Ah, yes. Fixed.
We could use the switch-case-with-break
approach but I chose to stay with the if-then-else-if
because to me at least it's slightly clearer.
microprofile/telemetry/src/main/java/io/helidon/microprofile/telemetry/WithSpanInterceptor.java
Show resolved
Hide resolved
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.
LGTM (not an expert in this area)
… name to pass TCK tests that do not expect it
@SpanAttribute
annotation@SpanAttribute
annotation, use entire path for REST resource span name
… update separate tests now that our filter correctly precedes the path with a slash
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.
LGTM
Description
Resolves #8157
Resolves #8162
Highlights:
WithSpanInterceptor
so it also processes@SpanAttribute
annotations.Documentation
Bug fix; no doc impact.