Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mysql): Metrics for mysql #1220

Merged
merged 81 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
569d21c
feat(mysql): started working on mysql metrics
haddasbronfman Oct 7, 2022
1b32eb3
Merge branch 'main' into add-mysql-metrics
haddasbronfman Oct 7, 2022
477fa6c
feat(mysql): remove redundant code
haddasbronfman Oct 7, 2022
b12de48
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Oct 7, 2022
c7ce388
feat(mysql): fix lint errors
haddasbronfman Oct 7, 2022
6bb21eb
Merge branch 'main' into add-mysql-metrics
haddasbronfman Oct 27, 2022
f41ed40
feat(mysql): try to run only metrics test
haddasbronfman Oct 27, 2022
f96fb10
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Oct 27, 2022
97ff8f9
feat(mysql): add createConnection
haddasbronfman Oct 27, 2022
7301a11
feat(mysql): metricsTake2
haddasbronfman Oct 27, 2022
8cf707a
feat(mysql): lint
haddasbronfman Oct 27, 2022
d2a3233
feat(mysql): metrics take2
haddasbronfman Oct 27, 2022
2ef8241
feat(mysql): rename take2.test.ts test
haddasbronfman Oct 27, 2022
5138cf8
feat(mysql): disable all github actions except lint & unit-test
haddasbronfman Oct 27, 2022
516a1fe
feat(mysql): remove poolCluster. add 1 metrics test
haddasbronfman Oct 27, 2022
181345f
feat(mysql): lint
haddasbronfman Oct 27, 2022
bb206c0
feat(mysql): remove parallel option
haddasbronfman Oct 30, 2022
80a2790
Merge branch 'main' into add-mysql-metrics
haddasbronfman Oct 30, 2022
0876d9a
feat(mysql): keep only unit-test action & change test to 4 exportedMe…
haddasbronfman Oct 30, 2022
7419210
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Oct 30, 2022
bb768cd
feat(mysql): bug fix in metrics test
haddasbronfman Oct 30, 2022
30ac5c4
feat(mysql): bug fix in metrics test - datapoint
haddasbronfman Oct 30, 2022
5e9b4e3
Merge branch 'main' into add-mysql-metrics
haddasbronfman Oct 30, 2022
691df84
feat(mysql): uncomment all github workflows
haddasbronfman Oct 30, 2022
ae7e012
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Oct 30, 2022
751f89a
feat(mysql): revert changes
haddasbronfman Oct 30, 2022
0e830c1
feat(mysql): lint
haddasbronfman Oct 30, 2022
cfe629f
feat(mysql): fix to 2 exportedMetrics
haddasbronfman Oct 30, 2022
545ae3f
Merge branch 'main' into add-mysql-metrics
dyladan Oct 31, 2022
58e8bdc
feat(mysql): fix according to specifications
haddasbronfman Nov 6, 2022
94da4bf
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Nov 6, 2022
d930017
feat(mysql): fix 'state' field according to specifications
haddasbronfman Nov 8, 2022
3f077a6
feat(mysql): move sdk-metrics to devDependencies
haddasbronfman Nov 8, 2022
06d2e3d
feat(mysql): lint
haddasbronfman Nov 8, 2022
8d168c7
Merge branch 'main' into add-mysql-metrics
haddasbronfman Nov 8, 2022
eb7f5a3
Merge branch 'main' into add-mysql-metrics
haddasbronfman Nov 9, 2022
2f86369
feat(metrics): add metrics example & a function to print the current …
haddasbronfman Nov 14, 2022
1e9d446
Merge branch 'main' into add-mysql-metrics
haddasbronfman Nov 14, 2022
6746ccc
feat(metrics): remove the function that prints the current metrics
haddasbronfman Nov 14, 2022
dcb1502
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Nov 14, 2022
e0a5e05
feat(metrics): remove redundant imports
haddasbronfman Nov 14, 2022
729d8ec
Merge branch 'main' into add-mysql-metrics
haddasbronfman Nov 16, 2022
345da4f
Merge branch 'main' into add-mysql-metrics
haddasbronfman Nov 17, 2022
3b5513a
feat(metrics): add example code for 2 connections in the same pool
haddasbronfman Nov 17, 2022
aa18802
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Nov 17, 2022
3a3edd4
feat(metrics): lint
haddasbronfman Nov 17, 2022
dd9b707
feat(metrics): add docker-compose to set up grafana, prometheus, otel…
haddasbronfman Nov 20, 2022
2f397ee
feat(metrics): add readme instructions about the docker compose
haddasbronfman Nov 20, 2022
4c5864c
fix(mysql): add name attribute + examples with 2 pools
haddasbronfman Dec 2, 2022
537c91b
Merge branch 'main' into add-mysql-metrics
haddasbronfman Dec 2, 2022
b7a913f
fix(mysql): lint
haddasbronfman Dec 3, 2022
fe65af1
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Dec 3, 2022
3b07481
fix(mysql): add test for 'name' attribute
haddasbronfman Dec 3, 2022
754af63
fix(mysql): fix 'name' test
haddasbronfman Dec 3, 2022
8c02d3b
fix(mysql): add tests for poolCluster
haddasbronfman Dec 5, 2022
9dfc5c8
fix(mysql): lint
haddasbronfman Dec 5, 2022
5902fed
fix(mysql): lint
haddasbronfman Dec 5, 2022
510da98
fix(mysql): fix tests
haddasbronfman Dec 12, 2022
cb17540
Merge branch 'main' into add-mysql-metrics
haddasbronfman Dec 12, 2022
8481d9d
fix(mysql): remove comments
haddasbronfman Dec 12, 2022
403a22d
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Dec 12, 2022
29e21c8
fix(mysql): move getPoolName to utils file + add tests
haddasbronfman Dec 13, 2022
dc65f35
fix(mysql): fix dependencies
haddasbronfman Dec 13, 2022
f5071f2
fix(mysql): add test that uses pool.query
haddasbronfman Dec 14, 2022
19e3075
fix(mysql): lint
haddasbronfman Dec 14, 2022
7058372
fix(mysql): patch pool.end function, add test for 2 connections
haddasbronfman Dec 15, 2022
464c230
Merge branch 'main' into add-mysql-metrics
haddasbronfman Dec 15, 2022
3b78a86
fix(mysql): improve loop
haddasbronfman Dec 15, 2022
6897dcb
Merge branch 'add-mysql-metrics' of github.com:haddasbronfman/opentel…
haddasbronfman Dec 15, 2022
f9ce208
Merge branch 'main' into add-mysql-metrics
haddasbronfman Dec 20, 2022
4d5490f
fix(mysql): change pool.anme according to new spec
haddasbronfman Dec 21, 2022
4131d16
Merge branch 'main' into add-mysql-metrics
haddasbronfman Dec 21, 2022
17c4e6a
fix(mysql): lint
haddasbronfman Dec 21, 2022
26fd2ff
fix(mysql): lint
haddasbronfman Dec 21, 2022
a02cb89
fix(mysql): fix tests
haddasbronfman Dec 21, 2022
51e6c82
fix(mysql): handle the case where PoolCluster.add is called without id
haddasbronfman Dec 27, 2022
24db720
fix(mysql): remove redundant log
haddasbronfman Dec 28, 2022
c60a919
fix(mysql): fix readme
haddasbronfman Jan 1, 2023
5b01dbb
Merge branch 'main' into add-mysql-metrics
haddasbronfman Jan 1, 2023
2ce42ee
fix(mysql): lint
haddasbronfman Jan 1, 2023
529d784
Merge branch 'main' into add-mysql-metrics
haddasbronfman Jan 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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