-
-
Notifications
You must be signed in to change notification settings - Fork 467
Expand file tree
/
Copy pathSpringProfilesEventProcessor.java
More file actions
51 lines (44 loc) · 1.63 KB
/
SpringProfilesEventProcessor.java
File metadata and controls
51 lines (44 loc) · 1.63 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package io.sentry.spring;
import io.sentry.EventProcessor;
import io.sentry.Hint;
import io.sentry.SentryBaseEvent;
import io.sentry.SentryEvent;
import io.sentry.SentryReplayEvent;
import io.sentry.protocol.SentryTransaction;
import io.sentry.protocol.Spring;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.core.env.Environment;
/**
* Attaches the list of active Spring profiles (an empty list if only the default profile is active)
* to the {@link io.sentry.TraceContext} associated with the event.
*/
public final class SpringProfilesEventProcessor implements EventProcessor {
private final @NotNull Environment environment;
@Override
public @NotNull SentryEvent process(final @NotNull SentryEvent event, final @NotNull Hint hint) {
processInternal(event);
return event;
}
@Override
public @NotNull SentryTransaction process(
final @NotNull SentryTransaction transaction, final @NotNull Hint hint) {
processInternal(transaction);
return transaction;
}
@Override
public @NotNull SentryReplayEvent process(
final @NotNull SentryReplayEvent event, final @NotNull Hint hint) {
processInternal(event);
return event;
}
private void processInternal(final @NotNull SentryBaseEvent event) {
@Nullable String[] activeProfiles = environment.getActiveProfiles();
@NotNull Spring springContext = new Spring();
springContext.setActiveProfiles(activeProfiles);
event.getContexts().setSpring(springContext);
}
public SpringProfilesEventProcessor(final @NotNull Environment environment) {
this.environment = environment;
}
}