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 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
- Currently only
db.client.connections.usageis supported, which denotes the number of idle/used connections.
# from this directory
npm installSetup Zipkin Tracing
In case you want to see also metrics:
- Go to
dockerfolder - Run
docker compose up. This will set up Zipkin, otel collector, Prometheus and Grafana. - To see your metrics, go to
http://localhost:3000/.
-
Run the server
# from this directory npm run zipkin:server -
Run the client
# from this directory npm run zipkin:client
The zipkin:server script should output the traceid in the terminal (e.g traceid: 4815c3d576d930189725f1f1d1bdfcc6).
Go to Zipkin with your browser http://localhost:9411/zipkin/traces/(your-trace-id) (e.g http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6)
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more information on OpenTelemetry for Node.js, visit: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-sdk-trace-node
Apache License 2.0
