Skip to content

Commit

Permalink
feat(mysql): Metrics for mysql (open-telemetry#1220)
Browse files Browse the repository at this point in the history
  • Loading branch information
haddasbronfman authored Jan 4, 2023
1 parent 72e961c commit 8b8bfeb
Show file tree
Hide file tree
Showing 18 changed files with 3,553 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Overview

OpenTelemetry MySQL Instrumentation allows the user to automatically collect trace data and export them to the backend of choice (we can use Zipkin or Jaeger for this example), to give observability to distributed systems.
OpenTelemetry MySQL Instrumentation allows the user to automatically collect trace data and metrics and export them to the backend of choice (we can use Zipkin, Jaeger or Grafana for this example), to give observability to distributed systems.

This is a modification of the HTTP example that executes multiple parallel requests that interact with a MySQL server backend using the `mysql` npm module. The example displays traces using multiple connection methods.

- Direct Connection Query
- Pool Connection Query
- Cluster Pool Connection Query

## supported metrics

- Currently only `db.client.connections.usage` is supported, which denoted the number of idle/used connections.

## Installation

```sh
Expand All @@ -19,6 +23,12 @@ Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html)
or
Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one)

In case you want to see also metrics:

1. Go to `docker` folder
2. Run `docker compose up`. This will set up Zipkin, Jaeger, otel collector, Prometheus and Grafana.
3. To see your metrics, go to `http://localhost:3000/`.

## Run the Application

### Zipkin
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
receivers:
otlp:
protocols:
grpc:

exporters:
prometheus:
endpoint: "0.0.0.0:8889"
const_labels:
label1: value1

logging:
loglevel: debug

zipkin:
endpoint: "http://zipkin-all-in-one:9411/api/v2/spans"
format: proto

jaeger:
endpoint: jaeger-all-in-one:14250
tls:
insecure: true

processors:
batch:

extensions:
health_check:
pprof:
endpoint: :1888
zpages:
endpoint: :55679

service:
extensions: [pprof, zpages, health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging, prometheus]
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: "2"
services:

# mysql
mysql:
image: mysql:5.7
command: --init-file /etc/mysql/init.sql
volumes:
- ./mysql/init.sql:/etc/mysql/init.sql
environment:
- MYSQL_ROOT_PASSWORD=secret
ports:
- "3306:3306"

# Jaeger

jaeger-all-in-one:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268"
- "14250"

# Zipkin

zipkin-all-in-one:
image: openzipkin/zipkin:latest
ports:
- "9411:9411"

# Collector

otel-collector:
image: otel/opentelemetry-collector-contrib:0.61.0
command: ["--config=/etc/otel-collector-config.yaml", ""]
volumes:
- ./collector/otel-collector-config.yaml:/etc/otel-collector-config.yaml
ports:
- "1888:1888" # pprof extension
- "8888:8888" # Prometheus metrics exposed by the collector
- "8889:8889" # Prometheus exporter metrics
- "13133:13133" # health_check extension
- "4317:4317" # OTLP gRPC receiver
- "55679:55679" # zpages extension
depends_on:
- jaeger-all-in-one
- zipkin-all-in-one

# Prometheus

prometheus:
image: quay.io/prometheus/prometheus:v2.34.0
command: --config.file=/etc/prometheus/prometheus.yml --no-scrape.adjust-timestamps
volumes:
- ./prometheus/prometheus.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"

# Grafana

grafana:
image: grafana/grafana:9.0.1
container_name: grafana
volumes:
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
- ./grafana/provisioning/:/etc/grafana/provisioning/
ports:
- "3000:3000"
Loading

0 comments on commit 8b8bfeb

Please sign in to comment.