# OpenTelemetry for Python

The Baselime Python OpenTelemetry SDK enables you to instrument your Python services with OpenTelemetry without the boilerplate of using the OpenTelemetry SDK directly.

This SDK uses OpenTelemetry for Python and provides a layer that facilitates instrumenting your Python applications.


# Instrumentation

# Step 1: Install the SDKs

Install the Baselime Python OpenTelemetry SDK.

terminal
poetry add baselime-opentelemetry

# Step 2: Install Instrumentations

Automatically install instrumentation for the python libraries you use with opentelemetry-bootstrap

terminal
poetry run opentelemetry-bootstrap

# Step 3: Set the Baselime environment variables

Set the environment variables of your comntainer service to include the Baselime API Key

terminal
export BASELIME_API_KEY=<YOUR_API_KEY>
export OTEL_SERVICE_NAME='<NAME_OF_YOUR_APP_OR_SERVICE>'

# Step 4: Run the Opentelemetry Instrumentation

poetry run opentelemetry-instrument python myapp.py

Once these steps are completed, distributed traces from your Python container applications should be available in Baselime to query via the console or the Baselime CLI.


# Configuration

When running your application locally you can set the environment variable EXPORT_CONSOLE=TRUE to print all the telemetry to the console. This can help make sure you have instrumented your application correctly