Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
added dist to options (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Jan 3, 2020
1 parent 1a8bbd7 commit 5d40505
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ private void processNonCachedEvent(SentryEvent event) {
event.setEnvironment(options.getEnvironment());
}

if (event.getDist() == null) {
event.setDist(options.getDist());
}

if (event.getThreads() == null) {
event.setThreads(sentryThreadFactory.getCurrentThreads());
}
Expand Down
9 changes: 9 additions & 0 deletions sentry-core/src/main/java/io/sentry/core/SentryOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SentryOptions {
private @Nullable Double sampleRate;
private @NotNull List<String> inAppExcludes;
private @NotNull List<String> inAppIncludes;
private @Nullable String dist;

public void addEventProcessor(@NotNull EventProcessor eventProcessor) {
eventProcessors.add(eventProcessor);
Expand Down Expand Up @@ -228,6 +229,14 @@ public void addInAppInclude(@NotNull String include) {
inAppIncludes.add(include);
}

public @Nullable String getDist() {
return dist;
}

public void setDist(@Nullable String dist) {
this.dist = dist;
}

public interface BeforeSendCallback {
@Nullable
SentryEvent execute(@NotNull SentryEvent event, @Nullable Object hint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class MainEventProcessorTest {
dsn = dsnString
release = "release"
environment = "environment"
dist = "dist"
}
fun getSut() = MainEventProcessor(sentryOptions)
}

private val fixture = Fixture()

@Test
fun `when processing an event from UncaughtExceptionHandlerIntegration, crashed thread is flaged, mechanism added`() {
fun `when processing an event from UncaughtExceptionHandlerIntegration, crashed thread is flagged, mechanism added`() {
val sut = fixture.getSut()

val crashedThread = Thread.currentThread()
Expand All @@ -42,9 +43,25 @@ class MainEventProcessorTest {

assertEquals("release", event.release)
assertEquals("environment", event.environment)
assertEquals("dist", event.dist)
assertTrue(event.threads.first { t -> t.id == crashedThread.id }.isCrashed)
}

@Test
fun `data should be applied only if event doesn't have them`() {
val sut = fixture.getSut()
var event = generateCrashedEvent()
event.dist = "eventDist"
event.environment = "eventEnvironment"
event.release = "eventRelease"

event = sut.process(event, null)

assertEquals("eventRelease", event.release)
assertEquals("eventEnvironment", event.environment)
assertEquals("eventDist", event.dist)
}

@Test
fun `When hint is Cached, data should not be applied`() {
val sut = fixture.getSut()
Expand Down

0 comments on commit 5d40505

Please sign in to comment.