-
Notifications
You must be signed in to change notification settings - Fork 99
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
Spring: Cannot configure Segment name in BaseAbstractXRayInterceptor #281
Comments
I ended up rolling my own abstract class and removed the aws-xray-recorder-sdk-spring dep. It's more of an example than a library at this point, no offense. |
Hi @stnor - thanks for filing these issues. It sounds like you are adding tracing to a new app. Did you by any chance take a look at our support for OpenTelemetry? https://aws-otel.github.io/docs/getting-started/java-sdk It has far more features and can provide a better experience than XRay sdk for new apps. There is a Java agent that can automatically instrument and/or ability to manually instrument by creating spans. Our effort is mostly focused on OpenTelemetry going forward so we probably wouldn't be able to make changes for improving the experience here, though we would fix any bugs though |
Thanks, good to know.
The app is huge and 10 years old at this point.
I’m thinking of migrating from AppDynamics, which it usung -javaagent. And
looking at the open telemetry support st present, it does not look
production ready?
For instance, no supporr for lowering sample rates from 100%?
…On Sun, 2 May 2021 at 04:12, Anuraag Agrawal ***@***.***> wrote:
Hi @stnor <https://github.com/stnor> - thanks for filing these issues. It
sounds like you are adding tracing to a new app. Did you by any chance take
a look at our support for OpenTelemetry?
https://aws-otel.github.io/docs/getting-started/java-sdk
It has far more features and can provide a better experience than XRay sdk
for new apps. There is a Java agent that can automatically instrument
and/or ability to manually instrument by creating spans.
Our effort is mostly focused on OpenTelemetry going forward so we probably
wouldn't be able to make changes for improving the experience here, though
we would fix any bugs though
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEJAD6LISXYGCS3ZO572MTTLSYKHANCNFSM435BSENQ>
.
|
@stnor While it hasn't quite hit GA yet it can be used in production and a few folks are doing so. While X-Ray centralized sampling isn't currently supported unfortunately, the sampling rate can be tweaked with a flag ( https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#sampler |
Thanks, I'll check it out!
…On Sun, 2 May 2021 at 09:59, Anuraag Agrawal ***@***.***> wrote:
@stnor <https://github.com/stnor> While it hasn't quite hit GA yet it can
be used in production and a few folks are doing so.
While X-Ray centralized sampling isn't currently supported unfortunately,
the sampling rate can be tweaked with a flag (traceidratio).
https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure#sampler
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#281 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEJAD67CIHMTPNVUF6KJO3TLUA7HANCNFSM435BSENQ>
.
|
I've gotten the otel stuff to work decently well now... However I do not understand how to compliment the -javaagent's standard tracing with my own Spring AOP aspects. I think the right approach would be to create nested spans? I've looked here: https://opentelemetry.io/docs/java/manual_instrumentation/ and it doesn't really cover my use-case.
I've added these deps: <dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency> Any pointers or help would be highly appreciated. |
Also found open-telemetry/opentelemetry-java#3035 |
Sorry for the spam. (1) Is it "correct"? public abstract class AbstractSpringOtelInterceptor {
private static final Log logger = LogFactory.getLog(AbstractSpringOtelInterceptor.class);
private Tracer tracer = OpenTelemetrySdk.builder().build().getTracer("se.nomp");
protected Object processXRayTrace(ProceedingJoinPoint pjp) throws Throwable {
Span span = tracer.spanBuilder(generateSubsegmentName(pjp)).startSpan();
try(Scope scope = span.makeCurrent()) {
return conditionalProceed(pjp);
} finally {
span.end();
}
}
protected String generateSubsegmentName(ProceedingJoinPoint pjp) {
return "Hello " + pjp.getSignature().getDeclaringType().getSimpleName() + "." + pjp.getSignature().getName();
}
public static Object conditionalProceed(ProceedingJoinPoint pjp) throws Throwable {
return pjp.getArgs().length == 0 ? pjp.proceed() : pjp.proceed(pjp.getArgs());
}
}
Also tried protected Object processXRayTrace(ProceedingJoinPoint pjp) throws Throwable {
Span parent = Span.current();
Span span = tracer.spanBuilder(generateSubsegmentName(pjp)).setParent(Context.current().with(parent)).startSpan();
try(Scope scope = span.makeCurrent()) {
return conditionalProceed(pjp);
} finally {
span.end();
}
} |
Hey @stnor - just to confirm you are using the aws distro if the Java agent and a collector configured for x-ray? Are you seeing the agent's spans, but just not seeing yours? To get a tracer when using the agent, you need to use In fact, you should make sure not to have a dependency on opentelemetry-sdk in your app as the agent brings it in. The dependency itself doesn't hurt but can lead to the mistake of trying to use it. The only artifact needed for instrumenting code is opentelemetry-api. Other than that, your first snippet (which correctly implicitly parents to the current span) looks good. |
Thanks @anuraaga - that solved it!
after editing the Dockerfile. |
Nice trace! If you found anything, always happy for more ideas on improving instrumentation at https://github.com/open-telemetry/opentelemetry-java-instrumentation/. Instrumentation for hikaricp seems like it could be nice for us to offer natively. |
Ah and I've always had the idea of injecting |
I'm attaching my code here if anyone else would like to instrument att their services and repos using OpenTelemetry. One needs to edit the |
Thanks for attaching that reference @stnor! I'll go ahead and resolve this since it seems like you've resolved your issue using OpenTelemetry. |
Hi,
I'm manually instrumenting my fairly large Spring application.
Why are you not adding the Class name to the sub-segment name?
It's quite frustrating to not have the class name in the UI when looking at the traces.
I would suggest changing:
aws-xray-sdk-java/aws-xray-recorder-sdk-spring/src/main/java/com/amazonaws/xray/spring/aop/BaseAbstractXRayInterceptor.java
Line 48 in d66d69a
to
so that the user can override the subsegment name.
The text was updated successfully, but these errors were encountered: