Skip to content

Commit

Permalink
Merge branch 'main' into feat/node/prom-client-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Oct 17, 2024
2 parents 310a2b2 + f9f5123 commit feb3f36
Show file tree
Hide file tree
Showing 58 changed files with 794 additions and 324 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ jobs:
- name: Lint
run: |
npm run lint
npm run lint:markdown
npm run lint:readme
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"detectors/node/opentelemetry-resource-detector-alibaba-cloud": "0.29.2",
"detectors/node/opentelemetry-resource-detector-alibaba-cloud": "0.29.3",
"detectors/node/opentelemetry-resource-detector-aws": "1.6.2",
"detectors/node/opentelemetry-resource-detector-azure": "0.2.11",
"detectors/node/opentelemetry-resource-detector-container": "0.4.2",
"detectors/node/opentelemetry-resource-detector-container": "0.4.4",
"detectors/node/opentelemetry-resource-detector-gcp": "0.29.12",
"detectors/node/opentelemetry-resource-detector-github": "0.29.0",
"detectors/node/opentelemetry-resource-detector-instana": "0.13.0",
"metapackages/auto-configuration-propagators": "0.3.1",
"metapackages/auto-instrumentations-node": "0.50.1",
"metapackages/auto-instrumentations-node": "0.51.0",
"metapackages/auto-instrumentations-web": "0.41.0",
"packages/baggage-span-processor": "0.3.1",
"packages/opentelemetry-host-metrics": "0.35.4",
Expand Down Expand Up @@ -48,7 +48,7 @@
"plugins/node/opentelemetry-instrumentation-mysql2": "0.41.0",
"plugins/node/opentelemetry-instrumentation-nestjs-core": "0.40.0",
"plugins/node/opentelemetry-instrumentation-net": "0.39.0",
"plugins/node/opentelemetry-instrumentation-pg": "0.45.0",
"plugins/node/opentelemetry-instrumentation-pg": "0.46.0",
"plugins/node/opentelemetry-instrumentation-pino": "0.42.0",
"plugins/node/opentelemetry-instrumentation-redis": "0.42.0",
"plugins/node/opentelemetry-instrumentation-redis-4": "0.42.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.29.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-alibaba-cloud-v0.29.2...resource-detector-alibaba-cloud-v0.29.3) (2024-10-10)


### Bug Fixes

* add missing @opentelemetry/core dependency ([#2473](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2473)) ([4d66431](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/4d66431a2ad480720bf6c33663a419ec1404cd33))

## [0.29.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-alibaba-cloud-v0.29.1...resource-detector-alibaba-cloud-v0.29.2) (2024-10-08)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-alibaba-cloud",
"version": "0.29.2",
"version": "0.29.3",
"description": "OpenTelemetry resource detector for Alibaba Cloud",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -57,6 +57,7 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.10.0",
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/semantic-conventions": "^1.27.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-alibaba-cloud#readme"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [0.4.4](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-container-v0.4.3...resource-detector-container-v0.4.4) (2024-10-16)


### Bug Fixes

* **detector-container:** properly detect container ID when using Podman ([#2448](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2448)) ([ad560df](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/ad560dfc5f662d418a74b0b197b3f48e4ae002d0))

## [0.4.3](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-container-v0.4.2...resource-detector-container-v0.4.3) (2024-10-10)


### Bug Fixes

* add missing @opentelemetry/core dependency ([#2473](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2473)) ([4d66431](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/4d66431a2ad480720bf6c33663a419ec1404cd33))

## [0.4.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-container-v0.4.1...resource-detector-container-v0.4.2) (2024-10-08)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-container",
"version": "0.4.2",
"version": "0.4.4",
"description": "Opentelemetry resource detector to get container resource attributes",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down Expand Up @@ -51,6 +51,7 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.10.0",
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/semantic-conventions": "^1.27.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-container#readme"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ContainerDetector implements DetectorSync {
readonly DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo';
readonly UTF8_UNICODE = 'utf8';
readonly HOSTNAME = 'hostname';
readonly MARKING_PREFIX = 'containers';
readonly MARKING_PREFIX = ['containers', 'overlay-containers'];
readonly CRIO = 'crio-';
readonly CRI_CONTAINERD = 'cri-containerd-';
readonly DOCKER = 'docker-';
Expand Down Expand Up @@ -105,7 +105,7 @@ export class ContainerDetector implements DetectorSync {
const strArray = str?.split('/') ?? [];
for (let i = 0; i < strArray.length - 1; i++) {
if (
strArray[i] === this.MARKING_PREFIX &&
this.MARKING_PREFIX.includes(strArray[i]) &&
strArray[i + 1]?.length === this.CONTAINER_ID_LENGTH
) {
return strArray[i + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const DEFAULT_CGROUP_V1_PATH = '/proc/self/cgroup';
export const DEFAULT_CGROUP_V2_PATH = '/proc/self/mountinfo';
export const UTF8_UNICODE = 'utf8';
export const HOSTNAME = 'hostname';
export const MARKING_PREFIX = 'containers';
export const MARKING_PREFIX = ['containers', 'overlay-containers'];
export const CRIO = 'crio-';
export const CRI_CONTAINERD = 'cri-containerd-';
export const DOCKER = 'docker-';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe('ContainerDetector', () => {
const correctCgroupV2Data = `containers/tmhdefghijklmnopqrstuvwxyzafgrefghiugkmnopqrstuvwxyzabcdefghijkl/hostname
fhkjdshgfhsdfjhdsfkjhfkdshkjhfd/host
sahfhfjkhjhfhjdhfjkdhfkjdhfjkhhdsjfhdfhjdhfkj/somethingelse`;
const correctCgroupV2PodmanData =
'4245 4237 0:94 /containers/overlay-containers/4e9dc37d00ebd2daea029d84bb37764ce12d746a6f3a33c5969cee15c4fc4418/userdata/hostname /etc/hostname rw - tmpfs tmpfs rw';

const wrongCgroupV2Data =
'bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm/wrongkeyword';
Expand Down Expand Up @@ -85,6 +87,22 @@ describe('ContainerDetector', () => {
});
});

it('should return a resource with container ID with a valid container ID present for v2 (Podman)', async () => {
readStub = sinon.stub(ContainerDetector, 'readFileAsync' as any);

readStub.onFirstCall().resolves('');
readStub.onSecondCall().resolves(correctCgroupV2PodmanData);

const resource = containerDetector.detect();
await resource.waitForAsyncAttributes?.();
sinon.assert.calledTwice(readStub);

assert.ok(resource);
assertContainerResource(resource, {
id: '4e9dc37d00ebd2daea029d84bb37764ce12d746a6f3a33c5969cee15c4fc4418',
});
});

it('should return a empty resource with failed hostname check for v2', async () => {
readStub = sinon.stub(ContainerDetector, 'readFileAsync' as any);

Expand Down
29 changes: 2 additions & 27 deletions examples/mysql/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Overview

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

Expand All @@ -20,13 +20,11 @@ npm install
```

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.
2. Run `docker compose up`. This will set up Zipkin, otel collector, Prometheus and Grafana.
3. To see your metrics, go to `http://localhost:3000/`.

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

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

### Jaeger

- Run the server

```sh
# from this directory
npm run jaeger:server
```

- Run the client

```sh
# from this directory
npm run jaeger:client
```

#### Jaeger UI

The `jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`).
Go to Jaeger with your browser <http://localhost:16686/trace/(your-trace-id)> (e.g <http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6>)

<p align="center"><img alt="Jaeger UI with trace" src="images/jaeger-ui.png?raw=true"/></p>

## Useful links

- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
Expand Down
13 changes: 4 additions & 9 deletions examples/mysql/docker/collector/otel-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@ exporters:
const_labels:
label1: value1

logging:
loglevel: debug
debug:
verbosity: detailed

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:

Expand All @@ -37,8 +32,8 @@ service:
traces:
receivers: [otlp]
processors: [batch]
exporters: [logging]
exporters: [debug]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [logging, prometheus]
exporters: [debug, prometheus]
14 changes: 2 additions & 12 deletions examples/mysql/docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: "2"
services:

# mysql
mysql:
image: mysql:5.7
platform: linux/amd64
command: --init-file /etc/mysql/init.sql
volumes:
- ./mysql/init.sql:/etc/mysql/init.sql
Expand All @@ -12,15 +12,6 @@ services:
ports:
- "3306:3306"

# Jaeger

jaeger-all-in-one:
image: jaegertracing/all-in-one:latest
ports:
- "16686:16686"
- "14268"
- "14250"

# Zipkin

zipkin-all-in-one:
Expand All @@ -31,7 +22,7 @@ services:
# Collector

otel-collector:
image: otel/opentelemetry-collector-contrib:0.61.0
image: otel/opentelemetry-collector-contrib:0.111.0
command: ["--config=/etc/otel-collector-config.yaml", ""]
volumes:
- ./collector/otel-collector-config.yaml:/etc/otel-collector-config.yaml
Expand All @@ -43,7 +34,6 @@ services:
- "4317:4317" # OTLP gRPC receiver
- "55679:55679" # zpages extension
depends_on:
- jaeger-all-in-one
- zipkin-all-in-one

# Prometheus
Expand Down
6 changes: 2 additions & 4 deletions examples/mysql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"docker:stop": "docker stop example-mysql && docker rm example-mysql",
"zipkin:server": "cross-env EXPORTER=zipkin ts-node src/server.ts",
"zipkin:client": "cross-env EXPORTER=zipkin ts-node src/client.ts",
"jaeger:server": "cross-env EXPORTER=jaeger ts-node src/server.ts",
"jaeger:client": "cross-env EXPORTER=jaeger ts-node src/client.ts",
"compile": "tsc -p ."
},
"repository": {
Expand All @@ -32,15 +30,15 @@
},
"dependencies": {
"@opentelemetry/api": "^1.0.0",
"@opentelemetry/exporter-jaeger": "^1.0.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.48.0",
"@opentelemetry/exporter-zipkin": "^1.0.0",
"@opentelemetry/instrumentation": "^0.48.0",
"@opentelemetry/instrumentation-http": "^0.48.0",
"@opentelemetry/instrumentation-mysql": "^0.31.0",
"@opentelemetry/sdk-trace-base": "^1.0.0",
"@opentelemetry/sdk-trace-node": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.27.0",
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.48.0",
"@types/node": "^18.18.14",
"mysql": "^2.18.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/mysql#readme",
Expand Down
1 change: 0 additions & 1 deletion examples/mysql/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function handleRequest(request: any, response: any) {
// display traceid in the terminal
const traceId = currentSpan?.spanContext().traceId;
console.log(`traceid: ${traceId}`);
console.log(`Jaeger URL: http://localhost:16686/trace/${traceId}`);
console.log(`Zipkin URL: http://localhost:9411/zipkin/traces/${traceId}`);
try {
const body = [];
Expand Down
3 changes: 0 additions & 3 deletions examples/mysql/src/tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import opentelemetry from '@opentelemetry/api';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
Expand Down Expand Up @@ -38,8 +37,6 @@ export const setupTracing = (serviceName: string) => {

if (EXPORTER.toLowerCase().startsWith('z')) {
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter()));
} else {
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new JaegerExporter()));
}

// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings
Expand Down
30 changes: 30 additions & 0 deletions metapackages/auto-instrumentations-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## [0.51.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.50.2...auto-instrumentations-node-v0.51.0) (2024-10-16)


### ⚠ BREAKING CHANGES

* **auto-instrumentations-node:** disable @opentelemetry/instrumentation-fs by default ([#2467](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2467))

### Features

* **auto-instrumentations-node:** disable @opentelemetry/instrumentation-fs by default ([#2467](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2467)) ([a558044](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/a55804415d39c751a3f5f58c00cf27747821302f))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @opentelemetry/instrumentation-pg bumped from ^0.45.1 to ^0.46.0
* @opentelemetry/resource-detector-container bumped from ^0.4.3 to ^0.4.4

## [0.50.2](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.50.1...auto-instrumentations-node-v0.50.2) (2024-10-10)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @opentelemetry/instrumentation-pg bumped from ^0.45.0 to ^0.45.1
* @opentelemetry/resource-detector-alibaba-cloud bumped from ^0.29.2 to ^0.29.3
* @opentelemetry/resource-detector-container bumped from ^0.4.2 to ^0.4.3

## [0.50.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.50.0...auto-instrumentations-node-v0.50.1) (2024-10-08)


Expand Down
Loading

0 comments on commit feb3f36

Please sign in to comment.