Skip to content
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

Sentry Exporter #253

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* xref:index.adoc[Introduction]
* xref:quarkus-opentelemetry-exporter-azure.adoc[Quarkus Opentelemetry Exporter for Microsoft Azure]
* xref:quarkus-opentelemetry-exporter-gcp.adoc[Quarkus Opentelemetry Exporter for Google Cloud Platform]
* xref:quarkus-opentelemetry-exporter-sentry.adoc[Quarkus Opentelemetry Exporter for Sentry]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
= Quarkus Opentelemetry Exporter for Sentry

include::./includes/attributes.adoc[]

This exporter sends data to sentry.

== General configuration

Add the https://mvnrepository.com/artifact/io.quarkiverse.opentelemetry.exporter/quarkus-opentelemetry-exporter-sentry[Sentry exporter extension] to your build file.

For Maven:

[source,xml,subs=attributes+]
----
<dependency>
<groupId>io.quarkiverse.opentelemetry.exporter</groupId>
<artifactId>quarkus-opentelemetry-exporter-sentry</artifactId>
<version>{project-version}</version>
</dependency>
----

You also need a sentry project to receive the telemetry data. Go to the sentry portal, search for your project or create a new one. On the overview page of your project, you will find a DSN https://docs.sentry.io/concepts/key-terms/dsn-explainer[in the top right corner].

You can then set the dsn in your project configuration:

* With the `application.properties` file

[source]
----
quarkus.otel.sentry.dsn=your_dsn
----

* With the `QUARKUS_OTEL_SENTRY_DSN=your_dsn` environment variable


Read https://quarkus.io/guides/opentelemetry#configuration-reference[this page] to learn more configuration options.

== Enable more instrumentation

* Read https://quarkus.io/guides/opentelemetry#jdbc[this documentation] to enable the JDBC instrumentation
* Read https://quarkus.io/guides/opentelemetry#additional-instrumentation[this documentation] to enable additional instrumentations


[[extension-configuration-reference]]
== Extension Configuration Reference

include::includes/quarkus-opentelemetry-tracer-exporter-sentry.adoc[leveloffset=+1, opts=optional]
32 changes: 24 additions & 8 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.opentelemetry.exporter</groupId>
<artifactId>quarkus-opentelemetry-exporter-sentry-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Expand All @@ -56,6 +69,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-doc-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<targetDirectory>${project.basedir}/modules/ROOT/pages/includes/</targetDirectory>
</configuration>
</plugin>
<plugin>
<groupId>it.ozimov</groupId>
<artifactId>yaml-properties-maven-plugin</artifactId>
Expand All @@ -73,14 +94,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-doc-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<targetDirectory>${project.basedir}/modules/ROOT/pages/includes/</targetDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -122,6 +135,9 @@
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<module>quarkus-opentelemetry-exporter-common</module>
<module>quarkus-opentelemetry-exporter-azure</module>
<module>quarkus-opentelemetry-exporter-gcp</module>
<module>quarkus-opentelemetry-exporter-sentry</module>
</modules>

<scm>
Expand Down
75 changes: 75 additions & 0 deletions quarkus-opentelemetry-exporter-sentry/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkiverse.opentelemetry.exporter</groupId>
<artifactId>quarkus-opentelemetry-exporter-sentry-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-opentelemetry-exporter-sentry-deployment</artifactId>
<name>Quarkus Opentelemetry Exporter Sentry - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkiverse.opentelemetry.exporter</groupId>
<artifactId>quarkus-opentelemetry-exporter-sentry</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-opentelemetry-core</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.quarkiverse.opentelemetry.exporter.sentry.deployment;

import static io.quarkus.deployment.Capability.REST;
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;

import java.util.function.BooleanSupplier;

import io.quarkiverse.opentelemetry.exporter.sentry.beans.SentrySpanProcessorProducer;
import io.quarkiverse.opentelemetry.exporter.sentry.config.SentryConfig;
import io.quarkiverse.opentelemetry.exporter.sentry.config.SentryConfig.SentryExporterRuntimeConfig;
import io.quarkiverse.opentelemetry.exporter.sentry.filters.SentryFilter;
import io.quarkiverse.opentelemetry.exporter.sentry.recorders.SentryRecorder;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.LogHandlerBuildItem;
import io.quarkus.opentelemetry.deployment.exporter.otlp.ExternalOtelExporterBuildItem;

@BuildSteps(onlyIf = SentryProcessor.SentryExporterEnabled.class)
public final class SentryProcessor {

static class SentryExporterEnabled implements BooleanSupplier {
SentryConfig.SentryExporterBuildConfig sentryExporterConfig;

public boolean getAsBoolean() {
return sentryExporterConfig.enabled();
}
}

private static final String FEATURE = "sentry";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
void registerExternalExporter(BuildProducer<ExternalOtelExporterBuildItem> buildProducer) {
buildProducer.produce(new ExternalOtelExporterBuildItem("sentry"));
}

@BuildStep
@Record(RUNTIME_INIT)
LogHandlerBuildItem addSentryHandler(final SentryExporterRuntimeConfig config, final SentryRecorder recorder) {
return new LogHandlerBuildItem(recorder.create(config));
}

@BuildStep
void additionalBeanSentryFilter(Capabilities capabilities, BuildProducer<AdditionalBeanBuildItem> producer) {
if (!capabilities.isPresent(REST)) {
return;
}
producer.produce(AdditionalBeanBuildItem.builder().addBeanClass(SentryFilter.class).build());
}

@BuildStep
AdditionalBeanBuildItem additionalBeanProducers() {
return AdditionalBeanBuildItem.builder()
.addBeanClass(SentrySpanProcessorProducer.class).build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.quarkiverse.opentelemetry.exporter.sentry.deployment;

import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.opentelemetry.api.OpenTelemetry;
import io.quarkus.test.QuarkusUnitTest;
import io.sentry.opentelemetry.SentrySpanProcessor;

public class SentryExporterDisabledTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.otel.sentry.enabled", "false");

@Inject
OpenTelemetry openTelemetry;

@Inject
Instance<SentrySpanProcessor> sentrySpanProcessorInstance;

@Test
void testOpenTelemetryButNoSpanProcessor() {
Assertions.assertNotNull(openTelemetry);
Assertions.assertFalse(sentrySpanProcessorInstance.isResolvable());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkiverse.opentelemetry.exporter.sentry.deployment;

import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.sdk.trace.SpanProcessor;
import io.quarkus.test.QuarkusUnitTest;

public class SentryExporterEnabledTest {

@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withEmptyApplication()
.overrideConfigKey("quarkus.otel.sentry.sentry.enabled", "true")
.overrideConfigKey("quarkus.otel.sentry.dsn", "https://1234@test/1234");

@Inject
OpenTelemetry openTelemetry;

@Inject
Instance<SpanProcessor> sentrySpanProcessorInstance;

@Test
void testOpenTelemetryButNoSpanProcessor() {
Assertions.assertNotNull(openTelemetry);
Assertions.assertTrue(sentrySpanProcessorInstance.isResolvable());
}
}
Loading
Loading