@opentelemetry/instrumentation-aws-sdk
Advanced tools
Comparing version 0.37.0 to 0.37.1
@@ -219,3 +219,3 @@ "use strict"; | ||
const normalizedRequest = (0, utils_1.normalizeV3Request)(serviceName, commandName, command.input, undefined); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest, self._config, self._diag); | ||
const span = self._startAwsV3Span(normalizedRequest, requestMetadata); | ||
@@ -308,3 +308,3 @@ const activeContextWithSpan = api_1.trace.setSpan(api_1.context.active(), span); | ||
const normalizedRequest = (0, utils_1.normalizeV2Request)(this); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest, self._config, self._diag); | ||
const span = self._startAwsV2Span(this, requestMetadata, normalizedRequest); | ||
@@ -330,3 +330,3 @@ this[REQUEST_SPAN_KEY] = span; | ||
const normalizedRequest = (0, utils_1.normalizeV2Request)(this); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest); | ||
const requestMetadata = self.servicesExtensions.requestPreSpanHook(normalizedRequest, self._config, self._diag); | ||
const span = self._startAwsV2Span(this, requestMetadata, normalizedRequest); | ||
@@ -333,0 +333,0 @@ this[REQUEST_SPAN_KEY] = span; |
@@ -1,2 +0,2 @@ | ||
import { Span, Tracer } from '@opentelemetry/api'; | ||
import { DiagLogger, Span, Tracer } from '@opentelemetry/api'; | ||
import { RequestMetadata, ServiceExtension } from './ServiceExtension'; | ||
@@ -6,5 +6,5 @@ import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } from '../types'; | ||
toArray<T>(values: T | T[]): T[]; | ||
requestPreSpanHook(normalizedRequest: NormalizedRequest): RequestMetadata; | ||
requestPreSpanHook(normalizedRequest: NormalizedRequest, config: AwsSdkInstrumentationConfig, diag: DiagLogger): RequestMetadata; | ||
responseHook(response: NormalizedResponse, span: Span, _tracer: Tracer, _config: AwsSdkInstrumentationConfig): void; | ||
} | ||
//# sourceMappingURL=dynamodb.d.ts.map |
@@ -25,3 +25,3 @@ "use strict"; | ||
} | ||
requestPreSpanHook(normalizedRequest) { | ||
requestPreSpanHook(normalizedRequest, config, diag) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w; | ||
@@ -36,4 +36,14 @@ const spanKind = api_1.SpanKind.CLIENT; | ||
[semantic_conventions_1.SemanticAttributes.DB_OPERATION]: operation, | ||
[semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: JSON.stringify(normalizedRequest.commandInput), | ||
}; | ||
if (config.dynamoDBStatementSerializer) { | ||
try { | ||
const sanitizedStatement = config.dynamoDBStatementSerializer(operation, normalizedRequest.commandInput); | ||
if (typeof sanitizedStatement === 'string') { | ||
spanAttributes[semantic_conventions_1.SemanticAttributes.DB_STATEMENT] = sanitizedStatement; | ||
} | ||
} | ||
catch (err) { | ||
diag.error('failed to sanitize DynamoDB statement', err); | ||
} | ||
} | ||
// normalizedRequest.commandInput.RequestItems) is undefined when no table names are returned | ||
@@ -40,0 +50,0 @@ // keys in this object are the table names |
@@ -5,3 +5,3 @@ import { Span, Tracer } from '@opentelemetry/api'; | ||
export declare class LambdaServiceExtension implements ServiceExtension { | ||
requestPreSpanHook(request: NormalizedRequest): RequestMetadata; | ||
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata; | ||
requestPostSpanHook: (request: NormalizedRequest) => void; | ||
@@ -8,0 +8,0 @@ responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void; |
@@ -42,3 +42,3 @@ "use strict"; | ||
} | ||
requestPreSpanHook(request) { | ||
requestPreSpanHook(request, _config) { | ||
const functionName = this.extractFunctionName(request.commandInput); | ||
@@ -45,0 +45,0 @@ let spanAttributes = {}; |
@@ -1,2 +0,2 @@ | ||
import { Span, SpanAttributes, SpanKind, Tracer } from '@opentelemetry/api'; | ||
import { DiagLogger, Span, SpanAttributes, SpanKind, Tracer } from '@opentelemetry/api'; | ||
import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } from '../types'; | ||
@@ -10,3 +10,3 @@ export interface RequestMetadata { | ||
export interface ServiceExtension { | ||
requestPreSpanHook: (request: NormalizedRequest) => RequestMetadata; | ||
requestPreSpanHook: (request: NormalizedRequest, config: AwsSdkInstrumentationConfig, diag: DiagLogger) => RequestMetadata; | ||
requestPostSpanHook?: (request: NormalizedRequest) => void; | ||
@@ -13,0 +13,0 @@ responseHook?: (response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig) => void; |
@@ -1,2 +0,2 @@ | ||
import { Tracer, Span } from '@opentelemetry/api'; | ||
import { Tracer, Span, DiagLogger } from '@opentelemetry/api'; | ||
import { ServiceExtension, RequestMetadata } from './ServiceExtension'; | ||
@@ -7,3 +7,3 @@ import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } from '../types'; | ||
constructor(); | ||
requestPreSpanHook(request: NormalizedRequest): RequestMetadata; | ||
requestPreSpanHook(request: NormalizedRequest, config: AwsSdkInstrumentationConfig, diag: DiagLogger): RequestMetadata; | ||
requestPostSpanHook(request: NormalizedRequest): void; | ||
@@ -10,0 +10,0 @@ responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void; |
@@ -16,3 +16,3 @@ "use strict"; | ||
} | ||
requestPreSpanHook(request) { | ||
requestPreSpanHook(request, config, diag) { | ||
const serviceExtension = this.services.get(request.serviceName); | ||
@@ -23,3 +23,3 @@ if (!serviceExtension) | ||
}; | ||
return serviceExtension.requestPreSpanHook(request); | ||
return serviceExtension.requestPreSpanHook(request, config, diag); | ||
} | ||
@@ -26,0 +26,0 @@ requestPostSpanHook(request) { |
@@ -5,3 +5,3 @@ import { Span, Tracer } from '@opentelemetry/api'; | ||
export declare class SnsServiceExtension implements ServiceExtension { | ||
requestPreSpanHook(request: NormalizedRequest): RequestMetadata; | ||
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata; | ||
requestPostSpanHook(request: NormalizedRequest): void; | ||
@@ -8,0 +8,0 @@ responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void; |
@@ -23,3 +23,3 @@ "use strict"; | ||
class SnsServiceExtension { | ||
requestPreSpanHook(request) { | ||
requestPreSpanHook(request, _config) { | ||
let spanKind = api_1.SpanKind.CLIENT; | ||
@@ -26,0 +26,0 @@ let spanName = `SNS ${request.commandName}`; |
@@ -5,3 +5,3 @@ import { Tracer, Span } from '@opentelemetry/api'; | ||
export declare class SqsServiceExtension implements ServiceExtension { | ||
requestPreSpanHook(request: NormalizedRequest): RequestMetadata; | ||
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata; | ||
requestPostSpanHook: (request: NormalizedRequest) => void; | ||
@@ -8,0 +8,0 @@ responseHook: (response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig) => void; |
@@ -97,3 +97,3 @@ "use strict"; | ||
} | ||
requestPreSpanHook(request) { | ||
requestPreSpanHook(request, _config) { | ||
const queueUrl = this.extractQueueUrl(request.commandInput); | ||
@@ -100,0 +100,0 @@ const queueName = this.extractQueueNameFromUrl(queueUrl); |
import { Span } from '@opentelemetry/api'; | ||
import { InstrumentationConfig } from '@opentelemetry/instrumentation'; | ||
import { SQS } from './aws-sdk.types'; | ||
export declare type CommandInput = Record<string, any>; | ||
/** | ||
@@ -12,3 +13,3 @@ * These are normalized request and response, which are used by both sdk v2 and v3. | ||
commandName: string; | ||
commandInput: Record<string, any>; | ||
commandInput: CommandInput; | ||
region?: string; | ||
@@ -46,2 +47,3 @@ } | ||
} | ||
export declare type AwsSdkDynamoDBStatementSerializer = (operation: string, commandInput: CommandInput) => string | undefined; | ||
export interface AwsSdkInstrumentationConfig extends InstrumentationConfig { | ||
@@ -54,2 +56,4 @@ /** hook for adding custom attributes before request is sent to aws */ | ||
sqsProcessHook?: AwsSdkSqsProcessCustomAttributeFunction; | ||
/** custom serializer function for the db.statement attribute in DynamoDB spans */ | ||
dynamoDBStatementSerializer?: AwsSdkDynamoDBStatementSerializer; | ||
/** | ||
@@ -56,0 +60,0 @@ * Most aws operation use http request under the hood. |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.37.0"; | ||
export declare const VERSION = "0.37.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.37.0'; | ||
exports.VERSION = '0.37.1'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/instrumentation-aws-sdk", | ||
"version": "0.37.0", | ||
"version": "0.37.1", | ||
"description": "OpenTelemetry automatic instrumentation for the `aws-sdk` package", | ||
@@ -80,3 +80,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "a757b5e443dfe1dade090aeb11ec37d0e802f8af" | ||
"gitHead": "c7e7000b7bf79b0b107c448b403c2613a9b9e2c1" | ||
} |
@@ -23,7 +23,7 @@ # OpenTelemetry aws-sdk Instrumentation for Node.js | ||
```js | ||
const { NodeTracerProvider } = require("@opentelemetry/sdk-trace-node"); | ||
const { registerInstrumentations } = require("@opentelemetry/instrumentation"); | ||
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); | ||
const { registerInstrumentations } = require('@opentelemetry/instrumentation'); | ||
const { | ||
AwsInstrumentation, | ||
} = require("@opentelemetry/instrumentation-aws-sdk"); | ||
} = require('@opentelemetry/instrumentation-aws-sdk'); | ||
@@ -46,9 +46,10 @@ const provider = new NodeTracerProvider(); | ||
| Options | Type | Description | | ||
| --------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | ||
| `preRequestHook` | `AwsSdkRequestCustomAttributeFunction` | Hook called before request send, which allow to add custom attributes to span. | | ||
| `responseHook` | `AwsSdkResponseCustomAttributeFunction` | Hook for adding custom attributes when response is received from aws. | | ||
| `sqsProcessHook` | `AwsSdkSqsProcessCustomAttributeFunction` | Hook called after starting sqs `process` span (for each sqs received message), which allow to add custom attributes to it. | | ||
| `suppressInternalInstrumentation` | `boolean` | Most aws operation use http requests under the hood. Set this to `true` to hide all underlying http spans. | | ||
| `sqsExtractContextPropagationFromPayload` | `boolean` | Will parse and extract context propagation headers from SQS Payload, false by default. [When should it be used?](./doc/sns.md#integration-with-sqs)| | ||
| Options | Type | Description | | ||
| ----------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `preRequestHook` | `AwsSdkRequestCustomAttributeFunction` | Hook called before request send, which allow to add custom attributes to span. | | ||
| `responseHook` | `AwsSdkResponseCustomAttributeFunction` | Hook for adding custom attributes when response is received from aws. | | ||
| `sqsProcessHook` | `AwsSdkSqsProcessCustomAttributeFunction` | Hook called after starting sqs `process` span (for each sqs received message), which allow to add custom attributes to it. | | ||
| `suppressInternalInstrumentation` | `boolean` | Most aws operation use http requests under the hood. Set this to `true` to hide all underlying http spans. | | ||
| `sqsExtractContextPropagationFromPayload` | `boolean` | Will parse and extract context propagation headers from SQS Payload, false by default. [When should it be used?](./doc/sns.md#integration-with-sqs) | | ||
| `dynamoDBStatementSerializer` | `AwsSdkDynamoDBStatementSerializer` | AWS SDK instrumentation will serialize DynamoDB commands to the `db.statement` attribute using the specified function. Defaults to using a serializer that returns `undefined`. | | ||
@@ -87,4 +88,4 @@ ## Span Attributes | ||
preRequestHook: (span, request) => { | ||
if (span.serviceName === "s3") { | ||
span.setAttribute("s3.bucket.name", request.commandInput["Bucket"]); | ||
if (span.serviceName === 's3') { | ||
span.setAttribute('s3.bucket.name', request.commandInput['Bucket']); | ||
} | ||
@@ -91,0 +92,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211265
1423
135