Skip to content

drigocsouza/tracechecklypoc-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TraceChecklyPoC Python

Proof of concept project for instrumenting Python APIs with OpenTelemetry and Checkly.

Table of Contents


About

This API demonstrates distributed tracing and monitoring in Python using OpenTelemetry and integration with Checkly.

Prerequisites

  • Python 3.8+
  • pip
  • Git

Installation

Clone the repository and install the dependencies:

git clone https://github.com/drigocsouza/tracechecklypoc-python.git
cd tracechecklypoc-python
pip install -r requirements.txt

Environment Variables Setup

Never expose sensitive tokens directly in your code!

Create a .env file at the root of the project (do not commit this file) and add:

CHECKLY_OTEL_TOKEN=<your_checkly_token>

Or export it directly in your terminal (Linux/macOS):

export CHECKLY_OTEL_TOKEN=<your_checkly_token>

On Windows (CMD):

set CHECKLY_OTEL_TOKEN=<your_checkly_token>

Add .env to .gitignore to ensure it is not versioned:

.env

Running the API

With the environment variable set, run:

python app.py

The API will be available at http://localhost:8000.

Simulating Trace Problems

The /ping endpoint will randomly:

  • Return a simulated error (HTTP 500) ~30% of the time.
  • Introduce a delay (~2 seconds) ~50% of the time.

This allows you to see both latency and error traces in Checkly.

A /fail endpoint is also available, which always raises an error and can be used to generate error traces intentionally.

OpenTelemetry Instrumentation

  • The code already includes tracer configuration and sends spans to Checkly via OTLP.
  • To change to another backend, update the endpoint and headers in the OTLPSpanExporter section.

Testing

It is recommended to use pytest for automated tests:

pytest

Deployment

Use environments that allow secure configuration of environment variables (Docker, Heroku, cloud servers).

References


Questions or suggestions? Open an issue in this repository!

About

Send traces for Checkly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages