Skip to content

Commit 8b8bfeb

Browse files
feat(mysql): Metrics for mysql (open-telemetry#1220)
1 parent 72e961c commit 8b8bfeb

File tree

18 files changed

+3553
-11
lines changed

18 files changed

+3553
-11
lines changed

Diff for: plugins/node/opentelemetry-instrumentation-mysql/examples/README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Overview
22

3-
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.
3+
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.
44

55
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.
66

77
- Direct Connection Query
88
- Pool Connection Query
99
- Cluster Pool Connection Query
1010

11+
## supported metrics
12+
13+
- Currently only `db.client.connections.usage` is supported, which denoted the number of idle/used connections.
14+
1115
## Installation
1216

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

26+
In case you want to see also metrics:
27+
28+
1. Go to `docker` folder
29+
2. Run `docker compose up`. This will set up Zipkin, Jaeger, otel collector, Prometheus and Grafana.
30+
3. To see your metrics, go to `http://localhost:3000/`.
31+
2232
## Run the Application
2333

2434
### Zipkin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
receivers:
2+
otlp:
3+
protocols:
4+
grpc:
5+
6+
exporters:
7+
prometheus:
8+
endpoint: "0.0.0.0:8889"
9+
const_labels:
10+
label1: value1
11+
12+
logging:
13+
loglevel: debug
14+
15+
zipkin:
16+
endpoint: "http://zipkin-all-in-one:9411/api/v2/spans"
17+
format: proto
18+
19+
jaeger:
20+
endpoint: jaeger-all-in-one:14250
21+
tls:
22+
insecure: true
23+
24+
processors:
25+
batch:
26+
27+
extensions:
28+
health_check:
29+
pprof:
30+
endpoint: :1888
31+
zpages:
32+
endpoint: :55679
33+
34+
service:
35+
extensions: [pprof, zpages, health_check]
36+
pipelines:
37+
traces:
38+
receivers: [otlp]
39+
processors: [batch]
40+
exporters: [logging]
41+
metrics:
42+
receivers: [otlp]
43+
processors: [batch]
44+
exporters: [logging, prometheus]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
version: "2"
2+
services:
3+
4+
# mysql
5+
mysql:
6+
image: mysql:5.7
7+
command: --init-file /etc/mysql/init.sql
8+
volumes:
9+
- ./mysql/init.sql:/etc/mysql/init.sql
10+
environment:
11+
- MYSQL_ROOT_PASSWORD=secret
12+
ports:
13+
- "3306:3306"
14+
15+
# Jaeger
16+
17+
jaeger-all-in-one:
18+
image: jaegertracing/all-in-one:latest
19+
ports:
20+
- "16686:16686"
21+
- "14268"
22+
- "14250"
23+
24+
# Zipkin
25+
26+
zipkin-all-in-one:
27+
image: openzipkin/zipkin:latest
28+
ports:
29+
- "9411:9411"
30+
31+
# Collector
32+
33+
otel-collector:
34+
image: otel/opentelemetry-collector-contrib:0.61.0
35+
command: ["--config=/etc/otel-collector-config.yaml", ""]
36+
volumes:
37+
- ./collector/otel-collector-config.yaml:/etc/otel-collector-config.yaml
38+
ports:
39+
- "1888:1888" # pprof extension
40+
- "8888:8888" # Prometheus metrics exposed by the collector
41+
- "8889:8889" # Prometheus exporter metrics
42+
- "13133:13133" # health_check extension
43+
- "4317:4317" # OTLP gRPC receiver
44+
- "55679:55679" # zpages extension
45+
depends_on:
46+
- jaeger-all-in-one
47+
- zipkin-all-in-one
48+
49+
# Prometheus
50+
51+
prometheus:
52+
image: quay.io/prometheus/prometheus:v2.34.0
53+
command: --config.file=/etc/prometheus/prometheus.yml --no-scrape.adjust-timestamps
54+
volumes:
55+
- ./prometheus/prometheus.yaml:/etc/prometheus/prometheus.yml
56+
ports:
57+
- "9090:9090"
58+
59+
# Grafana
60+
61+
grafana:
62+
image: grafana/grafana:9.0.1
63+
container_name: grafana
64+
volumes:
65+
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
66+
- ./grafana/provisioning/:/etc/grafana/provisioning/
67+
ports:
68+
- "3000:3000"

0 commit comments

Comments
 (0)