┌─────────────┐ ┌─────────────┐
│ │ HTTP 1.1 │ │
│ Client │───────/hello───────▶│ Webapp │
│ │ │ │
└─────────────┘ └─────────────┘
This Python applications utilizes tracing with a minimal reliance on external libraries, emphasizing core functionality without the need for web frameworks or non-standard library resources, demonstrating how to instrument an application from scratch (OTEL). It also includes Kubernetes manifests for easy deployment.
Test your OLTP collector by simply using kubectl apply with your clusters.
- Tracing
- [-] Metrics
- [-] Logs
- Python
3.8
- OTEL Collector
0.95.0
Before you begin, ensure that you have the following:
- A Kubernetes cluster up and running
kubectl
command-line tool installed and configured to connect to your clustercurl
command-line tool installed
The first step is to set the environment variable OTEL_EXPORTER_OTLP_ENDPOINT
to specify the endpoint where the traces will be sent. In this example, we'll set it to http://observe-traces.observe.svc.cluster.local:4317
.
export OTEL_EXPORTER_OTLP_ENDPOINT="http://observe-traces.observe.svc.cluster.local:4317"
Next, we'll deploy the client component of the Python application. The Kubernetes manifest file for the client component is hosted on GitHub in the p404/python-otel-example
repository.
curl -s https://raw.githubusercontent.com/p404/python-otel-example/main/.kustomize/client.yaml | envsubst | kubectl apply -f -
This command does the following:
- It downloads the
client.yaml
manifest file usingcurl
. - The
envsubst
command substitutes theOTEL_EXPORTER_OTLP_ENDPOINT
environment variable in the manifest file. - The resulting manifest is then applied to the Kubernetes cluster using
kubectl apply -f -
.
Similar to the client component, we'll deploy the webapp component of the Python application. The Kubernetes manifest file for the webapp component is also hosted on GitHub in the same repository.
curl -s https://raw.githubusercontent.com/p404/python-otel-example/main/.kustomize/webapp.yaml | envsubst | kubectl apply -f -
This command follows the same steps as the previous one, but it downloads and applies the webapp.yaml
manifest file.
export OTEL_EXPORTER_OTLP_ENDPOINT="http://observe-traces.observe.svc.cluster.local:4317" && \
curl -s https://raw.githubusercontent.com/p404/python-otel-example/main/.kustomize/client.yaml | envsubst | kubectl apply -f - && \
curl -s https://raw.githubusercontent.com/p404/python-otel-example/main/.kustomize/webapp.yaml | envsubst | kubectl apply -f -