Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tasks.withType<KotlinCompile>().configureEach {

dependencies {
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentless)
implementation(projects.sentryAsyncProfiler)

testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(projects.sentry)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.systemtest

import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import java.util.concurrent.TimeUnit
import org.junit.Assert.assertEquals
Expand All @@ -24,10 +25,12 @@ class ConsoleApplicationSystemTest {
jarFile,
mapOf(
"SENTRY_DSN" to testHelper.dsn,
// "SENTRY_AUTO_INIT" to "false",
// "SENTRY_AUTO_INIT" to "true",
Copy link

Choose a reason for hiding this comment

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

Bug: Commented-out debug code leftover from testing

The commented-out SENTRY_AUTO_INIT environment variable appears to be a leftover from development. The diff shows it was changed from "false" to "true" while remaining commented out, indicating this was part of local testing and wasn't meant to be committed. As the PR reviewer noted, this line doesn't contribute anything to the test and could be removed.

Fix in Cursor Fix in Web

"SENTRY_TRACES_SAMPLE_RATE" to "1.0",
"SENTRY_ENABLE_PRETTY_SERIALIZATION_OUTPUT" to "false",
"SENTRY_DEBUG" to "true",
"SENTRY_PROFILE_SESSION_SAMPLE_RATE" to "1.0",
"SENTRY_PROFILE_LIFECYCLE" to "TRACE",
"OTEL_METRICS_EXPORTER" to "none",
"OTEL_LOGS_EXPORTER" to "none",
"OTEL_TRACES_EXPORTER" to "none",
Expand All @@ -42,6 +45,8 @@ class ConsoleApplicationSystemTest {
}

private fun verifyExpectedEvents() {
var profilerId: SentryId? = null

// Verify we received a "Fatal message!" event
testHelper.ensureErrorReceived { event ->
event.message?.formatted == "Fatal message!" && event.level?.name == "FATAL"
Expand All @@ -67,10 +72,15 @@ class ConsoleApplicationSystemTest {

// Verify we received transaction events
testHelper.ensureTransactionReceived { transaction, _ ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "transaction name" &&
transaction.spans?.any { span -> span.op == "child" } == true
}

testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}

// Verify we received the loop messages (should be 10 of them)
var loopMessageCount = 0
try {
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-console/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ tasks.withType<KotlinCompile>().configureEach {

dependencies {
implementation(projects.sentry)
implementation(projects.sentryAsyncProfiler)

testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(projects.sentry)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.systemtest

import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import java.util.concurrent.TimeUnit
import org.junit.Assert.assertEquals
Expand Down Expand Up @@ -27,6 +28,8 @@ class ConsoleApplicationSystemTest {
"SENTRY_TRACES_SAMPLE_RATE" to "1.0",
"SENTRY_ENABLE_PRETTY_SERIALIZATION_OUTPUT" to "false",
"SENTRY_DEBUG" to "true",
"SENTRY_PROFILE_SESSION_SAMPLE_RATE" to "1.0",
"SENTRY_PROFILE_LIFECYCLE" to "TRACE",
),
)

Expand All @@ -38,6 +41,7 @@ class ConsoleApplicationSystemTest {
}

private fun verifyExpectedEvents() {
var profilerId: SentryId? = null
// Verify we received a "Fatal message!" event
testHelper.ensureErrorReceived { event ->
event.message?.formatted == "Fatal message!" && event.level?.name == "FATAL"
Expand All @@ -63,10 +67,15 @@ class ConsoleApplicationSystemTest {

// Verify we received transaction events
testHelper.ensureTransactionReceived { transaction, _ ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "transaction name" &&
transaction.spans?.any { span -> span.op == "child" } == true
}

testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}

// Verify we received the loop messages (should be 10 of them)
var loopMessageCount = 0
try {
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-spring-7/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))
implementation(projects.sentrySpring7)
implementation(projects.sentryLogback)
implementation(projects.sentryAsyncProfiler)
implementation(libs.jackson.databind)
implementation(libs.logback.classic)
implementation(libs.servlet.jakarta.api)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
debug=true
in-app-includes="io.sentry.samples"
profile-session-sample-rate=1.0
profiling-traces-dir-path=tmp/sentry/profiling-traces
profile-lifecycle=TRACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.systemtest

import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -48,4 +49,24 @@ class PersonSystemTest {
assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)
}

@Test
fun `create person starts a profile linked to the transaction`() {
var profilerId: SentryId? = null
val restClient = testHelper.restClient
val person = Person("firstA", "lastB")
val returnedPerson = restClient.createPerson(person)
assertEquals(200, restClient.lastKnownStatusCode)

assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)

testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "POST /person/"
}
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation(projects.sentryGraphql22)
implementation(projects.sentryQuartz)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring)
implementation(projects.sentryAsyncProfiler)

// database query tracing
implementation(projects.sentryJdbc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
in-app-includes="io.sentry.samples"
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE

# Uncomment and set to true to enable aot compatibility
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.systemtest

import io.sentry.protocol.FeatureFlag
import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -80,6 +81,26 @@ class PersonSystemTest {
}
}

@Test
fun `create person starts a profile linked to the transaction`() {
var profilerId: SentryId? = null
val restClient = testHelper.restClient
val person = Person("firstA", "lastB")
val returnedPerson = restClient.createPerson(person)
assertEquals(200, restClient.lastKnownStatusCode)

assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)

testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "POST /person/"
}
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}
}

@Test
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
val restClient = testHelper.restClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation(projects.sentryLogback)
implementation(projects.sentryGraphql22)
implementation(projects.sentryQuartz)
implementation(projects.sentryAsyncProfiler)
implementation(libs.otel)

// database query tracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
in-app-includes="io.sentry.samples"
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE

# Uncomment and set to true to enable aot compatibility
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.systemtest

import io.sentry.protocol.FeatureFlag
import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -75,6 +76,26 @@ class PersonSystemTest {
}
}

@Test
fun `create person starts a profile linked to the transaction`() {
var profilerId: SentryId? = null
val restClient = testHelper.restClient
val person = Person("firstA", "lastB")
val returnedPerson = restClient.createPerson(person)
assertEquals(200, restClient.lastKnownStatusCode)

assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)

testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "POST /person/"
}
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}
}

@Test
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
val restClient = testHelper.restClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation(projects.sentryLogback)
implementation(projects.sentryJdbc)
implementation(projects.sentryGraphql22)
implementation(projects.sentryAsyncProfiler)
implementation(libs.context.propagation)
implementation(libs.springboot4.starter.actuator)
implementation(libs.springboot4.starter.graphql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ sentry.traces-sample-rate=1.0
sentry.enable-backpressure-handling=true
sentry.logs.enabled=true
sentry.enable-spotlight=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.systemtest

import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -52,4 +53,25 @@ class PersonSystemTest {
testHelper.doesTransactionHaveOp(transaction, "http.server")
}
}

@Test
fun `create person starts a profile linked to the transaction`() {
var profilerId: SentryId? = null
val restClient = testHelper.restClient
val person = Person("firstA", "lastB")
val returnedPerson = restClient.createPerson(person)
assertEquals(200, restClient.lastKnownStatusCode)

assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)

testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
profilerId = transaction.contexts.profile?.profilerId
testHelper.doesTransactionHaveOp(transaction, "http.server")
}

testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
implementation(projects.sentryLogback)
implementation(projects.sentryGraphql22)
implementation(projects.sentryQuartz)
implementation(projects.sentryAsyncProfiler)

// database query tracing
implementation(projects.sentryJdbc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ sentry.graphql.ignored-error-types=SOME_ERROR,ANOTHER_ERROR
sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
in-app-includes="io.sentry.samples"
sentry.in-app-includes="io.sentry.samples"
sentry.logs.enabled=true
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE

# Uncomment and set to true to enable aot compatibility
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.sentry.systemtest

import io.sentry.protocol.FeatureFlag
import io.sentry.protocol.SentryId
import io.sentry.systemtest.util.TestHelper
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -72,4 +73,24 @@ class PersonSystemTest {
)
}
}

@Test
fun `create person starts a profile linked to the transaction`() {
var profilerId: SentryId? = null
val restClient = testHelper.restClient
val person = Person("firstA", "lastB")
val returnedPerson = restClient.createPerson(person)
assertEquals(200, restClient.lastKnownStatusCode)

assertEquals(person.firstName, returnedPerson!!.firstName)
assertEquals(person.lastName, returnedPerson!!.lastName)

testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
profilerId = transaction.contexts.profile?.profilerId
transaction.transaction == "POST /person/"
}
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
profileChunk.profilerId == profilerId
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ dependencies {
implementation(projects.sentryLogback)
implementation(projects.sentryGraphql22)
implementation(projects.sentryQuartz)
implementation(projects.sentryAsyncProfiler)
implementation(projects.sentryOpentelemetry.sentryOpentelemetryAgentlessSpring)

// database query tracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ sentry.enable-backpressure-handling=true
sentry.enable-spotlight=true
sentry.enablePrettySerializationOutput=false
sentry.logs.enabled=true
in-app-includes="io.sentry.samples"
sentry.in-app-includes="io.sentry.samples"
sentry.profile-session-sample-rate=1.0
sentry.profiling-traces-dir-path=tmp/sentry/profiling-traces
sentry.profile-lifecycle=TRACE

# Uncomment and set to true to enable aot compatibility
# This flag disables all AOP related features (i.e. @SentryTransaction, @SentrySpan)
Expand Down
Loading
Loading