Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/docker-otel-lgtm
Path: blob/main/examples/python/run.sh
401 views
1
#!/bin/bash
2
3
set -euo pipefail
4
5
export OTEL_METRIC_EXPORT_INTERVAL="5000" # so we don't have to wait 60s for metrics
6
export OTEL_RESOURCE_ATTRIBUTES="service.name=rolldice,service.instance.id=localhost:8082"
7
8
python3 -m venv venv
9
source ./venv/bin/activate
10
11
# How to get the requirements.txt file?
12
# 1. Follow https://opentelemetry.io/docs/languages/python/getting-started/
13
# 2. Run `pip freeze > requirements.txt` in the same directory as your app.py file
14
pip install -r requirements.txt
15
16
# Step 1: Install the OpenTelemetry SDK
17
pip install 'opentelemetry-distro[otlp]==0.46b0'
18
opentelemetry-bootstrap -a install
19
20
# Step 2: Run the application
21
export OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
22
export OTEL_LOGS_EXPORTER=otlp
23
opentelemetry-instrument flask run -p 8082
24
25