Instrumentation Python avec EDOT

VérifiéSûr

Guide pour instrumenter une application Python avec l'agent Elastic Distribution of OpenTelemetry (EDOT) pour le tracing, les métriques et les logs automatiques.

Spar Skills Guide Bot
DevOpsIntermédiaire
26/07/2026
Claude CodeCursorWindsurfCopilotCodex
#observability#opentelemetry#python#tracing#elastic

Recommandé pour

Synthèse automatique

Instrumente une application Python avec l'agent EDOT (Elastic Distribution of OpenTelemetry) pour collecter automatiquement traces, métriques et logs.

Points forts

  • Procédure minimale et explicite : installation de elastic-opentelemetry, edot-bootstrap --action=install, puis enveloppement du point d'entrée avec opentelemetry-instrument.
  • Liste précisément les trois variables d'environnement obligatoires (OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS).
  • Évite les pièges classiques : ne pas définir les exporteurs, ne pas ajouter de configuration SDK dans le code, ne pas réutiliser une URL APM Server.
  • Rappelle l'incompatibilité avec l'agent classique elastic-apm sur une même application.

Limites

  • Suppose un endpoint OTLP managé ou un EDOT Collector déjà disponible ; le skill ne couvre pas leur mise en place.
  • Ne traite pas l'instrumentation manuelle personnalisée (spans métier, attributs) ni la vérification que la télémétrie arrive bien.
  • Ne donne aucune indication de version ni d'adaptation aux environnements sans Docker ou sans fichier requirements.txt.
Quand l'utiliser

À utiliser pour ajouter une observabilité de base, sans agent APM existant, à un service Python déployé avec Elastic.

Quand l'éviter

À éviter si l'application utilise déjà elastic-apm, si aucun endpoint OTLP/EDOT Collector n'est disponible, ou s'il faut instrumenter manuellement du code métier.

Analyse de sécurité

Sûr
Score qualité88/100

The skill is purely instructional and does not execute any commands or use any tools. It provides configuration guidance for adding OpenTelemetry instrumentation to Python applications, including installing packages and setting environment variables, but does not perform destructive actions, exfiltrate data, or disable safety features.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Instrument a Flask service
Add EDOT OpenTelemetry instrumentation to my Python service in this Flask app (app.py served by gunicorn): install elastic-opentelemetry, install the auto-instrumentation packages, wrap the start command with opentelemetry-instrument, and set OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS.
Update Dockerfile for EDOT
Our Dockerfile builds a FastAPI app with pip requirements.txt. Update it so the image runs edot-bootstrap --action=install at build time and starts with opentelemetry-instrument uvicorn main:app, without adding any TracerProvider code in the app.
Fix wrong OTLP endpoint
My Python app has OTEL_EXPORTER_OTLP_ENDPOINT set to our APM Server URL on port 8200 and no telemetry shows up. Review my OpenTelemetry env vars and correct the setup for EDOT, including the Authorization header format.

name: observability-edot-python-instrument description: > Instrument a Python application with the Elastic Distribution of OpenTelemetry (EDOT) Python agent for automatic tracing, metrics, and logs. Use when adding observability to a Python service that has no existing APM agent. metadata: author: elastic version: 0.1.0

EDOT Python Instrumentation

Read the setup guide before making changes:

Guidelines

  1. Install elastic-opentelemetry via pip (add to requirements.txt or equivalent)
  2. Run edot-bootstrap --action=install during image build to install auto-instrumentation packages for detected libraries
  3. Wrap the application entrypoint with opentelemetry-instrument — e.g. opentelemetry-instrument gunicorn app:app or opentelemetry-instrument python app.py. Without this, no telemetry is collected
  4. Set exactly three required environment variables:
    • OTEL_SERVICE_NAME
    • OTEL_EXPORTER_OTLP_ENDPOINT — must be the managed OTLP endpoint or EDOT Collector URL. Never use an APM Server URL (no apm-server, no :8200, no /intake/v2/events)
    • OTEL_EXPORTER_OTLP_HEADERS — "Authorization=ApiKey <key>" or "Authorization=Bearer <token>"
  5. Do NOT set OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, or OTEL_LOGS_EXPORTER — the defaults are already correct
  6. Do NOT add code-level SDK setup (no TracerProvider, no configure_azure_monitor, etc.) — opentelemetry-instrument handles everything
  7. Never run both classic elastic-apm and EDOT on the same application

Examples

See the EDOT Python setup guide for complete examples.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/python-instrumentation-with-edot-ms1cu0a4/download' --output '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md.part' && mv '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md.part' '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && test -s '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/observability-edot-python-instrument' && cp -R '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4' '.claude/skills/observability-edot-python-instrument'

Cursor
test -f '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && test -s '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/observability-edot-python-instrument' && cp -R '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4' '.cursor/skills/observability-edot-python-instrument'

Codex
test -f '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && test -s '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/observability-edot-python-instrument' && cp -R '.skill-downloads/python-instrumentation-with-edot-ms1cu0a4' '.agents/skills/observability-edot-python-instrument'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/python-instrumentation-with-edot-ms1cu0a4'

openskills read 'python-instrumentation-with-edot-ms1cu0a4'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/python-instrumentation-with-edot-ms1cu0a4/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires