Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Conversation

@adinauer
Copy link
Member

@adinauer adinauer commented Dec 1, 2022

Changes

This replaces the OpenTelemetry Java Agent with the Sentry one and also sets DSN and tracesSampleRate.

Merge Requirements

For new features contributions please make sure you have completed the following
essential items:

  • CHANGELOG.md updated to document new feature additions
  • Appropriate documentation updates in the docs folder

Maintainers will not merge until the above have been completed. If you're unsure
which docs need to be changed ping the
@open-telemetry/demo-approvers.

@adinauer adinauer requested a review from tonyo December 1, 2022 10:26

COPY --from=builder /usr/src/app/ ./
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /app/opentelemetry-javaagent.jar
ADD https://search.maven.org/remotecontent?filepath=io/sentry/sentry-opentelemetry-agent/6.9.1/sentry-opentelemetry-agent-6.9.1.jar /app/opentelemetry-javaagent.jar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I did it here only uses Sentry to pass OTEL Spans to Sentry. There's no errors here. Do we want to

  • change this (maybe another PR) to initialize Sentry in the target application and have errors showcased as well?
  • have another service written in Java that showcases this combined use case of having OTEL for instrumentation and Sentry for errors

I like how this hardly differs from the OTEL sample in that you only replace the agent JAR and set DSN and tracesSampleRate and you're good to go with OTEL -> Sentry instrumentation.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this (maybe another PR) to initialize Sentry in the target application and have errors showcased as well?

I think we initialize Sentry for errors in other services, so yes, let's maybe do it in a separate PR later (to be confirmed with the team if we want to do it right away).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should initialize Sentry errors as well - we want this to be an example of what a user will do in production.

have another service written in Java that showcases this combined use case of having OTEL for instrumentation and Sentry for errors

Let's have this as a stretch goal for after we make the next release of the otel java sdk, maybe we can also think about contributing the service upstream. Maybe we write it in Kotlin then to make it more likely we merge it in?

Copy link
Member Author

@adinauer adinauer Dec 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about adding another service that uses Spring Boot. I could also do it in Kotlin (it's what I used in the past) but I guess the majority of people still use Spring with Java and not Kotlin. But I guess anywhone familiar with Java can easily understand most of the Kotlin code without looking anything up.

I'll update this example before merging this PR. Then after I added another service I can show how to use Sentry for errors and OTEL for instrumentation in the other sample and revert this one to what it is now (a showcase of allowing for a drop-in replacement of the original OTEL agent).


COPY --from=builder /usr/src/app/ ./
ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$version/opentelemetry-javaagent.jar /app/opentelemetry-javaagent.jar
ADD https://search.maven.org/remotecontent?filepath=io/sentry/sentry-opentelemetry-agent/6.9.1/sentry-opentelemetry-agent-6.9.1.jar /app/opentelemetry-javaagent.jar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should initialize Sentry errors as well - we want this to be an example of what a user will do in production.

have another service written in Java that showcases this combined use case of having OTEL for instrumentation and Sentry for errors

Let's have this as a stretch goal for after we make the next release of the otel java sdk, maybe we can also think about contributing the service upstream. Maybe we write it in Kotlin then to make it more likely we merge it in?

@adinauer adinauer merged commit 0f4fd8b into main Dec 7, 2022
@adinauer adinauer deleted the feat/add-java-agent-to-adservice branch December 7, 2022 13:33
@adinauer adinauer mentioned this pull request Dec 9, 2022
3 tasks
@smeubank smeubank linked an issue Dec 12, 2022 that may be closed by this pull request
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] Instrument service with Sentry

4 participants