Skip to content

Commit

Permalink
Merge branch 'main' into fix/host-metrics-bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
Netail authored Apr 30, 2024
2 parents 4fd1f8f + 4463483 commit 9c30315
Show file tree
Hide file tree
Showing 13 changed files with 1,808 additions and 519 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,15 @@ jobs:
# get main again
- name: Checkout Repository
# only checkout if a release has been created
if: ${{ steps.release.outputs.releases_created }}
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Rebuild Packages
# only rebuild if a release has been created
if: ${{ steps.release.outputs.releases_created }}
run: |
npm ci
npm run compile
Expand All @@ -67,6 +71,8 @@ jobs:
# need to publish all unpublished versions to npm here
# See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
- name: Publish to npm
# only publish if a release has been created
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
run: npx lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes
4 changes: 3 additions & 1 deletion metapackages/auto-instrumentations-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://your-endpoint"
export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
export OTEL_EXPORTER_OTLP_TRACES_HEADERS="x-api-key=your-api-key"
export OTEL_RESOURCE_ATTRIBUTES="service.namespace=my-namespace"
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os"
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os,serviceinstace"
export OTEL_SERVICE_NAME="client"
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
node app.js
Expand All @@ -62,6 +62,7 @@ By default, all SDK resource detectors are used, but you can use the environment
- `host`
- `os`
- `process`
- `serviceinstance`
- `container`
- `alibaba`
- `aws`
Expand Down Expand Up @@ -180,6 +181,7 @@ registerInstrumentations({
- [@opentelemetry/instrumentation-redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-redis)
- [@opentelemetry/instrumentation-restify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-restify)
- [@opentelemetry/instrumentation-socket.io](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io)
- [@opentelemetry/instrumentation-undici](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-undici)
- [@opentelemetry/instrumentation-winston](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-winston)

## Useful links
Expand Down
3 changes: 2 additions & 1 deletion metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@
"@opentelemetry/instrumentation-router": "^0.37.0",
"@opentelemetry/instrumentation-socket.io": "^0.39.0",
"@opentelemetry/instrumentation-tedious": "^0.10.0",
"@opentelemetry/instrumentation-undici": "^0.2.0",
"@opentelemetry/instrumentation-winston": "^0.37.0",
"@opentelemetry/resource-detector-alibaba-cloud": "^0.28.9",
"@opentelemetry/resource-detector-aws": "^1.4.2",
"@opentelemetry/resource-detector-azure": "^0.2.6",
"@opentelemetry/resource-detector-container": "^0.3.9",
"@opentelemetry/resource-detector-gcp": "^0.29.9",
"@opentelemetry/resources": "^1.12.0",
"@opentelemetry/resources": "^1.24.0",
"@opentelemetry/sdk-node": "^0.51.0"
},
"files": [
Expand Down
5 changes: 5 additions & 0 deletions metapackages/auto-instrumentations-node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { RestifyInstrumentation } from '@opentelemetry/instrumentation-restify';
import { RouterInstrumentation } from '@opentelemetry/instrumentation-router';
import { SocketIoInstrumentation } from '@opentelemetry/instrumentation-socket.io';
import { TediousInstrumentation } from '@opentelemetry/instrumentation-tedious';
import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici';
import { WinstonInstrumentation } from '@opentelemetry/instrumentation-winston';

import { alibabaCloudEcsDetector } from '@opentelemetry/resource-detector-alibaba-cloud';
Expand All @@ -72,6 +73,7 @@ import {
hostDetectorSync,
osDetectorSync,
processDetectorSync,
serviceInstanceIdDetectorSync,
} from '@opentelemetry/resources';
import {
azureAppServiceDetector,
Expand All @@ -83,6 +85,7 @@ const RESOURCE_DETECTOR_CONTAINER = 'container';
const RESOURCE_DETECTOR_ENVIRONMENT = 'env';
const RESOURCE_DETECTOR_HOST = 'host';
const RESOURCE_DETECTOR_OS = 'os';
const RESOURCE_DETECTOR_SERVICE_INSTANCE_ID = 'serviceinstance';
const RESOURCE_DETECTOR_PROCESS = 'process';
const RESOURCE_DETECTOR_ALIBABA = 'alibaba';
const RESOURCE_DETECTOR_AWS = 'aws';
Expand Down Expand Up @@ -127,6 +130,7 @@ const InstrumentationMap = {
'@opentelemetry/instrumentation-router': RouterInstrumentation,
'@opentelemetry/instrumentation-socket.io': SocketIoInstrumentation,
'@opentelemetry/instrumentation-tedious': TediousInstrumentation,
'@opentelemetry/instrumentation-undici': UndiciInstrumentation,
'@opentelemetry/instrumentation-winston': WinstonInstrumentation,
};

Expand Down Expand Up @@ -208,6 +212,7 @@ export function getResourceDetectorsFromEnv(): Array<Detector | DetectorSync> {
[RESOURCE_DETECTOR_ENVIRONMENT, envDetectorSync],
[RESOURCE_DETECTOR_HOST, hostDetectorSync],
[RESOURCE_DETECTOR_OS, osDetectorSync],
[RESOURCE_DETECTOR_SERVICE_INSTANCE_ID, serviceInstanceIdDetectorSync],
[RESOURCE_DETECTOR_PROCESS, processDetectorSync],
[RESOURCE_DETECTOR_ALIBABA, alibabaCloudEcsDetector],
[RESOURCE_DETECTOR_GCP, gcpDetector],
Expand Down
13 changes: 8 additions & 5 deletions metapackages/auto-instrumentations-node/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,25 +114,28 @@ describe('utils', () => {

describe('getResourceDetectorsFromEnv', () => {
it('should return all resource detectors by default', () => {
assert.equal(getResourceDetectorsFromEnv().length, 15);
assert.equal(getResourceDetectorsFromEnv().length, 16);
});

it('should return all resource detectors when OTEL_NODE_RESOURCE_DETECTORS contains "all"', () => {
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'all';

assert.equal(getResourceDetectorsFromEnv().length, 15);
assert.equal(getResourceDetectorsFromEnv().length, 16);

delete process.env.OTEL_NODE_RESOURCE_DETECTORS;
});

it('should return specific resource detectors depending on OTEL_NODE_RESOURCE_DETECTORS', () => {
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'env,host';
process.env.OTEL_NODE_RESOURCE_DETECTORS = 'env,host,serviceinstance';

const resourceDetectors = getResourceDetectorsFromEnv();

assert.equal(resourceDetectors.length, 2);
assert.equal(resourceDetectors.length, 3);
assert.equal(resourceDetectors[0].constructor.name, 'EnvDetectorSync');
assert.equal(resourceDetectors[1].constructor.name, 'HostDetectorSync');
assert.equal(
resourceDetectors[2].constructor.name,
'ServiceInstanceIdDetectorSync'
);

delete process.env.OTEL_NODE_RESOURCE_DETECTORS;
});
Expand Down
Loading

0 comments on commit 9c30315

Please sign in to comment.