Using the OpenTelemetry Operator to Inject Auto-Instrumentation

If you run your Python service in Kubernetes, you can take advantage of theOpenTelemetry Operatorto inject auto-instrumentation without having to modify each of your servicesdirectly.See the OpenTelemetry Operator Auto-instrumentation docs for more details.

Python-specific topics

Libraries with binary wheels

Some Python packages we instrument or need in our instrumentation libraries,might ship with some binary code. This is the case, for example, ofgrpcio andpsutil (used inopentelemetry-instrumentation-system-metrics).

The binary code is tied to a specific C library version (glibc or musl) and to aspecific Python version. TheOpenTelemetry Operatorprovides images for a single Python version based on the glibc C library. If youwant to use it you might need to build your own image operator Docker image forPython auto-instrumentation.

Since operator v0.113.0 it is possible to build an image with both glibc andmusl based auto-instrumentation andconfigure it at runtime.

Django applications

Applications that run from their own executable like Django requires to set inyour deployment file two environment variables:

  • PYTHONPATH, with the path to the Django application root directory, e.g.“/app”
  • DJANGO_SETTINGS_MODULE, with the name of the Django settings module, e.g.“myapp.settings”

gevent applications

Since the OpenTelemetry Python 1.37.0/0.58b0 release if you set in yourdeployment file theOTEL_PYTHON_AUTO_INSTRUMENTATION_EXPERIMENTAL_GEVENT_PATCHenvironment variable topatch_all the auto-instrumentation code will call thegevent monkeypatch method with the same name before initializing itself.

Thank you. Your feedback is appreciated!

Please let us knowhow we can improve this page. Your feedback is appreciated!