Skip to content

Commit e6851f4

Browse files
authored
Opentelemetry tweaks (#211)
* Update dependencies Signed-off-by: Federico Busetti <[email protected]> * Instrument celery worker Signed-off-by: Federico Busetti <[email protected]> --------- Signed-off-by: Federico Busetti <[email protected]>
1 parent 9292433 commit e6851f4

File tree

5 files changed

+27
-36
lines changed

5 files changed

+27
-36
lines changed

.idea/bootstrap-python-fastapi.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.lock

Lines changed: 13 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ optional = true
4545
[tool.poetry.group.http.dependencies]
4646
fastapi = ">=0.99.0"
4747
jinja2 = "^3.1.2"
48-
opentelemetry-instrumentation-fastapi = "*"
48+
# We use the generic ASGI instrumentation, so that if we decide to change
49+
# Framework it will still work consistently.
50+
opentelemetry-instrumentation-asgi = "*"
4951
starlette-prometheus = "^0.10.0"
5052
strawberry-graphql = { version = ">=0.204.0", extras = ["debug-server"] }
5153
uvicorn = { version = "^0.31.0", extras = ["standard"] }

src/celery_worker/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
without having to initialise the HTTP framework (or other ones)
55
"""
66

7+
from celery.signals import worker_process_init
8+
from opentelemetry.instrumentation.celery import CeleryInstrumentor
9+
710
from bootstrap import AppConfig, application_init
811

12+
13+
@worker_process_init.connect(weak=False)
14+
def init_celery_tracing(*args, **kwargs):
15+
CeleryInstrumentor().instrument() # pragma: nocover
16+
17+
918
app = application_init(AppConfig()).celery_app

0 commit comments

Comments
 (0)