-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (30 loc) · 801 Bytes
/
main.py
File metadata and controls
37 lines (30 loc) · 801 Bytes
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
#!/usr/bin/env python3
# https://community.grafana.com/t/configuring-grafana-and-pyroscope-phlare-with-docker-compose/102023
# https://github.com/grafana/pyroscope/blob/main/examples/python/simple/main.py
#
import logging
import os
import pyroscope
l = logging.getLogger()
l.setLevel(logging.DEBUG)
addr = os.getenv("PYROSCOPE_SERVER_ADDRESS") or "http://pyroscope:4040"
print(addr)
pyroscope.configure(
application_name = "simple.python.app",
server_address = addr,
enable_logging = True,
)
def work(n):
i = 0
while i < n:
i += 1
def fast_function():
with pyroscope.tag_wrapper({ "function": "fast" }):
work(20000)
def slow_function():
with pyroscope.tag_wrapper({ "function": "slow" }):
work(80000)
if __name__ == "__main__":
while True:
fast_function()
slow_function()