Skip to content

Commit ca67d83

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-js-contrib into db-error
2 parents fca2db1 + b043ffb commit ca67d83

File tree

47 files changed

+370
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+370
-264
lines changed

detectors/node/opentelemetry-resource-detector-container/src/detectors/ContainerDetector.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ContainerDetector implements DetectorSync {
3535
readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo';
3636
readonly UTF8_UNICODE = 'utf8';
3737
readonly HOSTNAME = 'hostname';
38-
readonly MARKING_PREFIX = 'containers';
38+
readonly MARKING_PREFIX = ['containers', 'overlay-containers'];
3939
readonly CRIO = 'crio-';
4040
readonly CRI_CONTAINERD = 'cri-containerd-';
4141
readonly DOCKER = 'docker-';
@@ -105,7 +105,7 @@ export class ContainerDetector implements DetectorSync {
105105
const strArray = str?.split('/') ?? [];
106106
for (let i = 0; i < strArray.length - 1; i++) {
107107
if (
108-
strArray[i] === this.MARKING_PREFIX &&
108+
this.MARKING_PREFIX.includes(strArray[i]) &&
109109
strArray[i + 1]?.length === this.CONTAINER_ID_LENGTH
110110
) {
111111
return strArray[i + 1];

detectors/node/opentelemetry-resource-detector-container/src/detectors/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup';
1818
export const DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo';
1919
export const UTF8_UNICODE = 'utf8';
2020
export const HOSTNAME = 'hostname';
21-
export const MARKING_PREFIX = 'containers';
21+
export const MARKING_PREFIX = ['containers', 'overlay-containers'];
2222
export const CRIO = 'crio-';
2323
export const CRI_CONTAINERD = 'cri-containerd-';
2424
export const DOCKER = 'docker-';

detectors/node/opentelemetry-resource-detector-container/test/ContainerDetector.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ describe('ContainerDetector', () => {
3232
const correctCgroupV2Data = `containers/tmhdefghijklmnopqrstuvwxyzafgrefghiugkmnopqrstuvwxyzabcdefghijkl/hostname
3333
fhkjdshgfhsdfjhdsfkjhfkdshkjhfd/host
3434
sahfhfjkhjhfhjdhfjkdhfkjdhfjkhhdsjfhdfhjdhfkj/somethingelse`;
35+
const correctCgroupV2PodmanData =
36+
'4245 4237 0:94 /containers/overlay-containers/4e9dc37d00ebd2daea029d84bb37764ce12d746a6f3a33c5969cee15c4fc4418/userdata/hostname /etc/hostname rw - tmpfs tmpfs rw';
3537

3638
const wrongCgroupV2Data =
3739
'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm/wrongkeyword';
@@ -85,6 +87,22 @@ describe('ContainerDetector', () => {
8587
});
8688
});
8789

90+
it('should return a resource with container ID with a valid container ID present for v2 (Podman)', async () => {
91+
readStub = sinon.stub(ContainerDetector, 'readFileAsync' as any);
92+
93+
readStub.onFirstCall().resolves('');
94+
readStub.onSecondCall().resolves(correctCgroupV2PodmanData);
95+
96+
const resource = containerDetector.detect();
97+
await resource.waitForAsyncAttributes?.();
98+
sinon.assert.calledTwice(readStub);
99+
100+
assert.ok(resource);
101+
assertContainerResource(resource, {
102+
id: '4e9dc37d00ebd2daea029d84bb37764ce12d746a6f3a33c5969cee15c4fc4418',
103+
});
104+
});
105+
88106
it('should return a empty resource with failed hostname check for v2', async () => {
89107
readStub = sinon.stub(ContainerDetector, 'readFileAsync' as any);
90108

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

metapackages/auto-instrumentations-node/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ For example, to enable only the `env`, `host` detectors:
7777
export OTEL_NODE_RESOURCE_DETECTORS="env,host"
7878
```
7979

80-
By default, all [Supported Instrumentations](#supported-instrumentations) are enabled.
81-
You can use the environment variable `OTEL_NODE_ENABLED_INSTRUMENTATIONS` to enable only certain instrumentations,
80+
By default, all [Supported Instrumentations](#supported-instrumentations) are enabled, unless they are annotated with "default disabled".
81+
You can use the environment variable `OTEL_NODE_ENABLED_INSTRUMENTATIONS` to enable only certain instrumentations, including "default disabled" ones
8282
OR the environment variable `OTEL_NODE_DISABLED_INSTRUMENTATIONS` to disable only certain instrumentations,
8383
by providing a comma-separated list of the instrumentation package names without the `@opentelemetry/instrumentation-` prefix.
8484

@@ -91,10 +91,10 @@ instrumentations:
9191
export OTEL_NODE_ENABLED_INSTRUMENTATIONS="http,nestjs-core"
9292
```
9393

94-
To disable only [@opentelemetry/instrumentation-fs](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs):
94+
To disable only [@opentelemetry/instrumentation-net](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-net):
9595

9696
```shell
97-
export OTEL_NODE_DISABLED_INSTRUMENTATIONS="fs"
97+
export OTEL_NODE_DISABLED_INSTRUMENTATIONS="net"
9898
```
9999

100100
If both environment variables are set, `OTEL_NODE_ENABLED_INSTRUMENTATIONS` is applied first, and then `OTEL_NODE_DISABLED_INSTRUMENTATIONS` is applied to that list.
@@ -170,6 +170,7 @@ registerInstrumentations({
170170
- [@opentelemetry/instrumentation-dns](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-dns)
171171
- [@opentelemetry/instrumentation-express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-express)
172172
- [@opentelemetry/instrumentation-fastify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-fastify)
173+
- [@opentelemetry/instrumentation-fs](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs) (default disabled)
173174
- [@opentelemetry/instrumentation-generic-pool](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-generic-pool)
174175
- [@opentelemetry/instrumentation-graphql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql)
175176
- [@opentelemetry/instrumentation-grpc](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-instrumentation-grpc)

0 commit comments

Comments
 (0)