Skip to content

Commit

Permalink
Merge pull request #253 from rmanibus/sentry
Browse files Browse the repository at this point in the history
Sentry Exporter
  • Loading branch information
brunobat authored Jan 7, 2025
2 parents 24ca538 + 3db9f33 commit dbe56d7
Show file tree
Hide file tree
Showing 25 changed files with 1,026 additions and 8 deletions.
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]
47 changes: 47 additions & 0 deletions docs/modules/ROOT/pages/quarkus-opentelemetry-exporter-sentry.adoc
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

0 comments on commit dbe56d7

Please sign in to comment.