Skip to content

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Dec 6, 2024

📜 Description

Add sentry-opentelemetry-agentless module that customers can add as a single dependency to use our OpenTelemetry offering instead of having to add multiple dependencies and manage versions.

💡 Motivation and Context

Closes #3913

💚 How did you test it?

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

  • Consider agentless-spring-boot that pulls in opentelemetry-spring-boot-starter with the required version
  • Consider creating a BOM, that also drags in the OTel BOM to manage Sentry + OTel versions
  • Update README

@adinauer adinauer changed the title POTEL 63 - sentry-opentelemetry-agentless module POTEL 64 - sentry-opentelemetry-agentless module Dec 6, 2024
Copy link
Contributor

github-actions bot commented Dec 6, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 6147a96

Copy link
Contributor

github-actions bot commented Dec 6, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 399.45 ms 428.74 ms 29.29 ms
Size 1.65 MiB 2.31 MiB 676.08 KiB

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

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

Left some comments regarding auto configuration that we need to figure out

api(Config.Libs.OpenTelemetry.otelSdk)
api(Config.Libs.OpenTelemetry.otelSemconv)
api(Config.Libs.OpenTelemetry.otelSemconvIncubating)
implementation(Config.Libs.OpenTelemetry.otelExtensionAutoconfigure)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs to be declared with api scope so that any depending Applications can use the AutoConfiguredOpenTelemetrySdk

Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to initialize OpenTelemetry by using AutoConfiguredOpenTelemetrySdk as explained here: https://opentelemetry.io/docs/languages/java/configuration/#zero-code-sdk-autoconfigure.

The implicit GlobalOpentelemetry.get() does not do automatic configuration which we need for our spis to load.

Also, just using AutoConfiguredOpenTelemetrySdk.initialize() as shown in the documentation above ist not enough because by default it tries to use oltp as exporter for which we do not have dependencies added and therefore crashes.

The following piece of code works for initializing the sdk:

    AutoConfiguredOpenTelemetrySdk.builder()
      .setResultAsGlobal()
      .addPropertiesSupplier(
        () -> {
          final Map<String, String> properties = new HashMap<>();
          properties.put("otel.logs.exporter", "none");
          properties.put("otel.metrics.exporter", "none");
          properties.put("otel.traces.exporter", "none");
          return properties;
        })
      .build();

AutoConfiguredOpenTelemetrySdk.initialize() would work only in conjunction with environment variables setting the exporters to none.

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 application can also be started using -Dotel.java.global-autoconfigure.enabled=true which means opentelemetry-sdk-extension-autoconfigure will take care of this.

Customers also have to add OTEL_LOGS_EXPORTER=none;OTEL_METRICS_EXPORTER=none;OTEL_TRACES_EXPORTER=none as env vars, to avoid spammy logs.

We can offer both ways in docs.

For more details on configuring Sentry via `sentry.properties` please see the
[docs page](https://docs.sentry.io/platforms/java/configuration/).

As an alternative to the `SENTRY_PROPERTIES_FILE` environment variable you can provide individual
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'll need to add some info on how to initialize with AutoConfiguredOpenTelemetrySdk. Or find another way to do that in e.g. OtelSpanFactory.getTracerProvider()

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's follow up in a different PR.

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@adinauer adinauer merged commit 30f169f into 8.x.x Dec 17, 2024
34 checks passed
@adinauer adinauer deleted the feat/agentless-module branch December 17, 2024 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants