Skip to content

Commit

Permalink
fix: reuse Hub instances for Sentry events (#328)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Romero Montes <[email protected]>
  • Loading branch information
ruromero authored Apr 1, 2024
1 parent 80e5087 commit 28b59d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.redhat.exhort.monitoring.impl.SentryMonitoringClient;

import io.quarkus.runtime.annotations.RegisterForReflection;
import io.sentry.Hub;
import io.sentry.SentryOptions;

import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -47,6 +48,6 @@ public MonitoringClient newInstance() {
opt.setDsn(dsn.get());
opt.setEnvironment(environment);
opt.setTag("server_name", serverName.get());
return new SentryMonitoringClient(opt);
return new SentryMonitoringClient(new Hub(opt));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@

import io.quarkus.runtime.annotations.RegisterForReflection;
import io.sentry.Hub;
import io.sentry.SentryOptions;
import io.sentry.protocol.User;

@RegisterForReflection
public class SentryMonitoringClient implements MonitoringClient {

private final SentryOptions options;
private final Hub hub;

public SentryMonitoringClient(SentryOptions options) {
this.options = options;
public SentryMonitoringClient(Hub hub) {
this.hub = hub;
}

@Override
public void reportException(Throwable exception, MonitoringContext context) {
var hub = new Hub(options);
if (!context.breadcrumbs().isEmpty()) {
context.breadcrumbs().forEach(b -> hub.addBreadcrumb(b));
}
Expand Down

0 comments on commit 28b59d0

Please sign in to comment.