quarkiverse / quarkus-opentelemetry-exporter

Quarkus extensions related with additional OpenTelemetry exporters
Apache License 2.0
13 stars 8 forks source link

Sentry Performance Monitoring #173

Open n-krueger opened 6 months ago

n-krueger commented 6 months ago

Hello,

We are currently using the quarkus-logging-sentry Quarkiverse extension to automatically send error reports to Sentry from our Quarkus Backend services. We are also utilizing Opentelemetry for tracing instrumentation of these services.

Sentry offers an Opentelemetry span processor and context propagator to send traces to their platform: https://docs.sentry.io/platforms/java/performance/instrumentation/opentelemetry/

Would it be possible to add support for these to this extension?

derari commented 2 months ago

I was able to get Sentry+Opentelemetry running using

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-opentelemetry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.loggingsentry</groupId>
            <artifactId>quarkus-logging-sentry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-jul</artifactId>
            <version>7.12.1</version>
        </dependency>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-opentelemetry-core</artifactId>
            <version>7.12.1</version>
        </dependency>
public class OtelSetup {

    @Produces
    SpanProcessor newSpanProcessor() {
        var options = Sentry.getCurrentHub().getOptions();
        if (options.getDsn() != null && !options.getDsn().isBlank()) {
            options.setInstrumenter(Instrumenter.OTEL);
            Sentry.init(options);
        }
        return new SentrySpanProcessor();
    }

    @Produces
    SpanExporter newSpanExporter() {
        return new SpanExporter() {

            @Override
            public CompletableResultCode export(Collection<SpanData> spans) {
                return CompletableResultCode.ofSuccess();
            }

            @Override
            public CompletableResultCode flush() {
                return CompletableResultCode.ofSuccess();
            }

            @Override
            public CompletableResultCode shutdown() {
                return CompletableResultCode.ofSuccess();
            }
        };
    }
}

Maybe this helps someone to turn this into a plugin