Skip to content
Draft
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
5 changes: 1 addition & 4 deletions .github/workflows/system-tests-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ jobs:
strategy:
fail-fast: false
matrix:
sample: [ "sentry-samples-console-otlp" ]
sample: [ "sentry-samples-spring-boot-4-otlp" ]
agent: [ "false" ]
agent-auto-init: [ "true" ]
include:
- sample: "sentry-samples-logback"
agent: "false"
agent-auto-init: "true"
- sample: "sentry-samples-spring-boot-4-otlp"
agent: "false"
agent-auto-init: "true"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies {
testImplementation(projects.sentryTestSupport)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(libs.awaitility.kotlin)
testImplementation(libs.google.truth)
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.mockito.kotlin)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package io.sentry.opentelemetry.otlp

import com.google.common.truth.Truth.assertThat
import io.opentelemetry.sdk.OpenTelemetrySdk
import io.opentelemetry.sdk.trace.SdkTracerProvider
import io.sentry.Sentry
import io.sentry.test.MockSentryServer
import io.sentry.test.event
import io.sentry.test.hasMetric
import io.sentry.test.initForTest
import io.sentry.test.logs
import io.sentry.test.metrics
import kotlin.test.AfterTest
import kotlin.test.Test

/**
* An app that exports its OpenTelemetry spans over OTLP and reports everything else to Sentry, as
* the console OTLP sample does.
*/
class OtlpEndToEndTest {
private val server = MockSentryServer()
private val openTelemetry =
OpenTelemetrySdk.builder().setTracerProvider(SdkTracerProvider.builder().build()).build()

@AfterTest
fun teardown() {
Sentry.close()
openTelemetry.close()
server.close()
}

@Test
fun `an event inside an OpenTelemetry span is linked to it`() {
initForTest {
it.dsn = server.dsn
it.logs.isEnabled = true
it.addEventProcessor(OpenTelemetryOtlpEventProcessor())
}

val span = openTelemetry.getTracer("otlp-end-to-end-test").spanBuilder("otelSpan").startSpan()
span.makeCurrent().use {
Sentry.captureMessage("this message is connected to the outerSpan")
Sentry.logger().error("Some error log message")
Sentry.metrics().count("invocations")
}
span.end()
Sentry.flush(5000)

val event =
server
.awaitEnvelope {
it.event()?.message?.formatted == "this message is connected to the outerSpan"
}
.event()!!
// The span's trace goes over OTLP, so the event points to it rather than to a Sentry span.
val trace = event.contexts.trace!!
assertThat(trace.traceId.toString()).isEqualTo(span.spanContext.traceId)
assertThat(trace.spanId.toString()).isEqualTo(span.spanContext.spanId)

val logs = server.awaitEnvelope { it.logs() != null }.logs()!!
assertThat(logs.items.map { it.body }).contains("Some error log message")

val metrics = server.awaitEnvelope { it.metrics() != null }.metrics()!!
assertThat(metrics.hasMetric("invocations", "counter", 1.0)).isTrue()
}
}
41 changes: 0 additions & 41 deletions sentry-samples/sentry-samples-console-otlp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
application
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.gradle.versions)
alias(libs.plugins.shadow)
id("io.sentry.systemtest")
}

application { mainClass.set("io.sentry.samples.console.Main") }
Expand All @@ -20,30 +16,12 @@ configure<JavaPluginExtension> {
targetCompatibility = JavaVersion.VERSION_17
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}

tasks.withType<KotlinCompile>().configureEach {
kotlin {
compilerOptions.freeCompilerArgs = listOf("-Xjsr305=strict")
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

dependencies {
implementation(projects.sentryOpentelemetry.sentryOpentelemetryOtlp)
implementation(projects.sentryAsyncProfiler)
implementation(libs.otel.semconv)
implementation(libs.otel.semconv.incubating)
implementation(libs.otel.exporter.logging)

testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(projects.sentry)
testImplementation(projects.sentrySystemTestSupport)
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.slf4j.api)
testImplementation(libs.slf4j.jdk14)
}

// Configure the Shadow JAR (executable JAR with all dependencies)
Expand All @@ -62,22 +40,3 @@ tasks.jar {

// Fix the startScripts task dependency
tasks.startScripts { dependsOn(tasks.shadowJar) }

tasks.register<Test>("systemTest").configure {
group = "verification"
description = "Runs the System tests"

val test = project.extensions.getByType<SourceSetContainer>()["test"]
testClassesDirs = test.output.classesDirs
classpath = test.runtimeClasspath

maxParallelForks = 1

filter { includeTestsMatching("io.sentry.systemtest*") }
}

tasks.named("test").configure {
require(this is Test)

filter { excludeTestsMatching("io.sentry.systemtest.*") }
}

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion test/system-test-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ def get_available_modules(self) -> List[ModuleConfig]:
"""Get list of all available test modules."""
return [
ModuleConfig("sentry-samples-spring-boot-4-otlp", "false", "true", "false"),
ModuleConfig("sentry-samples-console-otlp", "false", "true", "false"),
ModuleConfig("sentry-samples-logback", "false", "true", "false"),
]

Expand Down
Loading