What you will learn in this TP
- Auto-instrument an API
- Add a manual span
- Find the trace
The application #
What you will learn in this section
- Auto-instrument an API
- Add a manual span
- Find the trace
Context. A small Python API does not emit any traces yet. You instrument it with OpenTelemetry without rewriting its logic, then add a business span to measure a specific step (discount calculation).
Prerequisites: Previous lab (Tempo), Python 3 · Estimated time: 40 min
An API that calls a second API.1. Create the application
Why? A minimal application is enough to practise; what matters is seeing how instrumentation is added without changing the routes.
Write a Flask application with a/commanderoute that waits 100 ms.2. Auto-instrument
Why? Auto-instrumentation automatically creates spans for HTTP requests: it is the fastest way to get initial visibility.
Install the OpenTelemetry packages and run the application with the agent.3. Add a manual span
Why? Manual spans provide the business context that auto-instrumentation cannot guess (discount, customer type).
Add acalcul_remisespan with aremise.pourcentattribute.4. Find the trace
Why? Filtering by name and duration shows how to isolate a slow operation among thousands of traces.
Search for traces whosecalcul_remisespan lasts more than 50 ms.
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
Recommended Articles
Envoyer des traces vers Tempo : instrumentation OpenTelemetry et Alloy
Produire et acheminer des traces vers Tempo : auto-instrumentation Python/Java/Node, SDK manuel, ...
OTLP expliqué : comprendre le protocole OpenTelemetry
Découvrez le protocole OTLP expliqué simplement. Comprendre les différences entre gRPC et HTTP po...
Understanding the concept of score
The concept of score allows Elasticsearch to rank your documents by relevance during a search.
Understanding the Elastic Common Schema (ECS)
As always in our consulting engagements, we recommend that companies harmonise and standardise: k...
License consumption types
Understand the evolution of billing in Dynatrace: the difference between the old licensing model ...
Grafana Alloy: The importance of Self-Monitoring
Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...
Grafana Alloy: Understanding and exploiting the User Interface (UI)
Discover how to enable, secure, and use Grafana Alloy's built-in web interface to visualize your ...
Grafana Alloy: Introduction and Architecture
Discover the fundamental concepts of Grafana Alloy, the transition from the static Agent to Alloy...
Grafana Alloy: Syntax and Configuration (Alloy Language: River)
As part of a Grafana training or observability training, master the declarative syntax of Grafana...