-
-
Notifications
You must be signed in to change notification settings - Fork 444
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
Auto add OpenTelemetryLinkErrorEventProcessor for Spring Boot #2429
Changes from all commits
baf8bd5
49efc4c
183423a
8b47a99
e3c8470
707ea59
ba730c2
319b527
d7813ca
da36dbf
44f9f2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import io.sentry.Integration; | ||
import io.sentry.Sentry; | ||
import io.sentry.SentryOptions; | ||
import io.sentry.opentelemetry.OpenTelemetryLinkErrorEventProcessor; | ||
import io.sentry.protocol.SdkVersion; | ||
import io.sentry.spring.ContextTagsEventProcessor; | ||
import io.sentry.spring.SentryExceptionResolver; | ||
|
@@ -139,6 +140,19 @@ static class ContextTagsEventProcessorConfiguration { | |
} | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnProperty(name = "sentry.auto-init", havingValue = "false") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When not using the agent this will not trigger. At the moment it feels like a niche use case to not use the agent JAR and there doesn't seem to be an easy way of detecting whether the agent is in use. We could add some class that serves as a marker (to the bootstrap classloader) or manipulate the options (byte code manipulation) from the agent but decided not to do that for now. If this becomes a more common use case we can revisit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@ConditionalOnClass(OpenTelemetryLinkErrorEventProcessor.class) | ||
@Open | ||
static class OpenTelemetryLinkErrorEventProcessorConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public @NotNull OpenTelemetryLinkErrorEventProcessor openTelemetryLinkErrorEventProcessor() { | ||
return new OpenTelemetryLinkErrorEventProcessor(); | ||
} | ||
} | ||
|
||
/** Registers beans specific to Spring MVC. */ | ||
@Configuration(proxyBeanMethods = false) | ||
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET) | ||
|
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.
hm, why did we change it to
implementation
? It's not possible to use this module without otel, right? Or is the assumption that people will just include oursentry-opentelemetry-core
package, but not otel itself?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.
The intention was to make it easier to use
sentry-opentelemetry-agent
withSENTRY_AUTO_INIT=false
. Currently you need to addsentry-opentelemetry-core
to the dependencies so you can enjoy linking of errors to transactions. WithcompileOnly
you'd also have to include the correct version of the OTEL SDK, withimplementation
it just drags it in. Forsentry-opentelemetry-agent
we exclude it again, which users also have to do, if they don't want to use the agent but have a different OTEL version than we use or their build system can't figure out versions.Another approach (for later) would be to have yet another gradle module, that we can then add to the bootstrap classloader in the agent, thus not requiring the explicit dependency on
sentry-opentelemetry-core
at all, when settingSENTRY_AUTO_INIT=false
.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.
alright, just beware that
implementation
will override whatever version the users are using (if it's lower than ours). If that's what we want, then I'm good 👍