---
title: "Advanced Usage"
description: "Learn about managing the release ID and customizing Spring Boot to your organization's needs."
url: https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage/
---

# Advanced Usage | Sentry for Spring Boot

Sentry's Spring Boot integration automatically includes the release and sets options as described in the following sections.

## [Using Git Commit ID As The Release](https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage.md#using-git-commit-id-as-the-release)

When Spring Boot is [configured to generate Git information](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-git-info), every event triggered by Sentry will have a `release` field set to the current Git commit ID that will enable Sentry's [release health](https://docs.sentry.io/product/releases/health.md) feature.

This feature can be disabled in `application.properties` file:

`application.properties`

```properties
sentry.use-git-commit-id-as-release=false
```

## [Registering Custom Event Processor](https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage.md#registering-custom-event-processor)

Any Spring bean implementing `EventProcessor` will be automatically set on `SentryOptions` during Sentry SDK auto-configuration. There can be multiple event processors registered in single application.

```java
import io.sentry.SentryEvent;
import io.sentry.EventProcessor;
import io.sentry.Hint
import org.springframework.stereotype.Component;

@Component
public class CustomEventProcessor implements EventProcessor {
  @Override
  public SentryEvent process(SentryEvent event, Hint hint) {
    // modify the event or return null to drop it
    return event;
  }
}
```

## [Registering Custom Before Send Callback](https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage.md#registering-custom-before-send-callback)

Any Spring bean implementing the `BeforeSendCallback` will be automatically set on `SentryOptions` during the SDK's auto-configuration. Note that there can be only a single bean set this way.

```java
import io.sentry.SentryEvent;
import io.sentry.SentryOptions;
import io.sentry.Hint
import org.springframework.stereotype.Component;

@Component
public class CustomBeforeSendCallback implements SentryOptions.BeforeSendCallback {
  @Override
  public SentryEvent execute(SentryEvent event, Hint hint) {
    // Example: Never send server name in events
    event.setServerName(null);
    return event;
  }
}
```

## [Registering Custom Before Breadcrumb Callback](https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage.md#registering-custom-before-breadcrumb-callback)

Any Spring bean implementing the `BeforeBreadcrumbCallback` will be automatically set on `SentryOptions` during the SDK's auto-configuration. Note that there can be only a single bean set this way.

```java
import io.sentry.Breadcrumb;
import io.sentry.SentryOptions;
import io.sentry.Hint
import org.springframework.stereotype.Component;

@Component
public class CustomBeforeBreadcrumbCallback implements SentryOptions.BeforeBreadcrumbCallback {

  @Override
  public Breadcrumb execute(Breadcrumb breadcrumb, Hint hint) {
    // Don't add breadcrumbs with message containing:
    if (breadcrumb.getMessage() != null
      && breadcrumb.getMessage().contains("bad breadcrumb")) {
      return null;
    }
    return breadcrumb;
  }
}
```

## [Registering Custom On Discard Callback](https://docs.sentry.io/platforms/java/guides/spring-boot/advanced-usage.md#registering-custom-on-discard-callback)

Any Spring bean implementing the `OnDiscardCallback` will be automatically set on `SentryOptions` during the SDK's auto-configuration. Note that there can be only a single bean set this way.

```java
import io.sentry.SentryOptions;
import io.sentry.clientreport.DiscardReason;
import io.sentry.DataCategory;
import org.springframework.stereotype.Component;

@Component
class CustomOnDiscardCallback implements SentryOptions.OnDiscardCallback {
  @Override 
  public void execute(DiscardReason reason, DataCategory category, Long count) {
    // Only record the number of lost spans due to overflow conditions
    if ((reason == DiscardReason.CACHE_OVERFLOW
            || reason == DiscardReason.QUEUE_OVERFLOW)
        && category == DataCategory.Span) {
      System.out.println("Discarded " + number + " spans due to overflow.");
    }
  }
}
```
