-
-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathMain.java
More file actions
36 lines (29 loc) · 1.11 KB
/
Main.java
File metadata and controls
36 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package io.sentry.samples.logback;
import io.sentry.Sentry;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
public class Main {
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
public static void main(String[] args) {
LOGGER.debug("Hello Sentry!");
// MDC tags listed in logback.xml are converted to Sentry Event tags
MDC.put("userId", UUID.randomUUID().toString());
MDC.put("requestId", UUID.randomUUID().toString());
// MDC tag not listed in logback.xml
MDC.put("context-tag", "context-tag-value");
Sentry.setAttribute("user.type", "admin");
Sentry.setAttribute("feature.version", 2);
Sentry.setAttribute("debug.enabled", true);
Sentry.addFeatureFlag("my-feature-flag", true);
LOGGER.warn("important warning");
// logging arguments are converted to Sentry Event parameters
LOGGER.info("User has made a purchase of product: {}", 445);
try {
throw new RuntimeException("Invalid productId=445");
} catch (Throwable e) {
LOGGER.error("Something went wrong", e);
}
}
}