Skip to content

Commit b8d629f

Browse files
committed
remove unused profilerId, add tests for opentelemetry-noagent and webflux samples
1 parent 9ed6325 commit b8d629f

File tree

7 files changed

+126
-2
lines changed
  • sentry-samples
    • sentry-samples-spring-boot-4-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-boot-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-boot-webflux-jakarta/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-boot-webflux/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-boot/src/test/kotlin/io/sentry/systemtest
    • sentry-samples-spring-jakarta/src/test/kotlin/io/sentry/systemtest

7 files changed

+126
-2
lines changed

sentry-samples/sentry-samples-spring-boot-4-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.systemtest
22

33
import io.sentry.protocol.FeatureFlag
4+
import io.sentry.protocol.SentryId
45
import io.sentry.systemtest.util.TestHelper
56
import kotlin.test.Test
67
import kotlin.test.assertEquals
@@ -80,6 +81,26 @@ class PersonSystemTest {
8081
}
8182
}
8283

84+
@Test
85+
fun `create person starts a profile linked to the transaction`() {
86+
var profilerId: SentryId? = null
87+
val restClient = testHelper.restClient
88+
val person = Person("firstA", "lastB")
89+
val returnedPerson = restClient.createPerson(person)
90+
assertEquals(200, restClient.lastKnownStatusCode)
91+
92+
assertEquals(person.firstName, returnedPerson!!.firstName)
93+
assertEquals(person.lastName, returnedPerson!!.lastName)
94+
95+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
96+
profilerId = transaction.contexts.profile?.profilerId
97+
transaction.transaction == "POST /person/"
98+
}
99+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
100+
profileChunk.profilerId == profilerId
101+
}
102+
}
103+
83104
@Test
84105
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
85106
val restClient = testHelper.restClient

sentry-samples/sentry-samples-spring-boot-jakarta-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.systemtest
22

33
import io.sentry.protocol.FeatureFlag
4+
import io.sentry.protocol.SentryId
45
import io.sentry.systemtest.util.TestHelper
56
import kotlin.test.Test
67
import kotlin.test.assertEquals
@@ -80,6 +81,26 @@ class PersonSystemTest {
8081
}
8182
}
8283

84+
@Test
85+
fun `create person starts a profile linked to the transaction`() {
86+
var profilerId: SentryId? = null
87+
val restClient = testHelper.restClient
88+
val person = Person("firstA", "lastB")
89+
val returnedPerson = restClient.createPerson(person)
90+
assertEquals(200, restClient.lastKnownStatusCode)
91+
92+
assertEquals(person.firstName, returnedPerson!!.firstName)
93+
assertEquals(person.lastName, returnedPerson!!.lastName)
94+
95+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
96+
profilerId = transaction.contexts.profile?.profilerId
97+
transaction.transaction == "POST /person/"
98+
}
99+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
100+
profileChunk.profilerId == profilerId
101+
}
102+
}
103+
83104
@Test
84105
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
85106
val restClient = testHelper.restClient

sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.systemtest
22

33
import io.sentry.protocol.FeatureFlag
4+
import io.sentry.protocol.SentryId
45
import io.sentry.systemtest.util.TestHelper
56
import kotlin.test.Test
67
import kotlin.test.assertEquals
@@ -80,6 +81,26 @@ class PersonSystemTest {
8081
}
8182
}
8283

84+
@Test
85+
fun `create person starts a profile linked to the transaction`() {
86+
var profilerId: SentryId? = null
87+
val restClient = testHelper.restClient
88+
val person = Person("firstA", "lastB")
89+
val returnedPerson = restClient.createPerson(person)
90+
assertEquals(200, restClient.lastKnownStatusCode)
91+
92+
assertEquals(person.firstName, returnedPerson!!.firstName)
93+
assertEquals(person.lastName, returnedPerson!!.lastName)
94+
95+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
96+
profilerId = transaction.contexts.profile?.profilerId
97+
transaction.transaction == "POST /person/"
98+
}
99+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
100+
profileChunk.profilerId == profilerId
101+
}
102+
}
103+
83104
@Test
84105
fun `create person creates transaction if no sampled flag in sentry-trace header`() {
85106
val restClient = testHelper.restClient

sentry-samples/sentry-samples-spring-boot-webflux-jakarta/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.systemtest
22

3+
import io.sentry.protocol.SentryId
34
import io.sentry.systemtest.util.TestHelper
45
import kotlin.test.Test
56
import kotlin.test.assertEquals
@@ -52,4 +53,24 @@ class PersonSystemTest {
5253
testHelper.doesTransactionHaveOp(transaction, "http.server")
5354
}
5455
}
56+
57+
@Test
58+
fun `create person starts a profile linked to the transaction`() {
59+
var profilerId: SentryId? = null
60+
val restClient = testHelper.restClient
61+
val person = Person("firstA", "lastB")
62+
val returnedPerson = restClient.createPerson(person)
63+
assertEquals(200, restClient.lastKnownStatusCode)
64+
65+
assertEquals(person.firstName, returnedPerson!!.firstName)
66+
assertEquals(person.lastName, returnedPerson!!.lastName)
67+
68+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
69+
profilerId = transaction.contexts.profile?.profilerId
70+
testHelper.doesTransactionHaveOp(transaction, "http.server")
71+
}
72+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
73+
profileChunk.profilerId == profilerId
74+
}
75+
}
5576
}

sentry-samples/sentry-samples-spring-boot-webflux/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.systemtest
22

3+
import io.sentry.protocol.SentryId
34
import io.sentry.systemtest.util.TestHelper
45
import kotlin.test.Test
56
import kotlin.test.assertEquals
@@ -52,4 +53,24 @@ class PersonSystemTest {
5253
testHelper.doesTransactionHaveOp(transaction, "http.server")
5354
}
5455
}
56+
57+
@Test
58+
fun `create person starts a profile linked to the transaction`() {
59+
var profilerId: SentryId? = null
60+
val restClient = testHelper.restClient
61+
val person = Person("firstA", "lastB")
62+
val returnedPerson = restClient.createPerson(person)
63+
assertEquals(200, restClient.lastKnownStatusCode)
64+
65+
assertEquals(person.firstName, returnedPerson!!.firstName)
66+
assertEquals(person.lastName, returnedPerson!!.lastName)
67+
68+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
69+
profilerId = transaction.contexts.profile?.profilerId
70+
testHelper.doesTransactionHaveOp(transaction, "http.server")
71+
}
72+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
73+
profileChunk.profilerId == profilerId
74+
}
75+
}
5576
}

sentry-samples/sentry-samples-spring-boot/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class PersonSystemTest {
4646

4747
@Test
4848
fun `create person works`() {
49-
var profilerId: SentryId? = null
5049
val restClient = testHelper.restClient
5150
val person = Person("firstA", "lastB")
5251
val returnedPerson = restClient.createPerson(person)
@@ -56,7 +55,6 @@ class PersonSystemTest {
5655
assertEquals(person.lastName, returnedPerson!!.lastName)
5756

5857
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
59-
profilerId = transaction.contexts.profile?.profilerId
6058
testHelper.doesTransactionContainSpanWithOp(transaction, "PersonService.create") &&
6159
testHelper.doesTransactionContainSpanWithOpAndDescription(
6260
transaction,

sentry-samples/sentry-samples-spring-jakarta/src/test/kotlin/io/sentry/systemtest/PersonSystemTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.systemtest
22

3+
import io.sentry.protocol.SentryId
34
import io.sentry.systemtest.util.TestHelper
45
import kotlin.test.Test
56
import kotlin.test.assertEquals
@@ -48,4 +49,24 @@ class PersonSystemTest {
4849
assertEquals(person.firstName, returnedPerson!!.firstName)
4950
assertEquals(person.lastName, returnedPerson!!.lastName)
5051
}
52+
53+
@Test
54+
fun `create person starts a profile linked to the transaction`() {
55+
var profilerId: SentryId? = null
56+
val restClient = testHelper.restClient
57+
val person = Person("firstA", "lastB")
58+
val returnedPerson = restClient.createPerson(person)
59+
assertEquals(200, restClient.lastKnownStatusCode)
60+
61+
assertEquals(person.firstName, returnedPerson!!.firstName)
62+
assertEquals(person.lastName, returnedPerson!!.lastName)
63+
64+
testHelper.ensureTransactionReceived { transaction, envelopeHeader ->
65+
profilerId = transaction.contexts.profile?.profilerId
66+
transaction.transaction == "POST /person/"
67+
}
68+
testHelper.ensureProfileChunkReceived { profileChunk, envelopeHeader ->
69+
profileChunk.profilerId == profilerId
70+
}
71+
}
5172
}

0 commit comments

Comments
 (0)