New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transactions not working as expected (metrics are not sent) #3004
Comments
Hey @raul3z, thanks for reporting and for providing a script to repro! I can't reproduce this locally, I get Sherlocks 1 through 6 as well as the Holmes transaction, tried this about 5 times. Stuff that comes to mind:
You selected that you're on SaaS -- if you give me your org name I can take a closer look. (You can also send it to me on |
Hi @sentrivana , thank you for answering me!
Thanks for your time. |
Thanks for the follow up! For 3. I could've worded the question better -- I meant if you still observe this even if you remove |
Oh sorry, I misunderstood it. Yes, I just have tried setting For the org name, what do you need exactly? the company site url or the project DSN? |
@raul3z you're calling a def send_transaction(name):
""" Send a Sentry transaction """
with sentry_sdk.start_transaction(name=name, op='test') as transaction:
hello(name)
def main():
""" Main function """
init_sentry()
for i in range(6):
send_transaction('Sherlock.{}'.format(i + 1))
send_transaction('Holmes')
sentry_sdk.flush() # not really necessary since atexit will call this anyway |
That seems to work! I am receiving the seven entries in Sentry, even if I disable the atexit integration, so for any reason that integration is not working well for us. |
ok to clarify you can either disable atexit and flush manually: def init_sentry():
""" Initializes Sentry """
sentry_sdk.init(
debug=True,
dsn=DSN,
max_breadcrumbs=100,
environment=os.environ.get('ENVIRON'),
traces_sample_rate=1.0,
default_integrations=False,
integrations=[],
)
sentry_sdk.set_user({'username': getpass.getuser()})
def main():
""" Main function """
init_sentry()
for i in range(6):
send_transaction('Sherlock.{}'.format(i + 1))
send_transaction('Holmes')
sentry_sdk.flush() or have atexit and not call flush manually: def init_sentry():
""" Initializes Sentry """
sentry_sdk.init(
debug=True,
dsn=DSN,
max_breadcrumbs=100,
environment=os.environ.get('ENVIRON'),
traces_sample_rate=1.0,
default_integrations=False,
integrations=[AtexitIntegration()],
)
sentry_sdk.set_user({'username': getpass.getuser()})
def main():
""" Main function """
init_sentry()
for i in range(6):
send_transaction('Sherlock.{}'.format(i + 1))
send_transaction('Holmes') these should both do the same thing. In general, you don't need to flush manually anywhere if you just use the sdk with default integrations, stuff should just work. |
It works flushing manually otherwise it does not send all the metrics |
ok well then just add the flush if that works for you. In theory the flush should happen automatically but maybe there's some other problem with your setup. |
Hi @sl0thentr0py, I have to say that it is working for my isolated script but if I try to do the same in the main code it is not working, I have to check if we have something wrong there with our code but in the meantime, do you have an idea of what could be wrong? what is the recommended setup? Thanks! |
maybe you're killing the process with another signal and the process doesn't get enough time to flush? just a hunch |
I have to check the code properly, just to know, do you have an example on how the server should be initialized? not sure if what I'm doing here is good enough. |
yes that looks ok to me |
Hi there! After get deeper on this I was not able to make it works for our main script, in fact I tested again the isolated script with the changes that worked and now it is not working again, we cannot dedicate more effort on this so we will assume that we are going to lost some transactions :( If you have any idea of what could be happening, it is welcome. Thanks! |
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.26.0; 1.44.1
Steps to Reproduce
Run this script
Expected Result
Having seven entries in sentry Discover, from Sherlock.1 to Sherlock.6 and another one for Holmes
Actual Result
Not having all the metrics, sometimes it works and sometimes not, even with traces_sample_rate set to 1.0 and flushing transactions manually.
output log:
Hello Sherlock.1!
[sentry] DEBUG: Setting up integrations (with default = False)
[sentry] DEBUG: Setting up previously not enabled integration atexit
[sentry] DEBUG: Enabling integration atexit
[sentry] DEBUG: Setting SDK name to 'sentry.python'
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.1>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.2>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Sherlock.2!
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: 2 event(s) pending on flush
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.3>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Sherlock.3!
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.4>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Sherlock.4!
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.5>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Sherlock.5!
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction <Sherlock.6>
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Sherlock.6!
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: [Tracing] Starting transaction
[sentry] DEBUG: [Profiling] Discarding profile because profiler was not started.
Hello Holmes!
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: atexit: got shutdown signal
[sentry] DEBUG: atexit: shutting down client
[sentry] DEBUG: Flushing HTTP transport
[sentry] DEBUG: Sending envelope [envelope with 1 items (transaction)] project:4505... host:o450...
[sentry] DEBUG: background worker got flush request
[sentry] DEBUG: background worker flushed
[sentry] DEBUG: Killing HTTP transport
[sentry] DEBUG: background worker got kill request
[sentry] DEBUG: Killing HTTP transport
The text was updated successfully, but these errors were encountered: