Skip to content

Commit

Permalink
feat: add sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Dec 11, 2024
1 parent 7c33bbd commit 7e1dd17
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions java/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins {
id 'war'
id 'idea'
id 'nu.studer.jooq' version '8.0'
id "io.sentry.jvm.gradle" version "4.14.1"
}

repositories {
Expand All @@ -34,6 +35,17 @@ sourceSets {
}
}

sentry {
// Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.
// This enables source context, allowing you to see your source
// code as part of your stack traces in Sentry.
includeSourceContext = true

org = "getalby"
projectName = "albyhub-vss"
authToken = System.getenv("SENTRY_AUTH_TOKEN")
}

group 'org.vss'
version '1.0'

Expand Down
2 changes: 2 additions & 0 deletions java/app/src/main/java/org/vss/api/DeleteObjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.vss.KVStore;
import org.vss.auth.AuthResponse;
import org.vss.auth.Authorizer;
import io.sentry.Sentry;

@Path(VssApiEndpoint.DELETE_OBJECT)
@Slf4j
Expand All @@ -33,6 +34,7 @@ public Response execute(byte[] payload, @Context HttpHeaders headers) {
return toResponse(response);
} catch (Exception e) {
log.error("Exception in DeleteObjectApi: ", e);
Sentry.captureException(e);
return toErrorResponse(e);
}
}
Expand Down
2 changes: 2 additions & 0 deletions java/app/src/main/java/org/vss/api/GetObjectApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.vss.KVStore;
import org.vss.auth.AuthResponse;
import org.vss.auth.Authorizer;
import io.sentry.Sentry;

@Path(VssApiEndpoint.GET_OBJECT)
@Slf4j
Expand All @@ -34,6 +35,7 @@ public Response execute(byte[] payload, @Context HttpHeaders headers) {
return toResponse(response);
} catch (Exception e) {
log.error("Exception in GetObjectApi: ", e);
Sentry.captureException(e);
return toErrorResponse(e);
}
}
Expand Down
2 changes: 2 additions & 0 deletions java/app/src/main/java/org/vss/api/HealthCheckApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.vss.KVStore;
import org.vss.auth.AuthResponse;
import org.vss.auth.Authorizer;
import io.sentry.Sentry;

@Path(VssApiEndpoint.HEALTHCHECK)
@Slf4j
Expand All @@ -37,6 +38,7 @@ public Response execute(@Context HttpHeaders headers) {
.build();
} catch (Exception e) {
log.error("Exception in HealthCheckApi: ", e);
Sentry.captureException(e);
return Response.status(500)
.entity("an unexpected error occurred: " + e.getMessage())
.build();
Expand Down
2 changes: 2 additions & 0 deletions java/app/src/main/java/org/vss/api/ListKeyVersionsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.vss.ListKeyVersionsResponse;
import org.vss.auth.AuthResponse;
import org.vss.auth.Authorizer;
import io.sentry.Sentry;

@Path(VssApiEndpoint.LIST_KEY_VERSIONS)
@Slf4j
Expand All @@ -34,6 +35,7 @@ public Response execute(byte[] payload, @Context HttpHeaders headers) {
return toResponse(response);
} catch (Exception e) {
log.error("Exception in ListKeyVersionsApi: ", e);
Sentry.captureException(e);
return toErrorResponse(e);
}
}
Expand Down
2 changes: 2 additions & 0 deletions java/app/src/main/java/org/vss/api/PutObjectsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.vss.PutObjectResponse;
import org.vss.auth.AuthResponse;
import org.vss.auth.Authorizer;
import io.sentry.Sentry;

@Path(VssApiEndpoint.PUT_OBJECTS)
@Slf4j
Expand All @@ -34,6 +35,7 @@ public Response execute(byte[] payload, @Context HttpHeaders headers) {
return toResponse(response);
} catch (Exception e) {
log.error("Exception in PutObjectsApi: ", e);
Sentry.captureException(e);
return toErrorResponse(e);
}
}
Expand Down
6 changes: 6 additions & 0 deletions java/app/src/main/java/org/vss/guice/BaseModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
import org.vss.auth.NoopAuthorizer;
import org.vss.impl.postgres.PostgresBackendImpl;
import org.vss.auth.JwtAuthorizer;
import io.sentry.Sentry;

public class BaseModule extends AbstractModule {

@Override
protected void configure() {
Sentry.init(options -> {
options.setDsn(System.getenv("vss.sentry.dsn"));
// options.setDebug(true);
});

// Provide PostgresBackend as default implementation for KVStore.
bind(KVStore.class).to(PostgresBackendImpl.class).in(Singleton.class);

Expand Down

0 comments on commit 7e1dd17

Please sign in to comment.