https://github.com/billmeyer/otel-tailsampling
https://github.com/billmeyer/otel-tailsampling
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/billmeyer/otel-tailsampling
- Owner: billmeyer
- Created: 2025-02-21T22:43:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-24T16:17:52.000Z (over 1 year ago)
- Last Synced: 2025-02-24T17:30:03.955Z (over 1 year ago)
- Language: Python
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Testing Tail Sampling with OTel and Python
## One Time Setup
1. Create a Python virtualenv:
```bash
python3 -m venv venv
```
2. Source the new env:
```bash
source venv/bin/activate
```
3. Install dependencies:
```bash
pip3 install -r requirements.txt
```
4. Download a OTel Collector
Download a [Contrib release](https://github.com/open-telemetry/opentelemetry-collector-releases/releases/tag/v0.120.0) of the OTel Collector and extract in the local directory.
## Execution
1. Start the Collector with the supplied config:
```bash
./otelcol-contrib --config config.yaml
```
2. In another terminal, run the python script to generate trace(s):
```bash
source venv/bin/activate
python3 send-traces.py
```
## Description
The python script send two traces-- one from a service named `checkout-worker` and the other named `frontend-worker`, both of which have an attribute named `env` with a value of `prod-eus2`.
The expectation is the following:
* the traces do not match Policy #1 (`env-based-sampling-policy`) because `env` does not match any of the listed values,
* the trace with `service.name` == `frontend-worker` **should** match Policy #2 and the trace should always be sampled resulting in it being sent to an exporter.
* the trace with `service.name` == `checkout-worker` **should** match Policy #3 and the trace should always be sampled resulting in it being sent to an exporter.
## Result
Only the trace for the `frontend-worker` (Policy #2) get sent to the exporter.
## Test cases
Comment out Policy #2 in the collector config, restart and send the trace. The `checkout-worker` trace now gets sampled properly and sent to an exporter.
## Suspicion
It would seem as if a key/value check in *any* policy uses an `invert_match` condition, the key/value pair can't be used in other policies. Note: changing the policy order in the collector config make no difference.