Skip to content

Commit d11efb3

Browse files
authored
chore(examples/mysql): modernize this example (#2465)
- drop Jaeger from examples (given open-telemetry/opentelemetry-specification#3551) - update otel-collector-contib version and switch from logging to debug exporter (lifted from #2441) - various other small fixes to get the README steps basically working Refs: #2441
1 parent d08d50d commit d11efb3

File tree

6 files changed

+10
-56
lines changed

6 files changed

+10
-56
lines changed

examples/mysql/README.md

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview
22

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

@@ -20,13 +20,11 @@ npm install
2020
```
2121

2222
Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html)
23-
or
24-
Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one)
2523

2624
In case you want to see also metrics:
2725

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

3230
## Run the Application
@@ -54,29 +52,6 @@ Go to Zipkin with your browser <http://localhost:9411/zipkin/traces/(your-trace-
5452

5553
<p align="center"><img alt="Zipkin UI with trace" src="./images/zipkin-ui.png?raw=true"/></p>
5654

57-
### Jaeger
58-
59-
- Run the server
60-
61-
```sh
62-
# from this directory
63-
npm run jaeger:server
64-
```
65-
66-
- Run the client
67-
68-
```sh
69-
# from this directory
70-
npm run jaeger:client
71-
```
72-
73-
#### Jaeger UI
74-
75-
The `jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
76-
Go to Jaeger with your browser <http://localhost:16686/trace/(your-trace-id)> (e.g <http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6>)
77-
78-
<p align="center"><img alt="Jaeger UI with trace" src="images/jaeger-ui.png?raw=true"/></p>
79-
8055
## Useful links
8156

8257
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>

examples/mysql/docker/collector/otel-collector-config.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@ exporters:
99
const_labels:
1010
label1: value1
1111

12-
logging:
13-
loglevel: debug
12+
debug:
13+
verbosity: detailed
1414

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

19-
jaeger:
20-
endpoint: jaeger-all-in-one:14250
21-
tls:
22-
insecure: true
23-
2419
processors:
2520
batch:
2621

@@ -37,8 +32,8 @@ service:
3732
traces:
3833
receivers: [otlp]
3934
processors: [batch]
40-
exporters: [logging]
35+
exporters: [debug]
4136
metrics:
4237
receivers: [otlp]
4338
processors: [batch]
44-
exporters: [logging, prometheus]
39+
exporters: [debug, prometheus]

examples/mysql/docker/docker-compose.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version: "2"
21
services:
32

43
# mysql
54
mysql:
65
image: mysql:5.7
6+
platform: linux/amd64
77
command: --init-file /etc/mysql/init.sql
88
volumes:
99
- ./mysql/init.sql:/etc/mysql/init.sql
@@ -12,15 +12,6 @@ services:
1212
ports:
1313
- "3306:3306"
1414

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-
2415
# Zipkin
2516

2617
zipkin-all-in-one:
@@ -31,7 +22,7 @@ services:
3122
# Collector
3223

3324
otel-collector:
34-
image: otel/opentelemetry-collector-contrib:0.61.0
25+
image: otel/opentelemetry-collector-contrib:0.111.0
3526
command: ["--config=/etc/otel-collector-config.yaml", ""]
3627
volumes:
3728
- ./collector/otel-collector-config.yaml:/etc/otel-collector-config.yaml
@@ -43,7 +34,6 @@ services:
4334
- "4317:4317" # OTLP gRPC receiver
4435
- "55679:55679" # zpages extension
4536
depends_on:
46-
- jaeger-all-in-one
4737
- zipkin-all-in-one
4838

4939
# Prometheus

examples/mysql/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"docker:stop": "docker stop example-mysql && docker rm example-mysql",
1010
"zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts",
1111
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
12-
"jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts",
13-
"jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts",
1412
"compile": "tsc -p ."
1513
},
1614
"repository": {
@@ -32,15 +30,15 @@
3230
},
3331
"dependencies": {
3432
"@opentelemetry/api": "^1.0.0",
35-
"@opentelemetry/exporter-jaeger": "^1.0.0",
33+
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.48.0",
3634
"@opentelemetry/exporter-zipkin": "^1.0.0",
3735
"@opentelemetry/instrumentation": "^0.48.0",
3836
"@opentelemetry/instrumentation-http": "^0.48.0",
3937
"@opentelemetry/instrumentation-mysql": "^0.31.0",
4038
"@opentelemetry/sdk-trace-base": "^1.0.0",
4139
"@opentelemetry/sdk-trace-node": "^1.0.0",
4240
"@opentelemetry/semantic-conventions": "^1.27.0",
43-
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.48.0",
41+
"@types/node": "^18.18.14",
4442
"mysql": "^2.18.1"
4543
},
4644
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/mysql#readme",

examples/mysql/src/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function handleRequest(request: any, response: any) {
5252
// display traceid in the terminal
5353
const traceId = currentSpan?.spanContext().traceId;
5454
console.log(`traceid: ${traceId}`);
55-
console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
5655
console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
5756
try {
5857
const body = [];

examples/mysql/src/tracer.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import opentelemetry from '@opentelemetry/api';
44
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
55
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
6-
import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
76
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
87
import { registerInstrumentations } from '@opentelemetry/instrumentation';
98
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
@@ -38,8 +37,6 @@ export const setupTracing = (serviceName: string) => {
3837

3938
if (EXPORTER.toLowerCase().startsWith('z')) {
4039
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter()));
41-
} else {
42-
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new JaegerExporter()));
4340
}
4441

4542
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings

0 commit comments

Comments
 (0)