... | ... | @@ -100,5 +100,16 @@ Dashboard requires a Bearer-token to access it for security reasons. To generate |
|
|
|
|
|
#### Instrumentation
|
|
|
|
|
|
Instrumentation means that out application is emitting traces, metrics etc. Jaeger itself doesn't produce the traces, so we need and instrumenting framework. It is [recommended](https://www.jaegertracing.io/docs/1.40/getting-started/#instrumentation) to use [OpenTelemetry](https://opentelemetry.io)(OTel). OTel allows producing and sending of traces to a tracing backend like Jaeger. OTel has support for all of the most popular programming languages.
|
|
|
Instrumentation means that out application is emitting traces, metrics etc. Jaeger itself doesn't produce the traces, so we need and instrumenting framework. It is [recommended](https://www.jaegertracing.io/docs/1.40/getting-started/#instrumentation) to use [OpenTelemetry](https://opentelemetry.io)(OTel). OTel allows producing and sending of traces to a tracing backend like Jaeger. OTel has support for all of the most popular programming languages. Traces in OTel are build from `spans`, which is a unit of work.
|
|
|
|
|
|
#### Setup
|
|
|
To setup Jeager tracing, we should first install libraries specific to language of our code. So for our python backend we install the packages using pip
|
|
|
```bash
|
|
|
pip install opentelemetry-distro
|
|
|
pip install opentelemetry-exporter-jaeger
|
|
|
```
|
|
|
After installing the necessary libraries, we need to make changes to our code. I decided to implement the tracing on the backend service and one route - /api/host. In reality, tracing should be implemented on all relevant services like frontend, nginx and backend but that would be very time consuming.
|
|
|
The adjusted code can be seen [here](https://gitlab.fi.muni.cz/xbrazda/kubernetes-monitoring/-/blob/main/web-backend/app/host.py)
|
|
|
Following [this](https://opentelemetry-python.readthedocs.io/en/latest/exporter/jaeger/jaeger.html) guide, there are two main changes we need to make.
|
|
|
First, we need our code to produce traces. The way to do this in python is using `with` statements, each `with` block will crate a span, whose lifetime will be ended when the code within the block is done executing. We can also start tracing at the begging of a function using the `@` decorator.
|
|
|
After that, we need to setup Jeager exporter to export the traces emitted by our code to the Jaeger backend. Only changes we need to make to the template code are the host name of our k8s Jaeger service and the name of service. |
|
|
\ No newline at end of file |