Enable tracing

This guide contains the steps to enable tracing with Grafana Tempo for your MySQL application.

Prerequisites


Deploy Tempo

First, switch to the Kubernetes controller where the COS model is deployed:

juju switch <k8s_controller_name>:<cos_model_name>

Then, deploy the dependencies of Tempo following this tutorial .

To summarize:

  • Deploy the MinIO charm

  • Deploy the s3 integrator charm

  • Add a bucket in MinIO using a python script

  • Configure s3 integrator with the MinIO credentials

Finally, deploy and integrate with Tempo HA in a monolithic setup .

Offer interfaces

Next, offer interfaces for cross-model integrations from the model where Charmed MySQL is deployed.

To offer the Tempo integration, run

juju offer <tempo_coordinator_k8s_application_name>:tracing

Then, switch to the Charmed MySQL VM model, find the offers, and integrate (relate) with them:

juju switch <mysql_controller_name>:<mysql_model_name>

juju find-offers <k8s_controller_name>:  

Do not miss the “:” in the command above!

Below is a sample output where k8s is the K8s controller name and cos is the model where cos-lite and tempo-k8s are deployed:

Store  URL                            Access  Interfaces
k8s    admin/cos.tempo                admin   tracing:tracing

Next, consume this offer so that it is reachable from the current model:

juju consume k8s:admin/cos.tempo

Consume interfaces

First, deploy opentelemetry-collector / opentelemetry-collector-k8s charm:

juju deploy opentelemetry-collector --channel 2/stable
juju deploy opentelemetry-collector-k8s --channel 2/stable --trust

Then, integrate OpenTelemetry Collector with Charmed MySQL:

juju integrate opentelemetry-collector:cos-agent mysql:cos-agent
juju integrate opentelemetry-collector-k8s:receive-traces mysql-k8s:tracing 

Finally, integrate OpenTelemetry Collector with the consumed interface from the previous section:

juju integrate opentelemetry-collector:send-traces tempo:tracing
juju integrate opentelemetry-collector-k8s:send-traces tempo:tracing

Wait until the model settles. The following is an example of the juju status --relations on the Charmed MySQL model:

Model     Controller  Cloud/Region         Version  SLA          Timestamp
mysql     lxd         localhost/localhost  3.6.14   unsupported  19:15:55Z

SAAS   Status  Store       URL
tempo  active  k8s         admin/cos.tempo

App                      Version  Status   Scale  Charm                    Channel      Rev  Exposed  Message
mysql                    8.4.7    active       1  mysql                    8.4/edge          no
opentelemetry-collector           blocked      1  opentelemetry-collector  2/stable     316  no

Unit                          Workload  Agent  Machine  Public address  Ports           Message
mysql/0*                      active    idle   0        10.205.193.32   3306,33060/tcp  Primary
  opentelemetry-collector/0*  blocked   idle            10.205.193.32

Machine  State    Address        Inst id        Base          AZ  Message
0        started  10.205.193.32  juju-4f3e50-0  ubuntu@26.04      Running

Integration provider           Requirer                             Interface        Type         Message
opentelemetry-collector:peers  opentelemetry-collector:peers        otelcol_replica  peer
mysql:cos-agent                opentelemetry-collector:cos-agent    tracing          subordinate
mysql:database-peers           mysql:database-peers                 mysql_peers      peer
mysql:refresh-v-three          mysql:refresh-v-three                refresh          peer
mysql:rolling-ops              mysql:rolling-ops                    rolling_op       peer
tempo:tracing                  opentelemetry-collector:send-traces  tracing          regular
Model     Controller  Cloud/Region        Version  SLA          Timestamp
mysql     k8s         microk8s/localhost  3.6.14   unsupported  16:33:26Z

SAAS   Status  Store       URL
tempo  active  k8s         admin/cos.tempo

App                          Version  Status  Scale  Charm                        Channel   Rev  Address         Exposed  Message
mysql-k8s                    8.4.7    active      1  mysql-k8s                    8.4/edge       10.152.183.135  no       Primary
opentelemetry-collector-k8s           active      1  opentelemetry-collector-k8s  2/stable  207  10.152.183.136

Unit                            Workload  Agent      Address       Ports  Message
mysql-k8s/0*                    active    executing  10.1.241.253         Primary
opentelemetry-collector-k8s/0*  active    idle       10.1.241.254

Integration provider               Requirer                                    Interface        Type     Message
opentelemetry-collector-k8s:peers  opentelemetry-collector-k8s:peers           otelcol_replica  peer
mysql-k8s:tracing                  opentelemetry-collector-k8s:receive-traces  tracing          regular
mysql-k8s:database-peers           mysql-k8s:database-peers                    mysql_peers      peer
mysql-k8s:refresh-v-three          mysql-k8s:refresh-v-three                   refresh          peer
mysql-k8s:rolling-ops              mysql-k8s:rolling-ops                       rolling_op       peer
tempo:tracing                      opentelemetry-collector-k8s:send-traces     tracing          regular

Note

All traces are exported to Tempo using HTTP. Support for sending traces via HTTPS is an upcoming feature.

View traces

The Tempo traces will be accessible from Grafana under the Explore section with tempo-k8s as the data source. You will be able to select mysql as the Service Name under the Search tab to view traces belonging to Charmed MySQL.

Screenshot

MySQL trace with Grafana Tempo

Feel free to read through the Tempo HA documentation at your leisure to explore its deployment and its integrations.