Skip to content

Commit 5b475d1

Browse files
committed
Add scope based feature flags
1 parent 96449e8 commit 5b475d1

File tree

68 files changed

+1229
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1229
-2
lines changed

sentry-samples/sentry-samples-console-opentelemetry-noagent/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public static void main(String[] args) throws InterruptedException {
6161
// Only data added to the scope on `configureScope` above is included.
6262
Sentry.captureMessage("Some warning!", SentryLevel.WARNING);
6363

64+
Sentry.addFeatureFlag("my-feature-flag", true);
65+
6466
// Sending exception:
6567
Exception exception = new RuntimeException("Some error!");
6668
Sentry.captureException(exception);

sentry-samples/sentry-samples-console-opentelemetry-noagent/src/test/kotlin/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class ConsoleApplicationSystemTest {
5555
// Verify we received the RuntimeException
5656
testHelper.ensureErrorReceived { event ->
5757
event.exceptions?.any { ex -> ex.type == "RuntimeException" && ex.value == "Some error!" } ==
58-
true
58+
true && testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
5959
}
6060

6161
// Verify we received the detailed event with fingerprint

sentry-samples/sentry-samples-console/src/main/java/io/sentry/samples/console/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public static void main(String[] args) throws InterruptedException {
126126
// Only data added to the scope on `configureScope` above is included.
127127
Sentry.captureMessage("Some warning!", SentryLevel.WARNING);
128128

129+
Sentry.addFeatureFlag("my-feature-flag", true);
130+
129131
// Sending exception:
130132
Exception exception = new RuntimeException("Some error!");
131133
Sentry.captureException(exception);

sentry-samples/sentry-samples-console/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ConsoleApplicationSystemTest {
5151
// Verify we received the RuntimeException
5252
testHelper.ensureErrorReceived { event ->
5353
event.exceptions?.any { ex -> ex.type == "RuntimeException" && ex.value == "Some error!" } ==
54-
true
54+
true && testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
5555
}
5656

5757
// Verify we received the detailed event with fingerprint

sentry-samples/sentry-samples-jul/src/main/java/io/sentry/samples/jul/Main.java

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

3+
import io.sentry.Sentry;
34
import java.util.UUID;
45
import java.util.logging.Level;
56
import java.util.logging.LogManager;
@@ -22,6 +23,10 @@ public static void main(String[] args) throws Exception {
2223
MDC.put("userId", UUID.randomUUID().toString());
2324
MDC.put("requestId", UUID.randomUUID().toString());
2425

26+
Sentry.addFeatureFlag("my-feature-flag", true);
27+
28+
LOGGER.warning("important warning");
29+
2530
// logging arguments are converted to Sentry Event parameters
2631
LOGGER.log(Level.INFO, "User has made a purchase of product: %d", 445);
2732

sentry-samples/sentry-samples-jul/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class ConsoleApplicationSystemTest {
5757
} != null
5858
}
5959

60+
testHelper.ensureErrorReceived { event ->
61+
event.message?.message == "important warning" &&
62+
testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
63+
}
64+
6065
testHelper.ensureLogsReceived { logs, _ ->
6166
testHelper.doesContainLogWithBody(logs, "User has made a purchase of product: 445") &&
6267
testHelper.doesContainLogWithBody(logs, "Something went wrong")

sentry-samples/sentry-samples-log4j2/src/main/java/io/sentry/samples/log4j2/Main.java

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

3+
import io.sentry.Sentry;
34
import java.util.UUID;
45
import org.apache.logging.log4j.LogManager;
56
import org.apache.logging.log4j.Logger;
@@ -19,6 +20,8 @@ public static void main(String[] args) {
1920
// ThreadContext tag not listed in log4j2.xml
2021
ThreadContext.put("context-tag", "context-tag-value");
2122

23+
Sentry.addFeatureFlag("my-feature-flag", true);
24+
2225
// logging arguments are converted to Sentry Event parameters
2326
LOGGER.info("User has made a purchase of product: {}", 445);
2427
// because minimumEventLevel is set to WARN this raises an event

sentry-samples/sentry-samples-log4j2/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class ConsoleApplicationSystemTest {
4747
event.level?.name == "ERROR"
4848
}
4949

50+
testHelper.ensureErrorReceived { event ->
51+
event.message?.message == "Important warning" &&
52+
testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
53+
}
54+
5055
testHelper.ensureErrorReceived { event ->
5156
event.breadcrumbs?.firstOrNull {
5257
it.message == "Hello Sentry!" && it.level == SentryLevel.DEBUG

sentry-samples/sentry-samples-logback/src/main/java/io/sentry/samples/logback/Main.java

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

3+
import io.sentry.Sentry;
34
import java.util.UUID;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
@@ -17,6 +18,9 @@ public static void main(String[] args) {
1718
// MDC tag not listed in logback.xml
1819
MDC.put("context-tag", "context-tag-value");
1920

21+
Sentry.addFeatureFlag("my-feature-flag", true);
22+
LOGGER.warn("important warning");
23+
2024
// logging arguments are converted to Sentry Event parameters
2125
LOGGER.info("User has made a purchase of product: {}", 445);
2226

sentry-samples/sentry-samples-logback/src/test/kotlin/io/sentry/systemtest/ConsoleApplicationSystemTest.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ class ConsoleApplicationSystemTest {
5353
} != null
5454
}
5555

56+
testHelper.ensureErrorReceived { event ->
57+
event.message?.message == "important warning" &&
58+
testHelper.doesEventHaveFlag(event, "my-feature-flag", true)
59+
}
60+
5661
testHelper.ensureErrorReceived { event ->
5762
event.breadcrumbs?.firstOrNull {
5863
it.message == "User has made a purchase of product: 445" && it.level == SentryLevel.INFO

0 commit comments

Comments
 (0)