Python 自动埋点

Python 自动埋点为 Python 应用提供自动 telemetry 采集,包括 Django、Flask、FastAPI 等常见框架,以及许多其他框架。此埋点无需修改代码即可从 Python 应用中采集 traces、metrics 和 logs。

Operator 会将 OpenTelemetry Python 自动埋点注入到 Python 应用容器中,并配置其在启动时自动为常用库和框架进行埋点。这使得在 Kubernetes 中运行的 Python 工作负载具备全面的可观测性。

启用 Python 埋点

要为 Python 应用启用自动埋点,请为你的 pod 或 namespace 添加注解:

apiVersion: v1
kind: Pod
metadata:
  name: python-app
  annotations:
    instrumentation.opentelemetry.io/inject-python: "true"
spec:
  containers:
  - name: app
    image: mypythonapp:latest

Operator 会自动注入埋点组件,并配置 Python runtime 在启动时加载它们。

配置参考

有关详细的配置选项、受支持的库以及高级使用场景,请参阅官方 OpenTelemetry Operator 文档:

Python 自动埋点文档