Skip to content

Commit 4d2790c

Browse files
authored
Merge pull request #3 from Albatarm/features/tags-config
Add tags configuration
2 parents f56b2a7 + 3c119d9 commit 4d2790c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ appenders:
4646
| `threshold` | ALL | The log level to configure to send to Sentry | `ERROR` |
4747
| `dsn` | | Data Source Name - format is `https://{PUBLIC_KEY}:{SECRET_KEY}@sentry.io/{PROJECT_ID}` | `https://foo:bar@sentry.io/12345` |
4848
| `environment` | [empty] | The environment your application is running in | `production` |
49+
| `tags` | [empty] | Tags to be sent with each event | `tag1:value1,tag2,value2` |
4950
| `mdcTags` | [empty] | Tag names to be extracted from logging MDC | `['foo', 'bar']` |
5051
| `sentryClientFactory` | [empty] | Specify a custom [`SentryClientFactory`](https://github.com/getsentry/sentry-java/blob/master/sentry/src/main/java/io/sentry/SentryClientFactory.java) class | `com.example.SentryClientFactory` |
5152
| `release` | [empty] | The release version of your application | `1.0.0` |
5253
| `serverName` | [empty] | Override the server name (rather than looking it up dynamically) | `10.0.0.1` |
53-
| `extra` | [empty] | Extra data to be sent with errors | `{key1:'value1',key2:'value2'}` |
54+
| `extra` | [empty] | Extra data to be sent with errors (but not as tags) | `{key1:'value1',key2:'value2'}` |
5455

5556
## Maven Artifacts
5657

src/main/java/org/dhatim/dropwizard/sentry/logging/SentryAppenderFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public class SentryAppenderFactory extends AbstractAppenderFactory<ILoggingEvent
3333
@JsonProperty
3434
private Optional<String> environment = Optional.empty();
3535

36+
@JsonProperty
37+
private Optional<Map<String, String>> tags = Optional.empty();
38+
3639
@JsonProperty
3740
private Optional<Set<String>> mdcTags = Optional.empty();
3841

@@ -64,6 +67,14 @@ public void setEnvironment(Optional<String> environment) {
6467
this.environment = environment;
6568
}
6669

70+
public Optional<Map<String, String>> getTags() {
71+
return tags;
72+
}
73+
74+
public void setTags(Optional<Map<String, String>> tags) {
75+
this.tags = tags;
76+
}
77+
6778
public Optional<Set<String>> getMdcTags() {
6879
return mdcTags;
6980
}
@@ -127,6 +138,7 @@ public Appender<ILoggingEvent> build(LoggerContext context,
127138
appender.setContext(context);
128139

129140
environment.ifPresent(sentryClient::setEnvironment);
141+
tags.ifPresent(sentryClient::setTags);
130142
mdcTags.ifPresent(sentryClient::setMdcTags);
131143
release.ifPresent(sentryClient::setRelease);
132144
serverName.ifPresent(sentryClient::setServerName);

0 commit comments

Comments
 (0)