Last active
July 14, 2020 18:04
-
-
Save siedentop/60cf8cf1faae4cca45aa10f54b76c2eb to your computer and use it in GitHub Desktop.
Trying out the new Sentry Performance monitoring feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_meta": { | |
"hash": { | |
"sha256": "4c3c3988cee9ef0aabedb0fe77f041c143b7c7fdde2feb775bb0578948a09288" | |
}, | |
"pipfile-spec": 6, | |
"requires": { | |
"python_version": "3.7" | |
}, | |
"sources": [ | |
{ | |
"name": "pypi", | |
"url": "https://pypi.org/simple", | |
"verify_ssl": true | |
} | |
] | |
}, | |
"default": { | |
"certifi": { | |
"hashes": [ | |
"sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3", | |
"sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41" | |
], | |
"version": "==2020.6.20" | |
}, | |
"sentry-sdk": { | |
"hashes": [ | |
"sha256:da06bc3641e81ec2c942f87a0676cd9180044fa3d1697524a0005345997542e2", | |
"sha256:e80d61af85d99a1222c1a3e2a24023618374cd50a99673aa7fa3cf920e7d813b" | |
], | |
"index": "pypi", | |
"version": "==0.16.0" | |
}, | |
"urllib3": { | |
"hashes": [ | |
"sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527", | |
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115" | |
], | |
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", | |
"version": "==1.25.9" | |
} | |
}, | |
"develop": {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[sentry] DEBUG: Setting up integrations (with default = True) | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.django.DjangoIntegration: Django not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.flask.FlaskIntegration: Flask is not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.bottle.BottleIntegration: Bottle not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.falcon.FalconIntegration: Falcon not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sanic.SanicIntegration: Sanic not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.celery.CeleryIntegration: Celery not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.rq.RqIntegration: RQ not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.aiohttp.AioHttpIntegration: AIOHTTP not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.tornado.TornadoIntegration: Tornado not installed | |
[sentry] DEBUG: Did not import default integration sentry_sdk.integrations.sqlalchemy.SqlalchemyIntegration: SQLAlchemy not installed. | |
[sentry] DEBUG: Setting up previously not enabled integration logging | |
[sentry] DEBUG: Setting up previously not enabled integration stdlib | |
[sentry] DEBUG: Setting up previously not enabled integration excepthook | |
[sentry] DEBUG: Setting up previously not enabled integration dedupe | |
[sentry] DEBUG: Setting up previously not enabled integration atexit | |
[sentry] DEBUG: Setting up previously not enabled integration modules | |
[sentry] DEBUG: Setting up previously not enabled integration argv | |
[sentry] DEBUG: Setting up previously not enabled integration threading | |
[sentry] DEBUG: Enabling integration logging | |
[sentry] DEBUG: Enabling integration stdlib | |
[sentry] DEBUG: Enabling integration excepthook | |
[sentry] DEBUG: Enabling integration dedupe | |
[sentry] DEBUG: Enabling integration atexit | |
[sentry] DEBUG: Enabling integration modules | |
[sentry] DEBUG: Enabling integration argv | |
[sentry] DEBUG: Enabling integration threading | |
[sentry] DEBUG: Sending envelope [envelope with 1 items (default)] project:1860700 host:o333597.ingest.sentry.io | |
[sentry] DEBUG: atexit: got shutdown signal | |
[sentry] DEBUG: atexit: shutting down client | |
[sentry] DEBUG: Flushing HTTP transport | |
[sentry] DEBUG: background worker got flush request | |
[sentry] DEBUG: 1 event(s) pending on flush | |
Sentry is attempting to send 1 pending error messages | |
Waiting up to 2 seconds | |
Press Ctrl-C to quit | |
[sentry] DEBUG: background worker flushed | |
[sentry] DEBUG: Killing HTTP transport | |
[sentry] DEBUG: background worker got kill request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sentry_sdk | |
import time | |
sentry_sdk.init( | |
"https://[email protected]/1860700", | |
_experiments={"auto_enabling_integrations": True}, | |
traces_sample_rate = 1.0, | |
debug=True, | |
) | |
from sentry_sdk import start_transaction | |
from dataclasses import dataclass | |
@dataclass | |
class Item: | |
transaction_name: str | |
def get_transaction_name(self): | |
return self.transaction_name | |
def process_item(item: Item): | |
time.sleep(0.1) | |
for item in [Item("hello"), Item("bar")]: | |
with start_transaction(op="task", name=item.get_transaction_name()): | |
# process_item may create more spans internally (see next examples) | |
process_item(item) |
Hi Markus,
thanks for the suggestion!
So, I added capture_message
to (1) make sure my connection works (it didn't due to proxy), and (2) to force a flush to Sentry.
Here is a list of changes, which each work independently. I.e. making any one of these changes makes performance info show up on Sentry-Web.
sentry_sdk.init(
...
shutdown_timeout=10,
)
This at end of file:
# sentry_sdk.capture_message(f"Test. Flush some messages..")
# As suggested by @untitaker
# time.sleep(10)
sentry_sdk.flush(timeout=30)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Christoph, maintainer of the python sdk here. Could you try putting
time.sleep(10)
at the end of your program. The SDK, according to its logs, is clearly successful in capturing data and attempting to send it out, but then times out on shutdown. I wonder if the latency to our servers is prohibitively large.