Tips for integrating OpenTelemetry when using mod_wsgi

7 views
Skip to first unread message

Andras Csizmadia

unread,
Sep 22, 2023, 3:55:23 PM9/22/23
to modwsgi
Hi!

I'm currently evaluating the possibility to integrate the OpenTelemetry framework into our existing Flask applications which are served at the moment using Apache2+mod_wsgi for trace and metrics collection.

Does anyone have experience with this topic?

Especially I'm hesitant about how does the OpenTelemetry tracing and metrics SDK behave with the multi process / multi thread model of mod_wsgi and Apache2 with the mpm_event module.

The OpenTelemetry documentation have some reference about it needs special configuration when using the fork process model:
Since I'm using the worker process model I'm a bit unsure about that should I need to use some kind of post-init hook to create my span/metrics processors?
Does mod_wsgi provide this kind of event hook?

I'll try to gather information from the OpenTelemetry groups as well but I wanted to try the other way too.

Thank you!

Graham Dumpleton

unread,
Sep 22, 2023, 3:59:45 PM9/22/23
to mod...@googlegroups.com
When using mod_wsgi there is no fork of the process after you have loaded any Python code. Each process is initialised from scratch as a separate Python process and each loads Python code itself.

So you don't have to worry about in process forking issues, only that there are multiple process/thread reporting.

BTW, make sure you are using daemon mode, and disable ability for Python to be initialised in embedded mode for good measure.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/b6f0646d-3370-4513-a997-a2ee8d7cb8c2n%40googlegroups.com.

Andras Csizmadia

unread,
Sep 23, 2023, 9:05:48 AM9/23/23
to modwsgi
Thanks for the response!

I think in this case OTEL traces will work out of the box, I'll just have to deal with aggregation of the different per process metrics values.

Best regards,
Andrew

Reply all
Reply to author
Forward
0 new messages