Hi there,
I’m trying to use Sentry in my Spring Boot + Gradle project and am going crazy.
I’m not seeing events and I expect that I should be.
I’m using:
compile 'io.sentry:sentry-spring-boot-starter:3.2.0'
compile 'io.sentry:sentry-logback:3.2.0'
I have an application.yml:
sentry:
dsn: $secret-sentry-dsn
in-app-includes: packages
max-breadcrumbs: 150
logging:
minimum-event-level: info
minimum-breadcrumb-level: debug
enable-tracing: true
traces-sample-rate: 1.0
and am using a profile called local-dev (application-local.yml):
sentry:
environment: local-dev
I can see that when the application starts, traffic comes through:
But when I hit this endpoint:
@GetMapping("/crash")
public String triggerException() {
throw new RuntimeException(
"Expected: controller used to showcase what " + "happens when an exception is thrown");
}
I get no crashes through.
Can anyone tell me what I’m missing?
When using the old java SDK (1.7) I sent exceptions through a global exception handler, could this be interfering?
@ControllerAdvice
public class GlobalExceptionHandler {
private final HoneycombContext honeycombContext;
public GlobalExceptionHandler(HoneycombContext honeycombContext) {
this.honeycombContext = honeycombContext;
}
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = BadRequestException.class)
@ResponseBody
ApiResponseMessage
handleBadRequest(BadRequestException badRequestException) {
Sentry.captureException(badRequestException);
honeycombContext.getContextualData().put("errors.message", badRequestException.getMessage());
return new ApiResponseMessage(HttpStatus.BAD_REQUEST.value(), badRequestException.getMessage());
}
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ExceptionHandler(value = NotFoundException.class)
@ResponseBody
ApiResponseMessage
handleResourceNotFoundException(NotFoundException notFoundException) {
Sentry.captureException(notFoundException);
honeycombContext.getContextualData().put("errors.message", notFoundException.getMessage());
return new ApiResponseMessage(HttpStatus.NOT_FOUND.value(), notFoundException.getMessage());
}
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ExceptionHandler(value = ForbiddenException.class)
@ResponseBody
ApiResponseMessage
handleForbiddenException(ForbiddenException forbiddenException) {
Sentry.captureException(forbiddenException);
honeycombContext.getContextualData().put("errors.message", forbiddenException.getMessage());
return new ApiResponseMessage(HttpStatus.NOT_FOUND.value(), forbiddenException.getMessage());
}
@ResponseStatus(value = HttpStatus.NOT_ACCEPTABLE)
@ExceptionHandler(value = HttpMediaTypeNotAcceptableException.class)
@ResponseBody
ApiResponseMessage
handleHttpMediaTypeNotAcceptableException(HttpMediaTypeNotAcceptableException httpMediaTypeNotAcceptableException) {
Sentry.captureException(httpMediaTypeNotAcceptableException);
honeycombContext.getContextualData().put("errors.message", httpMediaTypeNotAcceptableException.getMessage());
return new ApiResponseMessage(HttpStatus.NOT_ACCEPTABLE.value(), httpMediaTypeNotAcceptableException.getMessage());
}
}