not able to get parent span, send from Client service to Server service #3128
Unanswered
mayur-more
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Hi @mayur-more - you want to use |
Beta Was this translation helpful? Give feedback.
2 replies
-
Hi, I am able to resolve this issue. Previously, I have commented out all other modules from settings.gradle |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am new to OpenTelemetry word. I want to auto-instrument my 2 services. I have created spans for my services separately, but when i am try to combine spans of two different services, I am not able to do it successfully. I have used following code:
I have added two modules(client and server) under opentelemetry-java-instrumentation/instrumentation/
This is code before i have added code for context propagation.
Client Advice class:
public static class ClientAdvice {
@Advice.OnMethodEnter
public static void onEnter(
@Advice.Origin String origin,
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
String subStr = origin.substring(0, origin.indexOf("(") + 1);
String operation = subStr.substring(subStr.lastIndexOf(".") + 1, subStr.indexOf("("));
Tracer tracer = GlobalOpenTelemetry.getTracer("test");
Span span = tracer.spanBuilder("/" + operation).setSpanKind(SpanKind.CLIENT).startSpan();
scope = span.makeCurrent();
if (span != null) {
span.setAttribute("method_name", origin);
}
}
@Advice.OnMethodExit
public static void onExit(
@Advice.Origin String origin,
@Advice.Local("otelContext") Context context,
@Advice.Local("otelScope") Scope scope) {
Span span = Span.current();
scope = span.makeCurrent();
scope.close();
span.end();
}
}
Server Advice class:
public static class CidsAdvice {
@Advice.OnMethodEnter
public static void onEnter(@Advice.Origin String origin) {
String subStr = origin.substring(0, origin.indexOf("(") + 1);
String operation = subStr.substring(subStr.lastIndexOf(".") + 1, subStr.indexOf("("));
Tracer tracer = GlobalOpenTelemetry.getTracer("test");
Span span = tracer.spanBuilder("/" + operation).startSpan();
Scope scope = span.makeCurrent();
if (span != null) {
span.setAttribute("method_name", origin);
}
}
@Advice.OnMethodExit
public static void onExit(@Advice.Origin String origin) {
Span span = Span.current();
Scope scope = span.makeCurrent();
scope.close();
span.end();
}
}
Can someone help me to get all the spans of these both services under one trace, please.
Beta Was this translation helpful? Give feedback.
All reactions