Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<contributor>
<name>ccouturi</name>
</contributor>
<contributor>
<name>Felipe G Almeida</name>
</contributor>
</contributors>

<prerequisites>
Expand Down
2 changes: 2 additions & 0 deletions raven-logback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ In the `logback.xml` file set:
<tags>tag1:value1,tag2:value2</tags>
<!-- Optional, allows to select the ravenFactory -->
<!--<ravenFactory>net.kencochrane.raven.DefaultRavenFactory</ravenFactory>-->
<!-- Optional, allows setting app release information -->
<!-- <release>1.0.0</release>
</appender>
<root level="warn">
<appender-ref ref="Sentry"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public class SentryAppender extends AppenderBase<ILoggingEvent> {
* Might be null in which case the factory should be defined automatically.
*/
protected String ravenFactory;
/**
* Identifies the version of the application.
* <p>
* Might be null in which case the release information will not be sent with the event.
*/
protected String release;
/**
* Additional tags to be sent to sentry.
* <p>
Expand Down Expand Up @@ -168,6 +174,10 @@ protected Event buildEvent(ILoggingEvent iLoggingEvent) {
.withLevel(formatLevel(iLoggingEvent.getLevel()))
.withExtra(THREAD_NAME, iLoggingEvent.getThreadName());

if (this.release != null) {
eventBuilder.withRelease(this.release);
}

if (iLoggingEvent.getArgumentArray() != null) {
eventBuilder.withSentryInterface(new MessageInterface(iLoggingEvent.getMessage(),
formatMessageParameters(iLoggingEvent.getArgumentArray())));
Expand Down Expand Up @@ -279,6 +289,9 @@ public void setRavenFactory(String ravenFactory) {
this.ravenFactory = ravenFactory;
}

public void setRelease(String release) {
this.release = release;
}
/**
* Set the tags that should be sent along with the events.
*
Expand Down
12 changes: 12 additions & 0 deletions raven/src/main/java/net/kencochrane/raven/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public class Event implements Serializable {
* Identifies the host client from which the event was recorded.
*/
private String serverName;
/**
* Identifies the version of the application.
*/
private String release;
/**
* A map or list of additional properties for this event.
* <p>
Expand Down Expand Up @@ -165,6 +169,14 @@ void setServerName(String serverName) {
this.serverName = serverName;
}

public String getRelease() {
return release;
}

void setRelease(String release) {
this.release = release;
}

public Map<String, Object> getExtra() {
return extra;
}
Expand Down
11 changes: 11 additions & 0 deletions raven/src/main/java/net/kencochrane/raven/event/EventBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ public EventBuilder withLevel(Event.Level level) {
return this;
}

/**
* Sets application release version in the event.
*
* @param release application release version in the event.
* @return the current {@code EventBuilder} for chained calls.
*/
public EventBuilder withRelease(String release) {
event.setRelease(release);
return this;
}

/**
* Sets the logger in the event.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

/**
* Event marshaller using JSON to send the data.
* <p>
* <p/>
* The content can also be compressed with {@link DeflaterOutputStream} in which case the binary result is encoded
* in base 64.
*/
Expand Down Expand Up @@ -62,6 +62,10 @@ public class JsonMarshaller implements Marshaller {
* Identifies the host client from which the event was recorded.
*/
public static final String SERVER_NAME = "server_name";
/**
* Identifies the host client from which the event was recorded.
*/
public static final String RELEASE = "release";
/**
* A list of relevant modules and their versions.
*/
Expand Down Expand Up @@ -126,6 +130,7 @@ private void writeContent(JsonGenerator generator, Event event) throws IOExcepti
generator.writeStringField(CULPRIT, event.getCulprit());
writeTags(generator, event.getTags());
generator.writeStringField(SERVER_NAME, event.getServerName());
generator.writeStringField(RELEASE, event.getRelease());
writeExtras(generator, event.getExtra());
generator.writeStringField(CHECKSUM, event.getChecksum());
writeInterfaces(generator, event.getSentryInterfaces());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ public void testEventServerNameWrittenProperly(@Injectable("serverName") final S
assertThat(jsonOutputStreamParser.value(), is(jsonResource("/net/kencochrane/raven/marshaller/json/jsonmarshallertest/testServerName.json")));
}

@Test
public void testEventReleaseWrittenProperly(@Injectable("release") final String mockRelease) throws Exception {
final JsonOutputStreamParser jsonOutputStreamParser = newJsonOutputStream();
new NonStrictExpectations() {{
mockEvent.getRelease();
result = mockRelease;
}};

jsonMarshaller.marshall(mockEvent, jsonOutputStreamParser.outputStream());

assertThat(jsonOutputStreamParser.value(), is(jsonResource("/net/kencochrane/raven/marshaller/json/jsonmarshallertest/testRelease.json")));
}

@Test
public void testEventChecksumWrittenProperly(@Injectable("1234567890abcdef") final String mockChecksum) throws Exception {
final JsonOutputStreamParser jsonOutputStreamParser = newJsonOutputStream();
Expand Down Expand Up @@ -269,10 +282,10 @@ public void testCompressedDataIsWorking() throws Exception {
jsonMarshaller.marshall(mockEvent, outputStream);

assertThat(new String(outputStream.toByteArray(), Charsets.UTF_8.name()), is(""
+ "eJyFjcEOAiEMRP+lZ0zYk5Hv8L5psCKxsKSUjclm/"
+ "12islebucy087oBrZR1jjdwYP8MGEhUKwYClxuzAY"
+ "09UEylt6fL2Z7s1HW11n3UC9z5PM55CYFkuMKo90X"
+ "S8L5xkagHG0MFt+0GKslKMmdMx2N6qeB36x/kn7X9"
+ "MPsbwgxBSQ=="));
+ "eJyFjU0KAjEMhe+SdYXOSuw53A+hxlpMOyVpB2GYu"
+ "1vU6dbwNl94PxvQSrnO8QYO7J8DA4lUMRC43JgN1N"
+ "gfFVPp6elytic7dV2tdR/1APd+Puy8hEByUGGs90X"
+ "Swb5xkVhHNwYFt+0GlGQlmTOmMSzEhDqQXlXwa/YP"
+ "8k9tv9b9DbsbRo8="));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": "1234567890abcdef"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": "culprit",
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": [
"string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": "test"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": [
true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": {
"key": "value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": null
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": {
"null": "value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": 1
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": {
"true": "value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": {
"key": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {
"key": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null,
"interfaceKey": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"event_id": "00000000000000000000000000000000",
"message": null,
"timestamp": "1970-01-01T00:00:00",
"level": null,
"logger": null,
"platform": null,
"culprit": null,
"tags": {},
"server_name": null,
"release": "release",
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": "serverName",
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tagName": "tagValue"
},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"culprit": null,
"tags": {},
"server_name": null,
"release": null,
"extra": {},
"checksum": null
}
Loading