Skip to content

Commit

Permalink
Merge branch 'main' into feat/mongodb-support-v5
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDeconinck authored Jun 30, 2023
2 parents 4afcd91 + 8777cbd commit f23eeac
Show file tree
Hide file tree
Showing 78 changed files with 910 additions and 80 deletions.
3 changes: 2 additions & 1 deletion .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ components:
plugins/node/opentelemetry-instrumentation-winston:
- seemk
plugins/web/opentelemetry-instrumentation-document-load:
- obecny
- pkanal
- martinkuba
plugins/web/opentelemetry-instrumentation-long-task:
- mhennoch
- t2t2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
"change-case": "4.1.2",
"json5": "2.2.0",
"react": "17.0.2",
"react-dom": "17.0.2"
"react-dom": "17.0.2",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-browser-extension-autoinjection#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-alibaba-cloud#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dependencies": {
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-aws#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
*/

import { diag } from '@opentelemetry/api';
import { Detector, Resource } from '@opentelemetry/resources';
import {
Detector,
Resource,
ResourceAttributes,
} from '@opentelemetry/resources';
import {
CloudProviderValues,
CloudPlatformValues,
Expand Down Expand Up @@ -128,14 +132,19 @@ export class AwsEcsDetector implements Detector {
const baseArn: string = taskArn.substring(0, taskArn.lastIndexOf(':'));
const cluster: string = taskMetadata['Cluster'];

const accountId: string = AwsEcsDetector._getAccountFromArn(taskArn);
const region: string = AwsEcsDetector._getRegionFromArn(taskArn);
const availabilityZone: string | undefined =
taskMetadata?.['AvailabilityZone'];

const clusterArn = cluster.startsWith('arn:')
? cluster
: `${baseArn}:cluster/${cluster}`;

const containerArn: string = containerMetadata['ContainerARN'];

// https://github.com/open-telemetry/opentelemetry-specification/blob/main/semantic_conventions/resource/cloud_provider/aws/ecs.yaml
return new Resource({
// https://github.com/open-telemetry/semantic-conventions/blob/main/semantic_conventions/resource/cloud_provider/aws/ecs.yaml
const attributes: ResourceAttributes = {
[SemanticResourceAttributes.AWS_ECS_CONTAINER_ARN]: containerArn,
[SemanticResourceAttributes.AWS_ECS_CLUSTER_ARN]: clusterArn,
[SemanticResourceAttributes.AWS_ECS_LAUNCHTYPE]:
Expand All @@ -144,7 +153,18 @@ export class AwsEcsDetector implements Detector {
[SemanticResourceAttributes.AWS_ECS_TASK_FAMILY]: taskMetadata['Family'],
[SemanticResourceAttributes.AWS_ECS_TASK_REVISION]:
taskMetadata['Revision'],
});

[SemanticResourceAttributes.CLOUD_ACCOUNT_ID]: accountId,
[SemanticResourceAttributes.CLOUD_REGION]: region,
};

// The availability zone is not available in all Fargate runtimes
if (availabilityZone) {
attributes[SemanticResourceAttributes.CLOUD_AVAILABILITY_ZONE] =
availabilityZone;
}

return new Resource(attributes);
}

private static async _getLogResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import * as os from 'os';
import { join } from 'path';

interface EcsResourceAttributes {
readonly accountId?: string;
readonly region?: string;
readonly zone?: string;
readonly clusterArn?: string;
readonly containerArn?: string;
readonly launchType?: 'ec2' | 'fargate';
Expand All @@ -55,6 +58,9 @@ const assertEcsResource = (
) => {
assertCloudResource(resource, {
provider: CloudProviderValues.AWS,
accountId: validations.accountId,
region: validations.region,
zone: validations.zone,
});
assert.strictEqual(
resource.attributes[SemanticResourceAttributes.CLOUD_PLATFORM],
Expand Down Expand Up @@ -336,6 +342,9 @@ describe('AwsEcsResourceDetector', () => {
describe('on Fargate', () => {
describe('with AWS CloudWatch as log driver', () => {
generateLaunchTypeTests({
accountId: '111122223333',
region: 'us-west-2',
zone: 'us-west-2a',
clusterArn: 'arn:aws:ecs:us-west-2:111122223333:cluster/default',
containerArn:
'arn:aws:ecs:us-west-2:111122223333:container/05966557-f16c-49cb-9352-24b3a0dcd0e1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-container#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"gcp-metadata": "^5.0.0"
"gcp-metadata": "^5.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-gcp#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0"
"@opentelemetry/resources": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-github#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
},
"dependencies": {
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"peerDependencies": {
"@opentelemetry/api": "^1.3.0"
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 @@ -91,6 +91,7 @@
"@opentelemetry/resource-detector-container": "^0.2.5",
"@opentelemetry/resource-detector-gcp": "^0.28.3",
"@opentelemetry/resources": "^1.12.0",
"@opentelemetry/sdk-node": "^0.40.0"
"@opentelemetry/sdk-node": "^0.40.0",
"tslib": "^2.3.1"
}
}
3 changes: 2 additions & 1 deletion metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@opentelemetry/instrumentation-document-load": "^0.32.3",
"@opentelemetry/instrumentation-fetch": "^0.40.0",
"@opentelemetry/instrumentation-user-interaction": "^0.32.4",
"@opentelemetry/instrumentation-xml-http-request": "^0.40.0"
"@opentelemetry/instrumentation-xml-http-request": "^0.40.0",
"tslib": "^2.3.1"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"lerna": "5.5.2",
"lerna-changelog": "2.2.0",
"prettier": "2.8.7",
"typescript": "4.4.4"
"typescript": "4.4.4",
"tslib": "^2.3.1"
},
"changelog": {
"labels": {
Expand Down
3 changes: 2 additions & 1 deletion packages/opentelemetry-host-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
},
"dependencies": {
"@opentelemetry/sdk-metrics": "^1.8.0",
"systeminformation": "^5.0.0"
"systeminformation": "^5.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-host-metrics#readme"
}
3 changes: 2 additions & 1 deletion packages/opentelemetry-id-generator-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"webpack": "4.46.0"
},
"dependencies": {
"@opentelemetry/core": "^1.0.0"
"@opentelemetry/core": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/opentelemetry-id-generator-aws-xray#readme"
}
3 changes: 3 additions & 0 deletions packages/opentelemetry-propagation-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@
"sinon": "15.0.1",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"dependencies": {
"tslib": "^2.3.1"
}
}
3 changes: 3 additions & 0 deletions packages/opentelemetry-redis-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@
"nyc": "15.1.0",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
},
"dependencies": {
"tslib": "^2.3.1"
}
}
3 changes: 2 additions & 1 deletion packages/opentelemetry-sampler-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"axios": "^1.3.5"
"axios": "^1.3.5",
"tslib": "^2.3.1"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/opentelemetry-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@opentelemetry/sdk-trace-node": "^1.8.0",
"@opentelemetry/resources": "^1.8.0",
"@opentelemetry/sdk-trace-base": "^1.8.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
}
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-amqplib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@opentelemetry/api": "^1.3.0",
Expand Down
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-dataloader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.40.0"
"@opentelemetry/instrumentation": "^0.40.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-dataloader#readme"
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-fs#readme"
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-lru-memoizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.40.0"
"@opentelemetry/instrumentation": "^0.40.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-lru-memoizer#readme"
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"dependencies": {
"@opentelemetry/core": "^1.8.0",
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-mongoose#readme"
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-socket.io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
},
"dependencies": {
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0"
"@opentelemetry/semantic-conventions": "^1.0.0",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-socket.io#readme"
}
3 changes: 2 additions & 1 deletion plugins/node/instrumentation-tedious/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"dependencies": {
"@opentelemetry/instrumentation": "^0.40.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@types/tedious": "^4.0.6"
"@types/tedious": "^4.0.6",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/instrumentation-tedious#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In your Lambda function configuration, add or update the `NODE_OPTIONS` environm
| --- | --- | --- |
| `requestHook` | `RequestHook` (function) | Hook for adding custom attributes before lambda starts handling the request. Receives params: `span, { event, context }` |
| `responseHook` | `ResponseHook` (function) | Hook for adding custom attributes before lambda returns the response. Receives params: `span, { err?, res? }` |
| `disableAwsContextPropagation` | `boolean` | By default, this instrumentation will try to read the context from the `_X_AMZN_TRACE_ID` environment variable set by Lambda, set this to `true` to disable this behavior |
| `disableAwsContextPropagation` | `boolean` | By default, this instrumentation will try to read the context from the `_X_AMZN_TRACE_ID` environment variable set by Lambda, set this to `true` or set the environment variable `OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION=true` to disable this behavior |
| `eventContextExtractor` | `EventContextExtractor` (function) | Function for providing custom context extractor in order to support different event types that are handled by AWS Lambda (e.g., SQS, CloudWatch, Kinesis, API Gateway). Applied only when `disableAwsContextPropagation` is set to `true`. Receives params: `event, context` |

### Hooks Usage Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
"@opentelemetry/propagator-aws-xray": "^1.2.1",
"@opentelemetry/resources": "^1.8.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@types/aws-lambda": "8.10.81"
"@types/aws-lambda": "8.10.81",
"tslib": "^2.3.1"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-aws-lambda#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {

import { AwsLambdaInstrumentationConfig, EventContextExtractor } from './types';
import { VERSION } from './version';
import { env } from 'process';
import { LambdaModule } from './internal-types';

const awsPropagator = new AWSXRayPropagator();
Expand All @@ -77,6 +78,17 @@ export class AwsLambdaInstrumentation extends InstrumentationBase {

constructor(protected override _config: AwsLambdaInstrumentationConfig = {}) {
super('@opentelemetry/instrumentation-aws-lambda', VERSION, _config);
if (this._config.disableAwsContextPropagation == null) {
if (
typeof env['OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION'] ===
'string' &&
env[
'OTEL_LAMBDA_DISABLE_AWS_CONTEXT_PROPAGATION'
].toLocaleLowerCase() === 'true'
) {
this._config.disableAwsContextPropagation = true;
}
}
}

override setConfig(config: AwsLambdaInstrumentationConfig = {}) {
Expand Down
Loading

0 comments on commit f23eeac

Please sign in to comment.