Start pyroscope only after uwsgi fork (#1607)
# What this PR does Currently main uwsgi process sends spans while being idle, which make graphs unreadable <img width="494" alt="Screenshot 2023-03-23 at 18 00 21" src="https://user-images.githubusercontent.com/2262529/227168746-125f2329-bfaa-4989-a391-712a230e0087.png"> ## Which issue(s) this PR fixes ## Checklist - [ ] Tests updated - [ ] Documentation added - [ ] `CHANGELOG.md` updated
This commit is contained in:
parent
8278ad9670
commit
8d5cbcecf2
2 changed files with 23 additions and 12 deletions
|
|
@ -40,3 +40,22 @@ if settings.OTEL_TRACING_ENABLED and settings.OTEL_EXPORTER_OTLP_ENDPOINT:
|
|||
except ModuleNotFoundError:
|
||||
# Only works under uwsgi web server environment
|
||||
pass
|
||||
|
||||
if settings.PYROSCOPE_PROFILER_ENABLED:
|
||||
try:
|
||||
import pyroscope
|
||||
from uwsgidecorators import postfork
|
||||
|
||||
@postfork
|
||||
def init_pyroscope():
|
||||
pyroscope.configure(
|
||||
application_name=settings.PYROSCOPE_APPLICATION_NAME,
|
||||
server_address=settings.PYROSCOPE_SERVER_ADDRESS,
|
||||
auth_token=settings.PYROSCOPE_AUTH_TOKEN,
|
||||
detect_subprocesses=True,
|
||||
tags={"celery_worker": settings.PYROSCOPE_CELERY_WORKER_QUEUE},
|
||||
)
|
||||
|
||||
except ModuleNotFoundError:
|
||||
# Only works under uwsgi web server environment
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -678,15 +678,7 @@ MIGRATION_LINTER_OPTIONS = {"exclude_apps": ["social_django", "silk", "fcm_djang
|
|||
MIGRATION_LINTER_OVERRIDE_MAKEMIGRATIONS = True
|
||||
|
||||
PYROSCOPE_PROFILER_ENABLED = getenv_boolean("PYROSCOPE_PROFILER_ENABLED", default=False)
|
||||
if PYROSCOPE_PROFILER_ENABLED:
|
||||
import pyroscope
|
||||
|
||||
pyroscope.configure(
|
||||
application_name=os.getenv("PYROSCOPE_APPLICATION_NAME", "oncall"),
|
||||
server_address=os.getenv("PYROSCOPE_SERVER_ADDRESS", "http://pyroscope:4040"),
|
||||
auth_token=os.getenv("PYROSCOPE_AUTH_TOKEN", ""),
|
||||
detect_subprocesses=True,
|
||||
tags={
|
||||
"celery_worker": os.getenv("CELERY_WORKER_QUEUE", None),
|
||||
},
|
||||
)
|
||||
PYROSCOPE_APPLICATION_NAME = os.getenv("PYROSCOPE_APPLICATION_NAME", "oncall")
|
||||
PYROSCOPE_SERVER_ADDRESS = os.getenv("PYROSCOPE_SERVER_ADDRESS", "http://pyroscope:4040")
|
||||
PYROSCOPE_AUTH_TOKEN = os.getenv("PYROSCOPE_AUTH_TOKEN", "")
|
||||
PYROSCOPE_CELERY_WORKER_QUEUE = os.getenv("CELERY_WORKER_QUEUE", None)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue