-
Notifications
You must be signed in to change notification settings - Fork 870
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
Need to create a bean OtlpHttpSpanExporter before opentelemetry spring boot starter. #11052
Comments
Transferred to |
This breaking change is a consequence of #10453 - I didn't call this out as a breaking change, because I simply couldn't image a use case that would break 😞 Anyways, there's a way to get your setup running:
|
I'm keeping this issue open to document this use case. |
Note: it's also possible to use "otlp" as the key - it will replace the already configured otlp exporter |
@zeitlinger , Thanks for your input. Correct me if my understanding is wrong. GlobalOpenTelemetry will not set the configuration for second time. How can i make it happen? |
I've created a draft PR that demonstrates both: open-telemetry/opentelemetry-java-examples#378 Disclaimer: I haven't tested it manually. |
I will try it from my end the same you have shared as example code... @zeitlinger Thank you.. |
Thank you @zeitlinger ,
I removed AutoConfigureListener implementation but it was working fine . Is there any impact by removing AutoConfigureListener? As per my understanding, we are just injecting the bean with dynamic header. Could you please explain me more on this and how it work? Is this changes will be the standard one in future also? |
great 🎉
it creates metrics about the span export (i.e. if there were errors)
correct
I can't follow - can you make the questions more concrete or add an example? |
Please refer the code i just shared in the comment above, i just modified now and it was working as expected for my use case. I need some clarification on this:
|
Yes, you're injecting an exporter. The exporter is loaded here: https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/src/main/java/io/opentelemetry/sdk/autoconfigure/SpanExporterConfiguration.java#L82-L86 There's an additional translation of spring beans to "SPI": https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration.java#L140-L146
You should to not to use GlobalOpenTelemetry at all (for that reason, I'll also remove that hint from the PR).
yes |
Thank you for your explanation @zeitlinger , As you recommened i just removed GlobalOpenTelemetry bean from my code.
As a result i can export the spans but at the same time i could able to see this info log in my application.
|
Ah, that means someone is trying to access the global. Can you set a breakpoint and copy the stack trace of the caller? https://github.com/open-telemetry/opentelemetry-java/blob/cb44b2b18c474f80478184ff1665bc3fa5d2ced3/api/all/src/main/java/io/opentelemetry/api/GlobalOpenTelemetry.java#L236 |
I dont see any stack trace there. globalOpenTelemetry is null while calling get() method, that's why i received this info log. |
I mean, who is calling the |
My springboot project was launched smoothly, once i try to export the spans by hitting api it was occurred.
And this method is called by this line |
Interesting! |
I tried by adding AutoConfigureListener again in my code, the same info log persist. The current code..
|
Can you check the value of seenAttrs? |
Hey @zeitlinger I didn't set |
Hi @zeitlinger , On other hand We are using microservice with 2 springboot application, Both application having otel springboot dependency with different app name, I am hitting a api and it lands on app1 and communicates with app2. While seeing the result we are seeing 2 different traces. app1 having trace1 and app2 having trace2 (i.e) nested traces is not happening. will you please share the thoughts on this, if possible. My code :
The Env variables:
Note: The same configuration working for java agent. The web span, db span and custom spans are automatically created by the agent. |
You could also use an extension BTW
I guess it's because the starter doesn't support the same number of libraries out of the box - or because the spring starter is a bit more picky about how you use beans like RestTemplate (see #11054) If you provide details about the spans, I can double check. |
please go to the span details and look for the "library name" |
each of the entries in "previous span" (actually it's previous trace) should have such an entry. Can you add the library along with the span name for each? |
Can you please explain me how to do that? I don't have an idea on this.. |
I don't know how to do that in your UI, but you can always turn on console logging - which was called "logging" in older releases. |
@zeitlinger For your information, Do you think is this because of this changes? |
@DineshkumarVG let's do a call to investigate the issue. |
Hi @zeitlinger , Sounds great.. Shall we connect through slack? Or any other medium are you comfortable with? |
CNCF slack sounds good 😄 |
Hi @zeitlinger , when can i schedule a meet. Since i am having some login issue with slack CNCF. Planned to connect on zoom. |
sure - I'm still pretty free tomorrow |
Here are the expected spans (from the call) 1: the server span. The server span has a different library name - but the functionality is equivalent. 2: Different spans related to database queries. The spring starter needs to be set up to support DB queries: https://opentelemetry.io/docs/languages/java/automatic/spring-boot/#jdbc-instrumentation 2.1: spring data adds more details about the query - and is not supported in the starter 2.2: You should see the DB query once you follow the instructions (2). 2.3: Hibernate adds more details about the query - and is not supported in the starter 3: HTTP URL connection HTTP URL connection is not supported in the starter - and I have no idea how to make it work outside a java agent. Final thoughts:
|
Sounds Great @zeitlinger , Thank you for dedicating your time and attention to this matter. Your engagement is greatly appreciated. 👏 . Will proceed next steps on this. |
OK, closing then - please re-open if needed. |
Hi,
I am using oauth authentication for otel collector, The token needs to be changed one hour once. I need to set that dynamically. I have used your setHeader with supplier and it was working as expected. I am trying to implement that using @bean annotation. but springboot auto configuration injects the bean before the bean i have created. Anyone please help on this or is there anything i have missed?
It was working fine with the version 2.1.0-alpha
Sample code for reference.
build.gradle
`dependencyManagement {
imports {
mavenBom("io.opentelemetry:opentelemetry-bom:1.36.0")
mavenBom("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.2.0-alpha")
}
}
implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")`
Bean File
`@AutoConfiguration
@ConditionalOnClass({OpenTelemetry.class})
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
public class RefreshToken {
@bean
public OtlpHttpSpanExporter otlpHttpSpanExporter() {
Supplier<Map<String, String>> mapSupplier = () -> {
Map<String, String> map = new HashMap<>();
try {
map.put("Authorization", "Bearer " + refreshToken());
} catch (Exception e) {
throw new RuntimeException(e);
}
return map;
};
return OtlpHttpSpanExporter.builder().setHeaders(mapSupplier)
.setEndpoint("url").build();
}
}`
The text was updated successfully, but these errors were encountered: