Skip to main content
This guide demonstrates how to use OpenTelemetry SDK to instrument Python code and send traces to TrueFoundry’s OtelCollector. In this example, we’ll show how to instrument a simple Python application with nested function calls using OpenTelemetry’s context managers.
1

Create Tracing Project, API Key and copy tracing code

Follow the instructions in Getting Started to create a tracing project, generate API key and copy the tracing code.
2

Install Dependencies

First, you need to install the following packages:
3

Add tracing code to Python application

To enable tracing, you’ll need to configure opentelemetry sdk and intialize it. This section shows how to instrument your Python code using OpenTelemetry’s context managers. The example demonstrates nested function calls with proper tracing.
4

Run your application and view logged trace