Comments (11)
Hey @szokeasaurusrex -> Shared the link directly with you
from sentry-python.
Hi @mitchdawson1982, thank you for reporting this problem. Could you provide us a link to one of the error events where the environment was set to dev
, even though the event originated from a non-dev
environment to help us investigate?
from sentry-python.
Hi @szokeasaurusrex Sure here is one of the links
I have noticed that the trace details are populated with much more information for a working example.
from sentry-python.
@mitchdawson1982 Could you try using the SENTRY_ENVIRONMENT
env var instead? If you set SENTRY_ENVIRONMENT
, it'll be used automatically, so you could remove it from the init
. See also here.
As far as I can tell the SDK will never set the environment to dev
by itself. This is the only place I found where we set it to something (if it's not there), and we default to production
. So my hunch is this might be originating somewhere else. Maybe something external, like a tool, is setting the ENV
var, which is why I'm wondering if the issue goes away after switching to something more unique like SENTRY_ENVIRONMENT
.
Since the faulty events also have a different release though, is it at all possible the dev
events you're seeing are coming from a different place entirely? (Automated tests, etc.) Is the non-hash release something that you'd expect seeing in your local environment?
from sentry-python.
@mitchdawson1982 Could you try using the
SENTRY_ENVIRONMENT
env var instead? If you setSENTRY_ENVIRONMENT
, it'll be used automatically, so you could remove it from theinit
. See also here.As far as I can tell the SDK will never set the environment to
dev
by itself. This is the only place I found where we set it to something (if it's not there), and we default toproduction
. So my hunch is this might be originating somewhere else. Maybe something external, like a tool, is setting theENV
var, which is why I'm wondering if the issue goes away after switching to something more unique likeSENTRY_ENVIRONMENT
.Since the faulty events also have a different release though, is it at all possible the
dev
events you're seeing are coming from a different place entirely? (Automated tests, etc.) Is the non-hash release something that you'd expect seeing in your local environment?
Thanks for the suggestion I will try this out when I get time. In terms of where the events are originating from, I cant envisage them coming from anywhere else. We have tests but these are manually invoked, the scenario I have described is where the app is being run normally.
from sentry-python.
Hi @sentrivana I have performed further testing this morning with and without the SENTRY_ENVIRONMENT
variable. To clarify I am running this application utilising the current main branch on my local Macbook.
I have been thinking about the rationale provided for this behaviour and would like to clarify some of the points.
On the tests where we have populated the ENV
variable and sentry_sdk.init(environment=ENV or "local")
, I have in nearly all cases printed out the value of ENV
to the terminal after sentry_sdk.init(environment=ENV or "local")
in settings.py
to validate the correct value is passed as expected. Where I have done so this has always been consistent for both correct and incorrect alerts and therefore gives me a high level of confidence that the right value has always been passed to the sdk environment argument. I don't see any likelihood of our code being able to manipulate the environment argument within sentry after the sdk init has been called.
Where correct alerts are seen the release hash matches the correct commit hash i.e. this alert has the latest commit hash in main. However for incorrect alerts we see 0.12.1.5
. The only correlation I can find with this number is the version of the acryl-datahub
package we have installed. Which is a dependency of a library we have written in this application to talk to the backend datahub application.
Results
I have tested several with the SENTRY_ENVIRONMENT
variable set to sent-env
with the environment
argument removed from the sdk init
. In all cases the alert environmental value was persistent but there was variance in the trace details and the release names. Please see below.
from sentry-python.
In summary, when the wrong environment
is set also the release
is wrong. My hunch is that someone else is running the project that has set ENV
to the wrong value.
And this other one that runs the project does not run it from a Git repository. How the Sentry Python SDK sets the release
, if there is none specified in sentry_sdk.init()
, isdescribed here (below the code snippet): https://docs.sentry.io/platforms/python/configuration/releases/#setting-a-release
Do you have the project running in Google App Engine, Azure, AWS, Heroku, Codebuild, Circle CI, GitLab CI/CD, or Travis CI?
from sentry-python.
In summary, when the wrong
environment
is set also therelease
is wrong. My hunch is that someone else is running the project that has setENV
to the wrong value.And this other one that runs the project does not run it from a Git repository. How the Sentry Python SDK sets the
release
, if there is none specified insentry_sdk.init()
, isdescribed here (below the code snippet): https://docs.sentry.io/platforms/python/configuration/releases/#setting-a-releaseDo you have the project running in Google App Engine, Azure, AWS, Heroku, Codebuild, Circle CI, GitLab CI/CD, or Travis CI?
I'm not as yet convinced that the environment is being set wrong. On the tests where we have populated the ENV variable and sentry_sdk.init(environment=ENV or "local"), I have in nearly all cases printed out the value of ENV to the terminal after sentry_sdk.init(environment=ENV or "local") in settings.py to validate the correct value is passed as expected. Where I have done so this has always been consistent for both correct and incorrect alerts and therefore gives me a high level of confidence that the right value has always been passed to the sdk environment argument. Once this value has been passed to the sdk init, how could our code manipulate this value? I see this behaviour on local development laptops and three separate k8 pods.
from sentry-python.
Where correct alerts are seen the release hash matches the correct commit hash i.e. this alert has the latest commit hash in main. However for incorrect alerts we see 0.12.1.5. The only correlation I can find with this number is the version of the acryl-datahub package we have installed. Which is a dependency of a library we have written in this application to talk to the backend datahub application.
Is it possible acryl-datahub
itself is using Sentry? I don't have any experience with it but there seem to be some actual hits for sentry
in the repo that I got to via their PyPI. This line seems especially interesting.
from sentry-python.
Thanks, I am currently investigating this.
from sentry-python.
Related Issues (20)
- Bring back `get_last_event_id` HOT 1
- Load Testing Django Cache Module HOT 3
- Sentry can't be initialized twice HOT 3
- Issue with _set_db_data when using psycopg3 HOT 4
- Django Cache Module: handle cache clusters
- DJANGO - Sentry does not work in production, only in development environments HOT 2
- Dynamic sampling context might be missing from Celery Beat transactions
- Deprecate `set_measurement`
- 2.2.0: documentation build fails `most likely due to a circular import` HOT 5
- Queues module: Celery producer instrumentation
- `sentry-sdk[grpcio]` requires `protobuf` HOT 3
- Add entry point for opentelemetry propagator HOT 1
- [Django] Clickhouse integration not working after upgrading from 1.45.0 HOT 4
- AttributeError: module 'collections' has no attribute 'MutableMapping' in Python 3.12 HOT 4
- Fix langchain tests
- "Generic WSGI Request" naming HOT 7
- Make ClickHouse integration work with `django-clickhouse-backend`
- `sentry_sdk.init` breaks `import exceptiongroup` in virtualenv activated with `activate_this.py` HOT 2
- Django doesn't run if you remove a rq job on app.ready HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-python.