Skip to content

Commit

Permalink
Merge branch 'main' into refactor/mysql2-improve-span-name
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Oct 23, 2024
2 parents ddd8401 + d056d21 commit 07a9d46
Show file tree
Hide file tree
Showing 149 changed files with 3,640 additions and 6,618 deletions.
10 changes: 10 additions & 0 deletions .github/component-label-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ pkg:sql-common:
- changed-files:
- any-glob-to-any-file:
- packages/opentelemetry-sql-common/**
pkg:propagator-aws-xray:
- changed-files:
- any-glob-to-any-file:
- propagators/propagator-aws-xray/**
pkg:propagator-aws-xray-lambda:
- changed-files:
- any-glob-to-any-file:
- propagators/propagator-aws-xray-lambda/**
pkg-status:unmaintained:
- changed-files:
- any-glob-to-any-file:
Expand All @@ -296,3 +304,5 @@ pkg-status:unmaintained:
- plugins/node/opentelemetry-instrumentation-restify/**
- plugins/node/opentelemetry-instrumentation-router/**
- propagators/opentelemetry-propagator-ot-trace/**
- propagators/propagator-aws-xray/**
- propagators/propagator-aws-xray-lambda/**
4 changes: 4 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ components:
- kirrg001
propagators/opentelemetry-propagator-ot-trace: []
# Unmaintained
propagators/propagator-aws-xray: [ ]
# Unmaintained
propagators/propagator-aws-xray-lambda: [ ]
# Unmaintained

ignored-authors:
- renovate-bot
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
1 change: 1 addition & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require: 'ts-node/register/transpile-only'
10 changes: 6 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"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.3",
"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.2",
"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.1",
"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 All @@ -60,5 +60,7 @@
"plugins/web/opentelemetry-instrumentation-user-interaction": "0.40.0",
"plugins/web/opentelemetry-plugin-react-load": "0.31.0",
"propagators/opentelemetry-propagator-instana": "0.3.2",
"propagators/opentelemetry-propagator-ot-trace": "0.27.2"
"propagators/opentelemetry-propagator-ot-trace": "0.27.2",
"propagators/propagator-aws-xray": "1.26.0",
"propagators/propagator-aws-xray-lambda": "0.53.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint:fix": "eslint . --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/browser-extension-autoinjection --include-dependencies",
"prewatch": "npm run precompile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "npx webpack --mode=development --watch",
"watch:mv2": "npx webpack --mode=development --watch --env MV=2",
Expand Down Expand Up @@ -47,15 +47,13 @@
"html-webpack-plugin": "5.3.2",
"jimp": "0.16.1",
"jsdom": "15.2.1",
"mocha": "7.2.0",
"null-loader": "4.0.1",
"nyc": "15.1.0",
"responsive-loader": "2.3.0",
"rimraf": "4.2.0",
"sinon": "15.0.1",
"sinon-chrome": "3.0.1",
"ts-loader": "9.2.5",
"ts-mocha": "10.0.0",
"typescript": "4.4.4",
"webpack": "4.46.0",
"webpack-cli": "4.7.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-alibaba-cloud --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand Down Expand Up @@ -44,20 +44,18 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"sinon": "15.2.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/resources": "^1.10.0",
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/resources": "^1.10.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
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-aws --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand Down Expand Up @@ -43,12 +43,10 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"sinon": "15.2.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand All @@ -36,11 +36,9 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# 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)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-container",
"version": "0.4.3",
"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 All @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-container --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"version:update": "node ../../../scripts/version-update.js",
"watch": "tsc -w"
Expand All @@ -38,20 +38,18 @@
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
"eslint-plugin-header": "^3.1.1",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"sinon": "15.2.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
},
"dependencies": {
"@opentelemetry/resources": "^1.10.0",
"@opentelemetry/core": "^1.26.0",
"@opentelemetry/resources": "^1.10.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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-gcp --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand Down Expand Up @@ -43,11 +43,9 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/semver": "7.5.8",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-github --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand Down Expand Up @@ -46,11 +46,9 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/sinon": "10.0.20",
"mocha": "7.2.0",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"sinon": "15.2.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-instana --include-dependencies",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "tsc -w"
},
Expand Down Expand Up @@ -43,11 +43,9 @@
"@types/mocha": "8.2.3",
"@types/node": "18.18.14",
"@types/semver": "7.5.8",
"mocha": "7.2.0",
"nock": "13.3.3",
"nyc": "15.1.0",
"rimraf": "5.0.10",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"dependencies": {
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
Loading

0 comments on commit 07a9d46

Please sign in to comment.