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
💬 Recent discussions about this course
- Passer d'une trace Tempo aux logs Loki en un clic✓ solved · 1 reply(ies)
Ask a question about this lesson →See all discussions about this course
Recommended Articles
Sending traces to Tempo: OpenTelemetry instrumentation and Alloy
Produce and route traces to Tempo: Python/Java/Node auto-instrumentation, the manual SDK, OTEL en...
OTLP explained: understanding the OpenTelemetry protocol
The OTLP protocol explained simply. Understand the differences between gRPC and HTTP for exportin...
OpenTelemetry: automatic vs manual instrumentation
Understand the differences between automatic and manual instrumentation with OpenTelemetry, their...
Instrumenting applications for Jaeger with OpenTelemetry
Send traces to Jaeger with OpenTelemetry: auto-instrumentation (Java, Python, Node.js), SDK and m...
Logs with OpenTelemetry: data model, appenders, correlation and collection
Master the log signal: the LogRecord data model, the Logs Bridge API and appenders (Logback, Log4...
Grafana Alloy: Trace Management with Tempo
Dive into distributed trace processing. Learn how to ingest OTLP, Jaeger, or Zipkin traces with G...
Grafana Tempo best practices: instrumentation, sampling, queries and costs
Tempo best practices: attribute conventions, useful instrumentation, sampling, using TraceQL, cor...
Grafana Tempo or Jaeger: which tracing backend to choose?
Detailed comparison of Grafana Tempo and Jaeger: architecture, storage, search, query language, s...
Linking traces and profiles: span profiles with Tempo and Pyroscope
Go from a slow trace to the exact CPU profile of that span: span profiles in Go and Java, configu...