-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransactions_not_sent.py
62 lines (50 loc) · 1.63 KB
/
transactions_not_sent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# encoding: utf-8
'''
:authors:
| raul.catalina <raul.catalina@skydance.com>
:file: | sentry.sentry_support_test_02.py
:date: | 2024-04-09
:revision: | 2024-04-09
:summary: | Testing transactions not coming to Sentry
:copyright:
| Copyright Skydance Animation Madrid S.L. 2024
| The copyright to the computer program(s) herein is the property of Skydance Animation Madrid S.L..
| The program(s) may be used and/or copied only with the written permission of Skydance Animation Madrid S.L.
or in accordance with the terms and conditions stipulated in the agreement/contract under
which the program(s) have been supplied.
'''
import os
import getpass
import sentry_sdk
from sentry_sdk.integrations.atexit import AtexitIntegration
DSN = '<YOUR-DSN-HERE>'
def hello(name):
""" Dummy function to say Hello """
print('Hello {}!'.format(name))
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 send_transaction(name):
""" Send a Sentry transaction """
with sentry_sdk.start_transaction(name=name, op='test') as transaction:
hello(name)
transaction.hub.flush()
def main():
""" Main function """
init_sentry()
for i in range(6):
send_transaction('Sherlock.{}'.format(i + 1))
send_transaction('Holmes')
if __name__ == '__main__':
main()