When using environment (shell) variables, they are added and sent via the sentry logback integration.
However, there is a big caveat, they are not interpolated.
SENTRY_DSN=https://[email protected]/xxxxxx
SENTRY_TAGS=app:MyApplication,host:$HOSTNAME,project:${CI_PROJECT_NAME},branch:${CI_COMMIT_REF_NAME}
SENTRY_ENVIRONMENT=${CI_COMMIT_REF_NAME}
This happens even if these variables have a value, it will just not get replaced.
Neither $HOSTNAME nor ${CI_COMMIT_REF_NAME} will be resolved/replaced. It will result in the string just added verbatim and sent to sentry, as can be seen in the screenshot:
logback-spring.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Sentry" class="io.sentry.logback.SentryAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>WARN</level>
</filter>
</appender>
<root level="INFO">
<!-- Log both to console(collected by SumoLogic and Cloudwatch) and Sentry -->
<appender-ref ref="CONSOLE"/>
<appender-ref ref="Sentry"/>
</root>
</configuration>
This article, explains how to use the logback integration, but there is no mention of SENTRY_TAGS or other variables https://blog.sentry.io/2016/01/28/capturing-java-exceptions
There is a similar question here: Setting environment variables of Sentry dynamically for logback.xml Sentry appender
