Sentry-java: Cannot set release value from environment variable in sentry.properties

Created on 18 Mar 2020  Â·  13Comments  Â·  Source: getsentry/sentry-java

I'm using

  <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry-spring-boot-starter</artifactId>
            <version>1.7.30</version>
        </dependency>

and my sentry.properties has

release=${SENTRY_RELEASE_VERSION}
dns=${SENTRY_DNS}
stacktrace.app.packages=io.qtalk.datarain
environment=${SENTRY_ENVIRONMENT}

Values for dns and environment are populated correctly. But the value of release is set to the string ${SENTRY_RELEASE_VERSION} and not its actual environment value.

invalid

All 13 comments

hey @nischitpra sorry late reply.

that's odd, the look-up method for release and environment is the same, are you sure ${SENTRY_RELEASE_VERSION} is set and available?

mind setting up a test project? thanks
cc @bruno-garcia

Hey Manoel,

I've uploaded the test repository to
https://github.com/nischitpra/SentryTest

Its a spring boot app with a controller PingController. After running the
server, curl to localhost:8080/ping will send an event to sentry.

This works well with application.properties tough.

The environment variables used are in the screenshot below
[image: Screenshot from 2020-05-03 19-42-07.png]

The Sentry event is as follows
[image: Screenshot from 2020-05-03 19-37-35.png]

On Sun, 3 May 2020 at 18:49, Manoel Aranda Neto notifications@github.com
wrote:

hey @nischitpra https://github.com/nischitpra sorry late reply.

that's odd, the look-up method for release and environment is the same,
are you sure ${SENTRY_RELEASE_VERSION} is set and available?

mind setting up a test project? thanks
cc @bruno-garcia https://github.com/bruno-garcia

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/getsentry/sentry-java/issues/830#issuecomment-623109142,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AE6IANKGJL6M4FXTJQTGRVTRPVVODANCNFSM4LOOHSPQ
.

--
Regards,
Nischit

Please note the correct env var is SENTRY_RELEASE.

@nischitpra your screenshots didn't get into GitHub. Could you please try to add them via the github web UI?

Hey @bruno-garcia ,
Sorry about that,

sentry_event
environment_variables

Yes, I've tried with SENTRY_RELEASE as well and it works great. But trying to get it from the environment does not.

@nischitpra I guess you are mixing up the way of setting the values.
its either the sentry.properties with values but not system envs
or system envs itself.

so it's valid to say using sentry.properties
release=abc

OR the system env is set with the abc value.
export SENTRY_RELEASE=abc

if you have both set the sentry.properties and the system env SENTRY_RELEASE, there's a lookup order and won't continue if a value has been found.

@marandaneto
In the test repo I've created, I've only used sentry.properties and not SENTRY_RELEASE. As shown in the image of env variables used,, the field does not exist.

@nischitpra so if u have a release entry on sentry.properties that's all you need, it should be a raw value and not a system env.
Sentry won't read its entry and lookup system envs.
if you need to read a release from system envs.

omit release from sentry.properties and use just the system env SENTRY_RELEASE

@marandaneto
Yes,, I actually did this, but it feels like a work around and having it on the properties file like everything else would be really consistent. So used application.properties instead all together.
Maybe be can have this in the documentation as well?

btw I believe the other 2 confs on sentry.properties worked out only because coincidentally matched up with the predefined System envs and system envs are read before the Sentry properties file.

so if you remove dsn, environment and release from sentry.properties.

rename your system env SENTRY_RELEASE_VERSION to SENTRY_RELEASE it should work.

Oh, okay.. I'll try this out and confirm

Yes, the dsn and environment values were actually being picked from the environment variable and not sentry.properties. When I renamed the env variables to something else, it didn't work. Got it.

It would be nice to have this in the documentation to prevent confusion though. Because, like in application.properties I was expecting that I could get env variables in sentry.properties as well.

glad that it worked out, tbh I've not found anything on the docs that mention this mix of properties file and system envs. it's always either one or the other.

https://docs.sentry.io/clients/java/config/#options

we'll write this down explicitly, thanks for the feedback.

Was this page helpful?
0 / 5 - 0 ratings