@opentelemetry/instrumentation-aws-sdk 0.56.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/src/aws-sdk.d.ts +1 -0
- package/build/src/aws-sdk.js +13 -0
- package/build/src/aws-sdk.js.map +1 -1
- package/build/src/index.d.ts +1 -1
- package/build/src/index.js.map +1 -1
- package/build/src/semconv.d.ts +87 -9
- package/build/src/semconv.js +88 -10
- package/build/src/semconv.js.map +1 -1
- package/build/src/services/ServicesExtensions.d.ts +1 -0
- package/build/src/services/ServicesExtensions.js +7 -0
- package/build/src/services/ServicesExtensions.js.map +1 -1
- package/build/src/services/secretsmanager.d.ts +8 -0
- package/build/src/services/secretsmanager.js +46 -0
- package/build/src/services/secretsmanager.js.map +1 -0
- package/build/src/services/sqs.d.ts +1 -1
- package/build/src/services/sqs.js +18 -30
- package/build/src/services/sqs.js.map +1 -1
- package/build/src/services/stepfunctions.d.ts +6 -0
- package/build/src/services/stepfunctions.js +42 -0
- package/build/src/services/stepfunctions.js.map +1 -0
- package/build/src/types.d.ts +11 -8
- package/build/src/types.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/doc/sqs.md +5 -54
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ aws-sdk instrumentation has few options available to choose from. You can set th
|
|
|
52
52
|
| ----------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
53
|
| `preRequestHook` | `AwsSdkRequestCustomAttributeFunction` | Hook called before request send, which allow to add custom attributes to span. |
|
|
54
54
|
| `responseHook` | `AwsSdkResponseCustomAttributeFunction` | Hook for adding custom attributes when response is received from aws. |
|
|
55
|
-
| `
|
|
55
|
+
| `exceptionHook` | `AwsSdkExceptionCustomAttributeFunction` | Hook for adding custom attributes when exception is received from aws. |
|
|
56
56
|
| `suppressInternalInstrumentation` | `boolean` | Most aws operation use http requests under the hood. Set this to `true` to hide all underlying http spans. |
|
|
57
57
|
| `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) |
|
|
58
58
|
| `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`. |
|
package/build/src/aws-sdk.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class AwsInstrumentation extends InstrumentationBase<AwsSdkInstru
|
|
|
12
12
|
private _startAwsV3Span;
|
|
13
13
|
private _callUserPreRequestHook;
|
|
14
14
|
private _callUserResponseHook;
|
|
15
|
+
private _callUserExceptionResponseHook;
|
|
15
16
|
private _getV3ConstructStackPatch;
|
|
16
17
|
private _getV3SmithyClientSendPatch;
|
|
17
18
|
private patchV3MiddlewareStack;
|
package/build/src/aws-sdk.js
CHANGED
|
@@ -113,6 +113,18 @@ class AwsInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
113
113
|
api_1.diag.error(`${AwsInstrumentation.component} instrumentation: responseHook error`, e);
|
|
114
114
|
}, true);
|
|
115
115
|
}
|
|
116
|
+
_callUserExceptionResponseHook(span, request, err) {
|
|
117
|
+
const { exceptionHook } = this.getConfig();
|
|
118
|
+
if (!exceptionHook)
|
|
119
|
+
return;
|
|
120
|
+
const requestInfo = {
|
|
121
|
+
request,
|
|
122
|
+
};
|
|
123
|
+
(0, instrumentation_1.safeExecuteInTheMiddle)(() => exceptionHook(span, requestInfo, err), (e) => {
|
|
124
|
+
if (e)
|
|
125
|
+
api_1.diag.error(`${AwsInstrumentation.component} instrumentation: exceptionHook error`, e);
|
|
126
|
+
}, true);
|
|
127
|
+
}
|
|
116
128
|
_getV3ConstructStackPatch(moduleVersion, original) {
|
|
117
129
|
const self = this;
|
|
118
130
|
return function constructStack(...args) {
|
|
@@ -224,6 +236,7 @@ class AwsInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
|
224
236
|
message: err.message,
|
|
225
237
|
});
|
|
226
238
|
span.recordException(err);
|
|
239
|
+
self._callUserExceptionResponseHook(span, normalizedRequest, err);
|
|
227
240
|
throw err;
|
|
228
241
|
})
|
|
229
242
|
.finally(() => {
|
package/build/src/aws-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aws-sdk.js","sourceRoot":"","sources":["../../src/aws-sdk.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAO4B;AAC5B,8CAA8D;AAC9D,mCAAyC;AACzC,yCAAgD;AAQhD,kBAAkB;AAClB,uCAA0D;AAC1D,oEAOwC;AAQxC,mCAKiB;AACjB,yCAAsC;AAEtC,8EAAgF;AAEhF,MAAM,oBAAoB,GAAG,MAAM,CACjC,qDAAqD,CACtD,CAAC;AAKF,MAAa,kBAAmB,SAAQ,qCAAgD;IACtF,MAAM,CAAU,SAAS,GAAG,SAAS,CAAC;IAItC,YAAY,SAAsC,EAAE;QAClD,KAAK,CAAC,sBAAY,EAAE,yBAAe,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAES,IAAI;QACZ,MAAM,gCAAgC,GAAG,IAAI,+CAA6B,CACxE,uDAAuD,EACvD,CAAC,iBAAiB,CAAC,EACnB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EACrC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CACxC,CAAC;QACF,MAAM,gCAAgC,GAAG,IAAI,+CAA6B,CACxE,uDAAuD,EACvD,CAAC,UAAU,CAAC,EACZ,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,EACrC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CACxC,CAAC;QAEF,uFAAuF;QACvF,mDAAmD;QACnD,4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GAAG,EAAE,CAAC;6BACZ;wBACH,CAAC,CAAC,CAAC;wBACL,wBAAwB;6BACrB,IAAI,CAAC,GAAG,CAAC,EAAE;4BACV,OAAO,CAAC,GAAG,CAAC,CAAC;wBACf,CAAC,CAAC;6BACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC/B,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBAEH,OAAO,eAAe,CAAC,UAAU;oBAC/B,CAAC,CAAC,IAAA,mBAAW,EAAC,cAAc,EAAE,qBAAqB,EAAE,CAAC,CAAC;oBACvD,CAAC,CAAC,cAAc,CAAC;YACrB,CAAC,CAAC;YACF,OAAO,cAAc,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC;IAEO,qBAAqB,CAAI,gBAAuC;QACtE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,+BAA+B,EAAE;YACpD,OAAO,aAAO,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;SAC1E;aAAM;YACL,OAAO,gBAAgB,EAAE,CAAC;SAC3B;IACH,CAAC;IAEQ,wBAAwB;QAC/B,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC5B,IAAI,CAAC,kBAAkB,GAAG,IAAI,6BAAkB,EAAE,CAAC;SACpD;QACD,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;;AA9ZU,gDAAkB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Span,\n SpanKind,\n context,\n trace,\n diag,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport { hrTime, suppressTracing } from '@opentelemetry/core';\nimport { AttributeNames } from './enums';\nimport { ServicesExtensions } from './services';\nimport {\n AwsSdkInstrumentationConfig,\n AwsSdkRequestHookInformation,\n AwsSdkResponseHookInformation,\n NormalizedRequest,\n NormalizedResponse,\n} from './types';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport {\n InstrumentationBase,\n InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport type {\n MiddlewareStack,\n HandlerExecutionContext,\n Command as AwsV3Command,\n Handler as AwsV3MiddlewareHandler,\n InitializeHandlerArguments,\n} from '@aws-sdk/types';\nimport {\n bindPromise,\n extractAttributesFromNormalizedRequest,\n normalizeV3Request,\n removeSuffixFromStringIfExists,\n} from './utils';\nimport { propwrap } from './propwrap';\nimport { RequestMetadata } from './services/ServiceExtension';\nimport { SEMATTRS_HTTP_STATUS_CODE } from '@opentelemetry/semantic-conventions';\n\nconst V3_CLIENT_CONFIG_KEY = Symbol(\n 'opentelemetry.instrumentation.aws-sdk.client.config'\n);\ntype V3PluginCommand = AwsV3Command<any, any, any, any, any> & {\n [V3_CLIENT_CONFIG_KEY]?: any;\n};\n\nexport class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentationConfig> {\n static readonly component = 'aws-sdk';\n // need declare since initialized in callbacks from super constructor\n private declare servicesExtensions: ServicesExtensions;\n\n constructor(config: AwsSdkInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n protected init(): InstrumentationModuleDefinition[] {\n const v3MiddlewareStackFileOldVersions = new InstrumentationNodeModuleFile(\n '@aws-sdk/middleware-stack/dist/cjs/MiddlewareStack.js',\n ['>=3.1.0 <3.35.0'],\n this.patchV3ConstructStack.bind(this),\n this.unpatchV3ConstructStack.bind(this)\n );\n const v3MiddlewareStackFileNewVersions = new InstrumentationNodeModuleFile(\n '@aws-sdk/middleware-stack/dist-cjs/MiddlewareStack.js',\n ['>=3.35.0'],\n this.patchV3ConstructStack.bind(this),\n this.unpatchV3ConstructStack.bind(this)\n );\n\n // as for aws-sdk v3.13.1, constructStack is exported from @aws-sdk/middleware-stack as\n // getter instead of function, which fails shimmer.\n // so we are patching the MiddlewareStack.js file directly to get around it.\n const v3MiddlewareStack = new InstrumentationNodeModuleDefinition(\n '@aws-sdk/middleware-stack',\n ['^3.1.0'],\n undefined,\n undefined,\n [v3MiddlewareStackFileOldVersions, v3MiddlewareStackFileNewVersions]\n );\n\n // Patch for @smithy/middleware-stack for @aws-sdk/* packages v3.363.0+.\n // As of @smithy/middleware-stack@2.1.0 `constructStack` is only available\n // as a getter, so we cannot use `this._wrap()`.\n const self = this;\n const v3SmithyMiddlewareStack = new InstrumentationNodeModuleDefinition(\n '@smithy/middleware-stack',\n ['>=2.0.0'],\n (moduleExports, moduleVersion) => {\n const newExports = propwrap(\n moduleExports,\n 'constructStack',\n (orig: any) => {\n self._diag.debug('propwrapping aws-sdk v3 constructStack');\n return self._getV3ConstructStackPatch(moduleVersion, orig);\n }\n );\n return newExports;\n }\n );\n\n const v3SmithyClient = new InstrumentationNodeModuleDefinition(\n '@aws-sdk/smithy-client',\n ['^3.1.0'],\n this.patchV3SmithyClient.bind(this),\n this.unpatchV3SmithyClient.bind(this)\n );\n\n // patch for new @smithy/smithy-client for aws-sdk packages v3.363.0+\n const v3NewSmithyClient = new InstrumentationNodeModuleDefinition(\n '@smithy/smithy-client',\n ['>=1.0.3'],\n this.patchV3SmithyClient.bind(this),\n this.unpatchV3SmithyClient.bind(this)\n );\n\n return [\n v3MiddlewareStack,\n v3SmithyMiddlewareStack,\n v3SmithyClient,\n v3NewSmithyClient,\n ];\n }\n\n protected patchV3ConstructStack(moduleExports: any, moduleVersion?: string) {\n this._wrap(\n moduleExports,\n 'constructStack',\n this._getV3ConstructStackPatch.bind(this, moduleVersion)\n );\n return moduleExports;\n }\n\n protected unpatchV3ConstructStack(moduleExports: any) {\n this._unwrap(moduleExports, 'constructStack');\n return moduleExports;\n }\n\n protected patchV3SmithyClient(moduleExports: any) {\n this._wrap(\n moduleExports.Client.prototype,\n 'send',\n this._getV3SmithyClientSendPatch.bind(this)\n );\n return moduleExports;\n }\n\n protected unpatchV3SmithyClient(moduleExports: any) {\n this._unwrap(moduleExports.Client.prototype, 'send');\n return moduleExports;\n }\n\n private _startAwsV3Span(\n normalizedRequest: NormalizedRequest,\n metadata: RequestMetadata\n ): Span {\n const name =\n metadata.spanName ??\n `${normalizedRequest.serviceName}.${normalizedRequest.commandName}`;\n const newSpan = this.tracer.startSpan(name, {\n kind: metadata.spanKind ?? SpanKind.CLIENT,\n attributes: {\n ...extractAttributesFromNormalizedRequest(normalizedRequest),\n ...metadata.spanAttributes,\n },\n });\n\n return newSpan;\n }\n\n private _callUserPreRequestHook(\n span: Span,\n request: NormalizedRequest,\n moduleVersion: string | undefined\n ) {\n const { preRequestHook } = this.getConfig();\n if (preRequestHook) {\n const requestInfo: AwsSdkRequestHookInformation = {\n moduleVersion,\n request,\n };\n safeExecuteInTheMiddle(\n () => preRequestHook(span, requestInfo),\n (e: Error | undefined) => {\n if (e)\n diag.error(\n `${AwsInstrumentation.component} instrumentation: preRequestHook error`,\n e\n );\n },\n true\n );\n }\n }\n\n private _callUserResponseHook(span: Span, response: NormalizedResponse) {\n const { responseHook } = this.getConfig();\n if (!responseHook) return;\n\n const responseInfo: AwsSdkResponseHookInformation = {\n response,\n };\n safeExecuteInTheMiddle(\n () => responseHook(span, responseInfo),\n (e: Error | undefined) => {\n if (e)\n diag.error(\n `${AwsInstrumentation.component} instrumentation: responseHook error`,\n e\n );\n },\n true\n );\n }\n\n private _getV3ConstructStackPatch(\n moduleVersion: string | undefined,\n original: (...args: unknown[]) => MiddlewareStack<any, any>\n ) {\n const self = this;\n return function constructStack(\n this: any,\n ...args: unknown[]\n ): MiddlewareStack<any, any> {\n const stack: MiddlewareStack<any, any> = original.apply(this, args);\n self.patchV3MiddlewareStack(moduleVersion, stack);\n return stack;\n };\n }\n\n private _getV3SmithyClientSendPatch(\n original: (...args: unknown[]) => Promise<any>\n ) {\n return function send(\n this: any,\n command: V3PluginCommand,\n ...args: unknown[]\n ): Promise<any> {\n command[V3_CLIENT_CONFIG_KEY] = this.config;\n return original.apply(this, [command, ...args]);\n };\n }\n\n private patchV3MiddlewareStack(\n moduleVersion: string | undefined,\n middlewareStackToPatch: MiddlewareStack<any, any>\n ) {\n if (!isWrapped(middlewareStackToPatch.resolve)) {\n this._wrap(\n middlewareStackToPatch,\n 'resolve',\n this._getV3MiddlewareStackResolvePatch.bind(this, moduleVersion)\n );\n }\n\n // 'clone' and 'concat' functions are internally calling 'constructStack' which is in same\n // module, thus not patched, and we need to take care of it specifically.\n this._wrap(\n middlewareStackToPatch,\n 'clone',\n this._getV3MiddlewareStackClonePatch.bind(this, moduleVersion)\n );\n this._wrap(\n middlewareStackToPatch,\n 'concat',\n this._getV3MiddlewareStackClonePatch.bind(this, moduleVersion)\n );\n }\n\n private _getV3MiddlewareStackClonePatch(\n moduleVersion: string | undefined,\n original: (...args: any[]) => MiddlewareStack<any, any>\n ) {\n const self = this;\n return function (this: any, ...args: any[]) {\n const newStack = original.apply(this, args);\n self.patchV3MiddlewareStack(moduleVersion, newStack);\n return newStack;\n };\n }\n\n private _getV3MiddlewareStackResolvePatch(\n moduleVersion: string | undefined,\n original: (\n _handler: any,\n context: HandlerExecutionContext\n ) => AwsV3MiddlewareHandler<any, any>\n ) {\n const self = this;\n return function (\n this: any,\n _handler: any,\n awsExecutionContext: HandlerExecutionContext\n ): AwsV3MiddlewareHandler<any, any> {\n const origHandler = original.call(this, _handler, awsExecutionContext);\n const patchedHandler = function (\n this: any,\n command: InitializeHandlerArguments<any> & {\n [V3_CLIENT_CONFIG_KEY]?: any;\n }\n ): Promise<any> {\n const clientConfig = command[V3_CLIENT_CONFIG_KEY];\n const regionPromise = clientConfig?.region?.();\n const serviceName =\n clientConfig?.serviceId ??\n removeSuffixFromStringIfExists(\n // Use 'AWS' as a fallback serviceName to match type definition.\n // In practice, `clientName` should always be set.\n awsExecutionContext.clientName || 'AWS',\n 'Client'\n );\n const commandName =\n awsExecutionContext.commandName ?? command.constructor?.name;\n const normalizedRequest = normalizeV3Request(\n serviceName,\n commandName,\n command.input,\n undefined\n );\n const requestMetadata = self.servicesExtensions.requestPreSpanHook(\n normalizedRequest,\n self.getConfig(),\n self._diag\n );\n const startTime = hrTime();\n const span = self._startAwsV3Span(normalizedRequest, requestMetadata);\n const activeContextWithSpan = trace.setSpan(context.active(), span);\n\n const handlerPromise = new Promise((resolve, reject) => {\n Promise.resolve(regionPromise)\n .then(resolvedRegion => {\n normalizedRequest.region = resolvedRegion;\n span.setAttribute(AttributeNames.CLOUD_REGION, resolvedRegion);\n })\n .catch(e => {\n // there is nothing much we can do in this case.\n // we'll just continue without region\n diag.debug(\n `${AwsInstrumentation.component} instrumentation: failed to extract region from async function`,\n e\n );\n })\n .finally(() => {\n self._callUserPreRequestHook(\n span,\n normalizedRequest,\n moduleVersion\n );\n const resultPromise = context.with(activeContextWithSpan, () => {\n self.servicesExtensions.requestPostSpanHook(normalizedRequest);\n return self._callOriginalFunction(() =>\n origHandler.call(this, command)\n );\n });\n const promiseWithResponseLogic = resultPromise\n .then(response => {\n const requestId = response.output?.$metadata?.requestId;\n if (requestId) {\n span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);\n }\n\n const httpStatusCode =\n response.output?.$metadata?.httpStatusCode;\n if (httpStatusCode) {\n span.setAttribute(\n SEMATTRS_HTTP_STATUS_CODE,\n httpStatusCode\n );\n }\n\n const extendedRequestId =\n response.output?.$metadata?.extendedRequestId;\n if (extendedRequestId) {\n span.setAttribute(\n AttributeNames.AWS_REQUEST_EXTENDED_ID,\n extendedRequestId\n );\n }\n\n const normalizedResponse: NormalizedResponse = {\n data: response.output,\n request: normalizedRequest,\n requestId: requestId,\n };\n const override = self.servicesExtensions.responseHook(\n normalizedResponse,\n span,\n self.tracer,\n self.getConfig(),\n startTime\n );\n if (override) {\n response.output = override;\n normalizedResponse.data = override;\n }\n self._callUserResponseHook(span, normalizedResponse);\n return response;\n })\n .catch(err => {\n const requestId = err?.RequestId;\n if (requestId) {\n span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);\n }\n\n const httpStatusCode = err?.$metadata?.httpStatusCode;\n if (httpStatusCode) {\n span.setAttribute(\n SEMATTRS_HTTP_STATUS_CODE,\n httpStatusCode\n );\n }\n\n const extendedRequestId = err?.extendedRequestId;\n if (extendedRequestId) {\n span.setAttribute(\n AttributeNames.AWS_REQUEST_EXTENDED_ID,\n extendedRequestId\n );\n }\n\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n throw err;\n })\n .finally(() => {\n if (!requestMetadata.isStream) {\n span.end();\n }\n });\n promiseWithResponseLogic\n .then(res => {\n resolve(res);\n })\n .catch(err => reject(err));\n });\n });\n\n return requestMetadata.isIncoming\n ? bindPromise(handlerPromise, activeContextWithSpan, 2)\n : handlerPromise;\n };\n return patchedHandler;\n };\n }\n\n private _callOriginalFunction<T>(originalFunction: (...args: any[]) => T): T {\n if (this.getConfig().suppressInternalInstrumentation) {\n return context.with(suppressTracing(context.active()), originalFunction);\n } else {\n return originalFunction();\n }\n }\n\n override _updateMetricInstruments() {\n if (!this.servicesExtensions) {\n this.servicesExtensions = new ServicesExtensions();\n }\n this.servicesExtensions.updateMetricInstruments(this.meter);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"aws-sdk.js","sourceRoot":"","sources":["../../src/aws-sdk.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAO4B;AAC5B,8CAA8D;AAC9D,mCAAyC;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GAAG,CAAC;wBACZ,CAAC,CAAC;6BACD,OAAO,CAAC,GAAG,EAAE;4BACZ,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE;gCAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;6BACZ;wBACH,CAAC,CAAC,CAAC;wBACL,wBAAwB;6BACrB,IAAI,CAAC,GAAG,CAAC,EAAE;4BACV,OAAO,CAAC,GAAG,CAAC,CAAC;wBACf,CAAC,CAAC;6BACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC/B,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBAEH,OAAO,eAAe,CAAC,UAAU;oBAC/B,CAAC,CAAC,IAAA,mBAAW,EAAC,cAAc,EAAE,qBAAqB,EAAE,CAAC,CAAC;oBACvD,CAAC,CAAC,cAAc,CAAC;YACrB,CAAC,CAAC;YACF,OAAO,cAAc,CAAC;QACxB,CAAC,CAAC;IACJ,CAAC;IAEO,qBAAqB,CAAI,gBAAuC;QACtE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,+BAA+B,EAAE;YACpD,OAAO,aAAO,CAAC,IAAI,CAAC,IAAA,sBAAe,EAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;SAC1E;aAAM;YACL,OAAO,gBAAgB,EAAE,CAAC;SAC3B;IACH,CAAC;IAEQ,wBAAwB;QAC/B,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC5B,IAAI,CAAC,kBAAkB,GAAG,IAAI,6BAAkB,EAAE,CAAC;SACpD;QACD,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;;AA3bU,gDAAkB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Span,\n SpanKind,\n context,\n trace,\n diag,\n SpanStatusCode,\n} from '@opentelemetry/api';\nimport { hrTime, suppressTracing } from '@opentelemetry/core';\nimport { AttributeNames } from './enums';\nimport { ServicesExtensions } from './services';\nimport {\n AwsSdkInstrumentationConfig,\n AwsSdkRequestHookInformation,\n AwsSdkResponseHookInformation,\n NormalizedRequest,\n NormalizedResponse,\n} from './types';\n/** @knipignore */\nimport { PACKAGE_NAME, PACKAGE_VERSION } from './version';\nimport {\n InstrumentationBase,\n InstrumentationModuleDefinition,\n InstrumentationNodeModuleDefinition,\n InstrumentationNodeModuleFile,\n isWrapped,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport type {\n MiddlewareStack,\n HandlerExecutionContext,\n Command as AwsV3Command,\n Handler as AwsV3MiddlewareHandler,\n InitializeHandlerArguments,\n} from '@aws-sdk/types';\nimport {\n bindPromise,\n extractAttributesFromNormalizedRequest,\n normalizeV3Request,\n removeSuffixFromStringIfExists,\n} from './utils';\nimport { propwrap } from './propwrap';\nimport { RequestMetadata } from './services/ServiceExtension';\nimport { SEMATTRS_HTTP_STATUS_CODE } from '@opentelemetry/semantic-conventions';\n\nconst V3_CLIENT_CONFIG_KEY = Symbol(\n 'opentelemetry.instrumentation.aws-sdk.client.config'\n);\ntype V3PluginCommand = AwsV3Command<any, any, any, any, any> & {\n [V3_CLIENT_CONFIG_KEY]?: any;\n};\n\nexport class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentationConfig> {\n static readonly component = 'aws-sdk';\n // need declare since initialized in callbacks from super constructor\n private declare servicesExtensions: ServicesExtensions;\n\n constructor(config: AwsSdkInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, config);\n }\n\n protected init(): InstrumentationModuleDefinition[] {\n const v3MiddlewareStackFileOldVersions = new InstrumentationNodeModuleFile(\n '@aws-sdk/middleware-stack/dist/cjs/MiddlewareStack.js',\n ['>=3.1.0 <3.35.0'],\n this.patchV3ConstructStack.bind(this),\n this.unpatchV3ConstructStack.bind(this)\n );\n const v3MiddlewareStackFileNewVersions = new InstrumentationNodeModuleFile(\n '@aws-sdk/middleware-stack/dist-cjs/MiddlewareStack.js',\n ['>=3.35.0'],\n this.patchV3ConstructStack.bind(this),\n this.unpatchV3ConstructStack.bind(this)\n );\n\n // as for aws-sdk v3.13.1, constructStack is exported from @aws-sdk/middleware-stack as\n // getter instead of function, which fails shimmer.\n // so we are patching the MiddlewareStack.js file directly to get around it.\n const v3MiddlewareStack = new InstrumentationNodeModuleDefinition(\n '@aws-sdk/middleware-stack',\n ['^3.1.0'],\n undefined,\n undefined,\n [v3MiddlewareStackFileOldVersions, v3MiddlewareStackFileNewVersions]\n );\n\n // Patch for @smithy/middleware-stack for @aws-sdk/* packages v3.363.0+.\n // As of @smithy/middleware-stack@2.1.0 `constructStack` is only available\n // as a getter, so we cannot use `this._wrap()`.\n const self = this;\n const v3SmithyMiddlewareStack = new InstrumentationNodeModuleDefinition(\n '@smithy/middleware-stack',\n ['>=2.0.0'],\n (moduleExports, moduleVersion) => {\n const newExports = propwrap(\n moduleExports,\n 'constructStack',\n (orig: any) => {\n self._diag.debug('propwrapping aws-sdk v3 constructStack');\n return self._getV3ConstructStackPatch(moduleVersion, orig);\n }\n );\n return newExports;\n }\n );\n\n const v3SmithyClient = new InstrumentationNodeModuleDefinition(\n '@aws-sdk/smithy-client',\n ['^3.1.0'],\n this.patchV3SmithyClient.bind(this),\n this.unpatchV3SmithyClient.bind(this)\n );\n\n // patch for new @smithy/smithy-client for aws-sdk packages v3.363.0+\n const v3NewSmithyClient = new InstrumentationNodeModuleDefinition(\n '@smithy/smithy-client',\n ['>=1.0.3'],\n this.patchV3SmithyClient.bind(this),\n this.unpatchV3SmithyClient.bind(this)\n );\n\n return [\n v3MiddlewareStack,\n v3SmithyMiddlewareStack,\n v3SmithyClient,\n v3NewSmithyClient,\n ];\n }\n\n protected patchV3ConstructStack(moduleExports: any, moduleVersion?: string) {\n this._wrap(\n moduleExports,\n 'constructStack',\n this._getV3ConstructStackPatch.bind(this, moduleVersion)\n );\n return moduleExports;\n }\n\n protected unpatchV3ConstructStack(moduleExports: any) {\n this._unwrap(moduleExports, 'constructStack');\n return moduleExports;\n }\n\n protected patchV3SmithyClient(moduleExports: any) {\n this._wrap(\n moduleExports.Client.prototype,\n 'send',\n this._getV3SmithyClientSendPatch.bind(this)\n );\n return moduleExports;\n }\n\n protected unpatchV3SmithyClient(moduleExports: any) {\n this._unwrap(moduleExports.Client.prototype, 'send');\n return moduleExports;\n }\n\n private _startAwsV3Span(\n normalizedRequest: NormalizedRequest,\n metadata: RequestMetadata\n ): Span {\n const name =\n metadata.spanName ??\n `${normalizedRequest.serviceName}.${normalizedRequest.commandName}`;\n const newSpan = this.tracer.startSpan(name, {\n kind: metadata.spanKind ?? SpanKind.CLIENT,\n attributes: {\n ...extractAttributesFromNormalizedRequest(normalizedRequest),\n ...metadata.spanAttributes,\n },\n });\n\n return newSpan;\n }\n\n private _callUserPreRequestHook(\n span: Span,\n request: NormalizedRequest,\n moduleVersion: string | undefined\n ) {\n const { preRequestHook } = this.getConfig();\n if (preRequestHook) {\n const requestInfo: AwsSdkRequestHookInformation = {\n moduleVersion,\n request,\n };\n safeExecuteInTheMiddle(\n () => preRequestHook(span, requestInfo),\n (e: Error | undefined) => {\n if (e)\n diag.error(\n `${AwsInstrumentation.component} instrumentation: preRequestHook error`,\n e\n );\n },\n true\n );\n }\n }\n\n private _callUserResponseHook(span: Span, response: NormalizedResponse) {\n const { responseHook } = this.getConfig();\n if (!responseHook) return;\n\n const responseInfo: AwsSdkResponseHookInformation = {\n response,\n };\n safeExecuteInTheMiddle(\n () => responseHook(span, responseInfo),\n (e: Error | undefined) => {\n if (e)\n diag.error(\n `${AwsInstrumentation.component} instrumentation: responseHook error`,\n e\n );\n },\n true\n );\n }\n\n private _callUserExceptionResponseHook(\n span: Span,\n request: NormalizedRequest,\n err: any\n ) {\n const { exceptionHook } = this.getConfig();\n if (!exceptionHook) return;\n const requestInfo: AwsSdkRequestHookInformation = {\n request,\n };\n\n safeExecuteInTheMiddle(\n () => exceptionHook(span, requestInfo, err),\n (e: Error | undefined) => {\n if (e)\n diag.error(\n `${AwsInstrumentation.component} instrumentation: exceptionHook error`,\n e\n );\n },\n true\n );\n }\n\n private _getV3ConstructStackPatch(\n moduleVersion: string | undefined,\n original: (...args: unknown[]) => MiddlewareStack<any, any>\n ) {\n const self = this;\n return function constructStack(\n this: any,\n ...args: unknown[]\n ): MiddlewareStack<any, any> {\n const stack: MiddlewareStack<any, any> = original.apply(this, args);\n self.patchV3MiddlewareStack(moduleVersion, stack);\n return stack;\n };\n }\n\n private _getV3SmithyClientSendPatch(\n original: (...args: unknown[]) => Promise<any>\n ) {\n return function send(\n this: any,\n command: V3PluginCommand,\n ...args: unknown[]\n ): Promise<any> {\n command[V3_CLIENT_CONFIG_KEY] = this.config;\n return original.apply(this, [command, ...args]);\n };\n }\n\n private patchV3MiddlewareStack(\n moduleVersion: string | undefined,\n middlewareStackToPatch: MiddlewareStack<any, any>\n ) {\n if (!isWrapped(middlewareStackToPatch.resolve)) {\n this._wrap(\n middlewareStackToPatch,\n 'resolve',\n this._getV3MiddlewareStackResolvePatch.bind(this, moduleVersion)\n );\n }\n\n // 'clone' and 'concat' functions are internally calling 'constructStack' which is in same\n // module, thus not patched, and we need to take care of it specifically.\n this._wrap(\n middlewareStackToPatch,\n 'clone',\n this._getV3MiddlewareStackClonePatch.bind(this, moduleVersion)\n );\n this._wrap(\n middlewareStackToPatch,\n 'concat',\n this._getV3MiddlewareStackClonePatch.bind(this, moduleVersion)\n );\n }\n\n private _getV3MiddlewareStackClonePatch(\n moduleVersion: string | undefined,\n original: (...args: any[]) => MiddlewareStack<any, any>\n ) {\n const self = this;\n return function (this: any, ...args: any[]) {\n const newStack = original.apply(this, args);\n self.patchV3MiddlewareStack(moduleVersion, newStack);\n return newStack;\n };\n }\n\n private _getV3MiddlewareStackResolvePatch(\n moduleVersion: string | undefined,\n original: (\n _handler: any,\n context: HandlerExecutionContext\n ) => AwsV3MiddlewareHandler<any, any>\n ) {\n const self = this;\n return function (\n this: any,\n _handler: any,\n awsExecutionContext: HandlerExecutionContext\n ): AwsV3MiddlewareHandler<any, any> {\n const origHandler = original.call(this, _handler, awsExecutionContext);\n const patchedHandler = function (\n this: any,\n command: InitializeHandlerArguments<any> & {\n [V3_CLIENT_CONFIG_KEY]?: any;\n }\n ): Promise<any> {\n const clientConfig = command[V3_CLIENT_CONFIG_KEY];\n const regionPromise = clientConfig?.region?.();\n const serviceName =\n clientConfig?.serviceId ??\n removeSuffixFromStringIfExists(\n // Use 'AWS' as a fallback serviceName to match type definition.\n // In practice, `clientName` should always be set.\n awsExecutionContext.clientName || 'AWS',\n 'Client'\n );\n const commandName =\n awsExecutionContext.commandName ?? command.constructor?.name;\n const normalizedRequest = normalizeV3Request(\n serviceName,\n commandName,\n command.input,\n undefined\n );\n const requestMetadata = self.servicesExtensions.requestPreSpanHook(\n normalizedRequest,\n self.getConfig(),\n self._diag\n );\n const startTime = hrTime();\n const span = self._startAwsV3Span(normalizedRequest, requestMetadata);\n const activeContextWithSpan = trace.setSpan(context.active(), span);\n\n const handlerPromise = new Promise((resolve, reject) => {\n Promise.resolve(regionPromise)\n .then(resolvedRegion => {\n normalizedRequest.region = resolvedRegion;\n span.setAttribute(AttributeNames.CLOUD_REGION, resolvedRegion);\n })\n .catch(e => {\n // there is nothing much we can do in this case.\n // we'll just continue without region\n diag.debug(\n `${AwsInstrumentation.component} instrumentation: failed to extract region from async function`,\n e\n );\n })\n .finally(() => {\n self._callUserPreRequestHook(\n span,\n normalizedRequest,\n moduleVersion\n );\n const resultPromise = context.with(activeContextWithSpan, () => {\n self.servicesExtensions.requestPostSpanHook(normalizedRequest);\n return self._callOriginalFunction(() =>\n origHandler.call(this, command)\n );\n });\n const promiseWithResponseLogic = resultPromise\n .then(response => {\n const requestId = response.output?.$metadata?.requestId;\n if (requestId) {\n span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);\n }\n\n const httpStatusCode =\n response.output?.$metadata?.httpStatusCode;\n if (httpStatusCode) {\n span.setAttribute(\n SEMATTRS_HTTP_STATUS_CODE,\n httpStatusCode\n );\n }\n\n const extendedRequestId =\n response.output?.$metadata?.extendedRequestId;\n if (extendedRequestId) {\n span.setAttribute(\n AttributeNames.AWS_REQUEST_EXTENDED_ID,\n extendedRequestId\n );\n }\n\n const normalizedResponse: NormalizedResponse = {\n data: response.output,\n request: normalizedRequest,\n requestId: requestId,\n };\n const override = self.servicesExtensions.responseHook(\n normalizedResponse,\n span,\n self.tracer,\n self.getConfig(),\n startTime\n );\n if (override) {\n response.output = override;\n normalizedResponse.data = override;\n }\n self._callUserResponseHook(span, normalizedResponse);\n return response;\n })\n .catch(err => {\n const requestId = err?.RequestId;\n if (requestId) {\n span.setAttribute(AttributeNames.AWS_REQUEST_ID, requestId);\n }\n\n const httpStatusCode = err?.$metadata?.httpStatusCode;\n if (httpStatusCode) {\n span.setAttribute(\n SEMATTRS_HTTP_STATUS_CODE,\n httpStatusCode\n );\n }\n\n const extendedRequestId = err?.extendedRequestId;\n if (extendedRequestId) {\n span.setAttribute(\n AttributeNames.AWS_REQUEST_EXTENDED_ID,\n extendedRequestId\n );\n }\n\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: err.message,\n });\n span.recordException(err);\n self._callUserExceptionResponseHook(\n span,\n normalizedRequest,\n err\n );\n throw err;\n })\n .finally(() => {\n if (!requestMetadata.isStream) {\n span.end();\n }\n });\n promiseWithResponseLogic\n .then(res => {\n resolve(res);\n })\n .catch(err => reject(err));\n });\n });\n\n return requestMetadata.isIncoming\n ? bindPromise(handlerPromise, activeContextWithSpan, 2)\n : handlerPromise;\n };\n return patchedHandler;\n };\n }\n\n private _callOriginalFunction<T>(originalFunction: (...args: any[]) => T): T {\n if (this.getConfig().suppressInternalInstrumentation) {\n return context.with(suppressTracing(context.active()), originalFunction);\n } else {\n return originalFunction();\n }\n }\n\n override _updateMetricInstruments() {\n if (!this.servicesExtensions) {\n this.servicesExtensions = new ServicesExtensions();\n }\n this.servicesExtensions.updateMetricInstruments(this.meter);\n }\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { AwsInstrumentation } from './aws-sdk';
|
|
2
|
-
export type { AwsSdkDynamoDBStatementSerializer, AwsSdkInstrumentationConfig, AwsSdkRequestCustomAttributeFunction, AwsSdkRequestHookInformation, AwsSdkResponseCustomAttributeFunction, AwsSdkResponseHookInformation,
|
|
2
|
+
export type { AwsSdkDynamoDBStatementSerializer, AwsSdkInstrumentationConfig, AwsSdkRequestCustomAttributeFunction, AwsSdkRequestHookInformation, AwsSdkResponseCustomAttributeFunction, AwsSdkResponseHookInformation, CommandInput, NormalizedRequest, NormalizedResponse, } from './types';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,qCAA+C;AAAtC,6GAAA,kBAAkB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport { AwsInstrumentation } from './aws-sdk';\nexport type {\n AwsSdkDynamoDBStatementSerializer,\n AwsSdkInstrumentationConfig,\n AwsSdkRequestCustomAttributeFunction,\n AwsSdkRequestHookInformation,\n AwsSdkResponseCustomAttributeFunction,\n AwsSdkResponseHookInformation,\n
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,qCAA+C;AAAtC,6GAAA,kBAAkB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport { AwsInstrumentation } from './aws-sdk';\nexport type {\n AwsSdkDynamoDBStatementSerializer,\n AwsSdkInstrumentationConfig,\n AwsSdkRequestCustomAttributeFunction,\n AwsSdkRequestHookInformation,\n AwsSdkResponseCustomAttributeFunction,\n AwsSdkResponseHookInformation,\n CommandInput,\n NormalizedRequest,\n NormalizedResponse,\n} from './types';\n"]}
|
package/build/src/semconv.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ARN of the Secret stored in the Secrets Mangger
|
|
3
|
+
*
|
|
4
|
+
* @example arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretName-6RandomCharacters
|
|
5
|
+
*
|
|
6
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ATTR_AWS_SECRETSMANAGER_SECRET_ARN: "aws.secretsmanager.secret.arn";
|
|
9
|
+
/**
|
|
10
|
+
* The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.
|
|
11
|
+
*
|
|
12
|
+
* @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE
|
|
13
|
+
*
|
|
14
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ATTR_AWS_SNS_TOPIC_ARN: "aws.sns.topic.arn";
|
|
17
|
+
/**
|
|
18
|
+
* The ARN of the AWS Step Functions Activity.
|
|
19
|
+
*
|
|
20
|
+
* @example arn:aws:states:us-east-1:123456789012:activity:get-greeting
|
|
21
|
+
*
|
|
22
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN: "aws.step_functions.activity.arn";
|
|
25
|
+
/**
|
|
26
|
+
* The ARN of the AWS Step Functions State Machine.
|
|
27
|
+
*
|
|
28
|
+
* @example arn:aws:states:us-east-1:123456789012:stateMachine:myStateMachine:1
|
|
29
|
+
*
|
|
30
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
31
|
+
*/
|
|
32
|
+
export declare const ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN: "aws.step_functions.state_machine.arn";
|
|
1
33
|
/**
|
|
2
34
|
* The name of the operation being performed.
|
|
3
35
|
*
|
|
@@ -100,29 +132,75 @@ export declare const ATTR_GEN_AI_USAGE_INPUT_TOKENS: "gen_ai.usage.input_tokens"
|
|
|
100
132
|
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
101
133
|
*/
|
|
102
134
|
export declare const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS: "gen_ai.usage.output_tokens";
|
|
135
|
+
/**
|
|
136
|
+
* The number of messages sent, received, or processed in the scope of the batching operation.
|
|
137
|
+
*
|
|
138
|
+
* @example 0
|
|
139
|
+
* @example 1
|
|
140
|
+
* @example 2
|
|
141
|
+
*
|
|
142
|
+
* @note Instrumentations **SHOULD NOT** set `messaging.batch.message_count` on spans that operate with a single message. When a messaging client library supports both batch and single-message API for the same operation, instrumentations **SHOULD** use `messaging.batch.message_count` for batching APIs and **SHOULD NOT** use it for single-message APIs.
|
|
143
|
+
*
|
|
144
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
145
|
+
*/
|
|
146
|
+
export declare const ATTR_MESSAGING_BATCH_MESSAGE_COUNT: "messaging.batch.message_count";
|
|
147
|
+
/**
|
|
148
|
+
* The message destination name
|
|
149
|
+
*
|
|
150
|
+
* @example MyQueue
|
|
151
|
+
* @example MyTopic
|
|
152
|
+
*
|
|
153
|
+
* @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If
|
|
154
|
+
* the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.
|
|
155
|
+
*
|
|
156
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
157
|
+
*/
|
|
158
|
+
export declare const ATTR_MESSAGING_DESTINATION_NAME: "messaging.destination.name";
|
|
159
|
+
/**
|
|
160
|
+
* A value used by the messaging system as an identifier for the message, represented as a string.
|
|
161
|
+
*
|
|
162
|
+
* @example "452a7c7c7c7048c2f887f61572b18fc2"
|
|
163
|
+
*
|
|
164
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
165
|
+
*/
|
|
166
|
+
export declare const ATTR_MESSAGING_MESSAGE_ID: "messaging.message.id";
|
|
167
|
+
/**
|
|
168
|
+
* A string identifying the type of the messaging operation.
|
|
169
|
+
*
|
|
170
|
+
* @note If a custom value is used, it **MUST** be of low cardinality.
|
|
171
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
172
|
+
*/
|
|
173
|
+
export declare const ATTR_MESSAGING_OPERATION_TYPE: "messaging.operation.type";
|
|
103
174
|
/**
|
|
104
175
|
* Enum value "chat" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.
|
|
176
|
+
*
|
|
177
|
+
* Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)
|
|
178
|
+
*
|
|
179
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
105
180
|
*/
|
|
106
181
|
export declare const GEN_AI_OPERATION_NAME_VALUE_CHAT: "chat";
|
|
107
182
|
/**
|
|
108
183
|
* Enum value "aws.bedrock" for attribute {@link ATTR_GEN_AI_SYSTEM}.
|
|
184
|
+
*
|
|
185
|
+
* AWS Bedrock
|
|
186
|
+
*
|
|
187
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
109
188
|
*/
|
|
110
189
|
export declare const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK: "aws.bedrock";
|
|
111
190
|
/**
|
|
112
191
|
* Enum value "input" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
|
|
192
|
+
*
|
|
193
|
+
* Input tokens (prompt, input, etc.)
|
|
194
|
+
*
|
|
195
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
113
196
|
*/
|
|
114
197
|
export declare const GEN_AI_TOKEN_TYPE_VALUE_INPUT: "input";
|
|
115
198
|
/**
|
|
116
199
|
* Enum value "output" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
|
|
200
|
+
*
|
|
201
|
+
* Output tokens (completion, response, etc.)
|
|
202
|
+
*
|
|
203
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
117
204
|
*/
|
|
118
205
|
export declare const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT: "output";
|
|
119
|
-
/**
|
|
120
|
-
* Originally from '@opentelemetry/semantic-conventions/incubating'
|
|
121
|
-
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-sns-attributes
|
|
122
|
-
* The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html)
|
|
123
|
-
* is a logical access point that acts as a communication channel.
|
|
124
|
-
* @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE
|
|
125
|
-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
126
|
-
*/
|
|
127
|
-
export declare const ATTR_AWS_SNS_TOPIC_ARN: "aws.sns.topic.arn";
|
|
128
206
|
//# sourceMappingURL=semconv.d.ts.map
|
package/build/src/semconv.js
CHANGED
|
@@ -15,12 +15,44 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = exports.GEN_AI_TOKEN_TYPE_VALUE_INPUT = exports.GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = exports.GEN_AI_OPERATION_NAME_VALUE_CHAT = exports.ATTR_MESSAGING_OPERATION_TYPE = exports.ATTR_MESSAGING_MESSAGE_ID = exports.ATTR_MESSAGING_DESTINATION_NAME = exports.ATTR_MESSAGING_BATCH_MESSAGE_COUNT = exports.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS = exports.ATTR_GEN_AI_USAGE_INPUT_TOKENS = exports.ATTR_GEN_AI_TOKEN_TYPE = exports.ATTR_GEN_AI_SYSTEM = exports.ATTR_GEN_AI_RESPONSE_FINISH_REASONS = exports.ATTR_GEN_AI_REQUEST_TOP_P = exports.ATTR_GEN_AI_REQUEST_TEMPERATURE = exports.ATTR_GEN_AI_REQUEST_STOP_SEQUENCES = exports.ATTR_GEN_AI_REQUEST_MODEL = exports.ATTR_GEN_AI_REQUEST_MAX_TOKENS = exports.ATTR_GEN_AI_OPERATION_NAME = exports.ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN = exports.ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN = exports.ATTR_AWS_SNS_TOPIC_ARN = exports.ATTR_AWS_SECRETSMANAGER_SECRET_ARN = void 0;
|
|
19
19
|
/*
|
|
20
20
|
* This file contains a copy of unstable semantic convention definitions
|
|
21
21
|
* used by this package.
|
|
22
22
|
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
|
|
23
23
|
*/
|
|
24
|
+
/**
|
|
25
|
+
* The ARN of the Secret stored in the Secrets Mangger
|
|
26
|
+
*
|
|
27
|
+
* @example arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretName-6RandomCharacters
|
|
28
|
+
*
|
|
29
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
30
|
+
*/
|
|
31
|
+
exports.ATTR_AWS_SECRETSMANAGER_SECRET_ARN = 'aws.secretsmanager.secret.arn';
|
|
32
|
+
/**
|
|
33
|
+
* The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.
|
|
34
|
+
*
|
|
35
|
+
* @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE
|
|
36
|
+
*
|
|
37
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
38
|
+
*/
|
|
39
|
+
exports.ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn';
|
|
40
|
+
/**
|
|
41
|
+
* The ARN of the AWS Step Functions Activity.
|
|
42
|
+
*
|
|
43
|
+
* @example arn:aws:states:us-east-1:123456789012:activity:get-greeting
|
|
44
|
+
*
|
|
45
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
46
|
+
*/
|
|
47
|
+
exports.ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN = 'aws.step_functions.activity.arn';
|
|
48
|
+
/**
|
|
49
|
+
* The ARN of the AWS Step Functions State Machine.
|
|
50
|
+
*
|
|
51
|
+
* @example arn:aws:states:us-east-1:123456789012:stateMachine:myStateMachine:1
|
|
52
|
+
*
|
|
53
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
54
|
+
*/
|
|
55
|
+
exports.ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN = 'aws.step_functions.state_machine.arn';
|
|
24
56
|
/**
|
|
25
57
|
* The name of the operation being performed.
|
|
26
58
|
*
|
|
@@ -123,29 +155,75 @@ exports.ATTR_GEN_AI_USAGE_INPUT_TOKENS = 'gen_ai.usage.input_tokens';
|
|
|
123
155
|
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
124
156
|
*/
|
|
125
157
|
exports.ATTR_GEN_AI_USAGE_OUTPUT_TOKENS = 'gen_ai.usage.output_tokens';
|
|
158
|
+
/**
|
|
159
|
+
* The number of messages sent, received, or processed in the scope of the batching operation.
|
|
160
|
+
*
|
|
161
|
+
* @example 0
|
|
162
|
+
* @example 1
|
|
163
|
+
* @example 2
|
|
164
|
+
*
|
|
165
|
+
* @note Instrumentations **SHOULD NOT** set `messaging.batch.message_count` on spans that operate with a single message. When a messaging client library supports both batch and single-message API for the same operation, instrumentations **SHOULD** use `messaging.batch.message_count` for batching APIs and **SHOULD NOT** use it for single-message APIs.
|
|
166
|
+
*
|
|
167
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
168
|
+
*/
|
|
169
|
+
exports.ATTR_MESSAGING_BATCH_MESSAGE_COUNT = 'messaging.batch.message_count';
|
|
170
|
+
/**
|
|
171
|
+
* The message destination name
|
|
172
|
+
*
|
|
173
|
+
* @example MyQueue
|
|
174
|
+
* @example MyTopic
|
|
175
|
+
*
|
|
176
|
+
* @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If
|
|
177
|
+
* the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.
|
|
178
|
+
*
|
|
179
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
180
|
+
*/
|
|
181
|
+
exports.ATTR_MESSAGING_DESTINATION_NAME = 'messaging.destination.name';
|
|
182
|
+
/**
|
|
183
|
+
* A value used by the messaging system as an identifier for the message, represented as a string.
|
|
184
|
+
*
|
|
185
|
+
* @example "452a7c7c7c7048c2f887f61572b18fc2"
|
|
186
|
+
*
|
|
187
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
188
|
+
*/
|
|
189
|
+
exports.ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id';
|
|
190
|
+
/**
|
|
191
|
+
* A string identifying the type of the messaging operation.
|
|
192
|
+
*
|
|
193
|
+
* @note If a custom value is used, it **MUST** be of low cardinality.
|
|
194
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
195
|
+
*/
|
|
196
|
+
exports.ATTR_MESSAGING_OPERATION_TYPE = 'messaging.operation.type';
|
|
126
197
|
/**
|
|
127
198
|
* Enum value "chat" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.
|
|
199
|
+
*
|
|
200
|
+
* Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)
|
|
201
|
+
*
|
|
202
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
128
203
|
*/
|
|
129
204
|
exports.GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat';
|
|
130
205
|
/**
|
|
131
206
|
* Enum value "aws.bedrock" for attribute {@link ATTR_GEN_AI_SYSTEM}.
|
|
207
|
+
*
|
|
208
|
+
* AWS Bedrock
|
|
209
|
+
*
|
|
210
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
132
211
|
*/
|
|
133
212
|
exports.GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock';
|
|
134
213
|
/**
|
|
135
214
|
* Enum value "input" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
|
|
215
|
+
*
|
|
216
|
+
* Input tokens (prompt, input, etc.)
|
|
217
|
+
*
|
|
218
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
136
219
|
*/
|
|
137
220
|
exports.GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input';
|
|
138
221
|
/**
|
|
139
222
|
* Enum value "output" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.
|
|
223
|
+
*
|
|
224
|
+
* Output tokens (completion, response, etc.)
|
|
225
|
+
*
|
|
226
|
+
* @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
140
227
|
*/
|
|
141
228
|
exports.GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output';
|
|
142
|
-
/**
|
|
143
|
-
* Originally from '@opentelemetry/semantic-conventions/incubating'
|
|
144
|
-
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-sns-attributes
|
|
145
|
-
* The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html)
|
|
146
|
-
* is a logical access point that acts as a communication channel.
|
|
147
|
-
* @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE
|
|
148
|
-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
149
|
-
*/
|
|
150
|
-
exports.ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn';
|
|
151
229
|
//# sourceMappingURL=semconv.js.map
|
package/build/src/semconv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACU,QAAA,0BAA0B,GAAG,uBAAgC,CAAC;AAE3E;;;;;;GAMG;AACU,QAAA,8BAA8B,GACzC,2BAAoC,CAAC;AAEvC;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,sBAA+B,CAAC;AAEzE;;;;;;GAMG;AACU,QAAA,kCAAkC,GAC7C,+BAAwC,CAAC;AAE3C;;;;;;GAMG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;;;;;GAMG;AACU,QAAA,yBAAyB,GAAG,sBAA+B,CAAC;AAEzE;;;;;;;GAOG;AACU,QAAA,mCAAmC,GAC9C,gCAAyC,CAAC;AAE5C;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,kBAAkB,GAAG,eAAwB,CAAC;AAE3D;;;;;;;GAOG;AACU,QAAA,sBAAsB,GAAG,mBAA4B,CAAC;AAEnE;;;;;;GAMG;AACU,QAAA,8BAA8B,GACzC,2BAAoC,CAAC;AAEvC;;;;;;GAMG;AACU,QAAA,+BAA+B,GAC1C,4BAAqC,CAAC;AAExC;;GAEG;AACU,QAAA,gCAAgC,GAAG,MAAe,CAAC;AAEhE;;GAEG;AACU,QAAA,+BAA+B,GAAG,aAAsB,CAAC;AAEtE;;GAEG;AACU,QAAA,6BAA6B,GAAG,OAAgB,CAAC;AAE9D;;GAEG;AACU,QAAA,8BAA8B,GAAG,QAAiB,CAAC;AAEhE;;;;;;;GAOG;AACU,QAAA,sBAAsB,GAAG,mBAA4B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The name of the operation being performed.\n *\n * @note If one of the predefined values applies, but specific system uses a different name it's **RECOMMENDED** to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries **SHOULD** use applicable predefined value.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const;\n\n/**\n * The maximum number of tokens the model generates for a request.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MAX_TOKENS =\n 'gen_ai.request.max_tokens' as const;\n\n/**\n * The name of the GenAI model a request is being made to.\n *\n * @example \"gpt-4\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;\n\n/**\n * List of sequences that the model will use to stop generating further tokens.\n *\n * @example [\"forest\", \"lived\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES =\n 'gen_ai.request.stop_sequences' as const;\n\n/**\n * The temperature setting for the GenAI request.\n *\n * @example 0.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TEMPERATURE =\n 'gen_ai.request.temperature' as const;\n\n/**\n * The top_p sampling setting for the GenAI request.\n *\n * @example 1.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const;\n\n/**\n * Array of reasons the model stopped generating tokens, corresponding to each generation received.\n *\n * @example [\"stop\"]\n * @example [\"stop\", \"length\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_RESPONSE_FINISH_REASONS =\n 'gen_ai.response.finish_reasons' as const;\n\n/**\n * The Generative AI product as identified by the client or server instrumentation.\n *\n * @example \"openai\"\n *\n * @note The `gen_ai.system` describes a family of GenAI models with specific model identified\n * by `gen_ai.request.model` and `gen_ai.response.model` attributes.\n *\n * The actual GenAI product may differ from the one identified by the client.\n * Multiple systems, including Azure OpenAI and Gemini, are accessible by OpenAI client\n * libraries. In such cases, the `gen_ai.system` is set to `openai` based on the\n * instrumentation's best knowledge, instead of the actual system. The `server.address`\n * attribute may help identify the actual system in use for `openai`.\n *\n * For custom model, a custom friendly name **SHOULD** be used.\n * If none of these options apply, the `gen_ai.system` **SHOULD** be set to `_OTHER`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;\n\n/**\n * The type of token being counted.\n *\n * @example input\n * @example output\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_TOKEN_TYPE = 'gen_ai.token.type' as const;\n\n/**\n * The number of tokens used in the GenAI input (prompt).\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_INPUT_TOKENS =\n 'gen_ai.usage.input_tokens' as const;\n\n/**\n * The number of tokens used in the GenAI response (completion).\n *\n * @example 180\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS =\n 'gen_ai.usage.output_tokens' as const;\n\n/**\n * Enum value \"chat\" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.\n */\nexport const GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat' as const;\n\n/**\n * Enum value \"aws.bedrock\" for attribute {@link ATTR_GEN_AI_SYSTEM}.\n */\nexport const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock' as const;\n\n/**\n * Enum value \"input\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;\n\n/**\n * Enum value \"output\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;\n\n/**\n * Originally from '@opentelemetry/semantic-conventions/incubating'\n * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/aws.md#amazon-sns-attributes\n * The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html)\n * is a logical access point that acts as a communication channel.\n * @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn' as const;\n"]}
|
|
1
|
+
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":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A,gCAAgC,GAAG,MAAe,CAAC;AAEhE;;;;;;GAMG;AACU,QAAA,+BAA+B,GAAG,aAAsB,CAAC;AAEtE;;;;;;GAMG;AACU,QAAA,6BAA6B,GAAG,OAAgB,CAAC;AAE9D;;;;;;GAMG;AACU,QAAA,8BAA8B,GAAG,QAAiB,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The ARN of the Secret stored in the Secrets Mangger\n *\n * @example arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretName-6RandomCharacters\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SECRETSMANAGER_SECRET_ARN =\n 'aws.secretsmanager.secret.arn' as const;\n\n/**\n * The ARN of the AWS SNS Topic. An Amazon SNS [topic](https://docs.aws.amazon.com/sns/latest/dg/sns-create-topic.html) is a logical access point that acts as a communication channel.\n *\n * @example arn:aws:sns:us-east-1:123456789012:mystack-mytopic-NZJ5JSMVGFIE\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_SNS_TOPIC_ARN = 'aws.sns.topic.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions Activity.\n *\n * @example arn:aws:states:us-east-1:123456789012:activity:get-greeting\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN =\n 'aws.step_functions.activity.arn' as const;\n\n/**\n * The ARN of the AWS Step Functions State Machine.\n *\n * @example arn:aws:states:us-east-1:123456789012:stateMachine:myStateMachine:1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN =\n 'aws.step_functions.state_machine.arn' as const;\n\n/**\n * The name of the operation being performed.\n *\n * @note If one of the predefined values applies, but specific system uses a different name it's **RECOMMENDED** to document it in the semantic conventions for specific GenAI system and use system-specific name in the instrumentation. If a different name is not documented, instrumentation libraries **SHOULD** use applicable predefined value.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_OPERATION_NAME = 'gen_ai.operation.name' as const;\n\n/**\n * The maximum number of tokens the model generates for a request.\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MAX_TOKENS =\n 'gen_ai.request.max_tokens' as const;\n\n/**\n * The name of the GenAI model a request is being made to.\n *\n * @example \"gpt-4\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_MODEL = 'gen_ai.request.model' as const;\n\n/**\n * List of sequences that the model will use to stop generating further tokens.\n *\n * @example [\"forest\", \"lived\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_STOP_SEQUENCES =\n 'gen_ai.request.stop_sequences' as const;\n\n/**\n * The temperature setting for the GenAI request.\n *\n * @example 0.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TEMPERATURE =\n 'gen_ai.request.temperature' as const;\n\n/**\n * The top_p sampling setting for the GenAI request.\n *\n * @example 1.0\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_REQUEST_TOP_P = 'gen_ai.request.top_p' as const;\n\n/**\n * Array of reasons the model stopped generating tokens, corresponding to each generation received.\n *\n * @example [\"stop\"]\n * @example [\"stop\", \"length\"]\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_RESPONSE_FINISH_REASONS =\n 'gen_ai.response.finish_reasons' as const;\n\n/**\n * The Generative AI product as identified by the client or server instrumentation.\n *\n * @example \"openai\"\n *\n * @note The `gen_ai.system` describes a family of GenAI models with specific model identified\n * by `gen_ai.request.model` and `gen_ai.response.model` attributes.\n *\n * The actual GenAI product may differ from the one identified by the client.\n * Multiple systems, including Azure OpenAI and Gemini, are accessible by OpenAI client\n * libraries. In such cases, the `gen_ai.system` is set to `openai` based on the\n * instrumentation's best knowledge, instead of the actual system. The `server.address`\n * attribute may help identify the actual system in use for `openai`.\n *\n * For custom model, a custom friendly name **SHOULD** be used.\n * If none of these options apply, the `gen_ai.system` **SHOULD** be set to `_OTHER`.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_SYSTEM = 'gen_ai.system' as const;\n\n/**\n * The type of token being counted.\n *\n * @example input\n * @example output\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_TOKEN_TYPE = 'gen_ai.token.type' as const;\n\n/**\n * The number of tokens used in the GenAI input (prompt).\n *\n * @example 100\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_INPUT_TOKENS =\n 'gen_ai.usage.input_tokens' as const;\n\n/**\n * The number of tokens used in the GenAI response (completion).\n *\n * @example 180\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_GEN_AI_USAGE_OUTPUT_TOKENS =\n 'gen_ai.usage.output_tokens' as const;\n\n/**\n * The number of messages sent, received, or processed in the scope of the batching operation.\n *\n * @example 0\n * @example 1\n * @example 2\n *\n * @note Instrumentations **SHOULD NOT** set `messaging.batch.message_count` on spans that operate with a single message. When a messaging client library supports both batch and single-message API for the same operation, instrumentations **SHOULD** use `messaging.batch.message_count` for batching APIs and **SHOULD NOT** use it for single-message APIs.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_BATCH_MESSAGE_COUNT =\n 'messaging.batch.message_count' as const;\n\n/**\n * The message destination name\n *\n * @example MyQueue\n * @example MyTopic\n *\n * @note Destination name **SHOULD** uniquely identify a specific queue, topic or other entity within the broker. If\n * the broker doesn't have such notion, the destination name **SHOULD** uniquely identify the broker.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_DESTINATION_NAME =\n 'messaging.destination.name' as const;\n\n/**\n * A value used by the messaging system as an identifier for the message, represented as a string.\n *\n * @example \"452a7c7c7c7048c2f887f61572b18fc2\"\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_MESSAGE_ID = 'messaging.message.id' as const;\n\n/**\n * A string identifying the type of the messaging operation.\n *\n * @note If a custom value is used, it **MUST** be of low cardinality.\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_MESSAGING_OPERATION_TYPE =\n 'messaging.operation.type' as const;\n\n/**\n * Enum value \"chat\" for attribute {@link ATTR_GEN_AI_OPERATION_NAME}.\n *\n * Chat completion operation such as [OpenAI Chat API](https://platform.openai.com/docs/api-reference/chat)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_OPERATION_NAME_VALUE_CHAT = 'chat' as const;\n\n/**\n * Enum value \"aws.bedrock\" for attribute {@link ATTR_GEN_AI_SYSTEM}.\n *\n * AWS Bedrock\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_SYSTEM_VALUE_AWS_BEDROCK = 'aws.bedrock' as const;\n\n/**\n * Enum value \"input\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Input tokens (prompt, input, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_INPUT = 'input' as const;\n\n/**\n * Enum value \"output\" for attribute {@link ATTR_GEN_AI_TOKEN_TYPE}.\n *\n * Output tokens (completion, response, etc.)\n *\n * @experimental This enum value is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const GEN_AI_TOKEN_TYPE_VALUE_OUTPUT = 'output' as const;\n"]}
|
|
@@ -4,6 +4,7 @@ import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } fr
|
|
|
4
4
|
export declare class ServicesExtensions implements ServiceExtension {
|
|
5
5
|
services: Map<string, ServiceExtension>;
|
|
6
6
|
constructor();
|
|
7
|
+
private registerServices;
|
|
7
8
|
requestPreSpanHook(request: NormalizedRequest, config: AwsSdkInstrumentationConfig, diag: DiagLogger): RequestMetadata;
|
|
8
9
|
requestPostSpanHook(request: NormalizedRequest): void;
|
|
9
10
|
responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig, startTime: HrTime): any;
|
|
@@ -4,13 +4,20 @@ exports.ServicesExtensions = void 0;
|
|
|
4
4
|
const sqs_1 = require("./sqs");
|
|
5
5
|
const bedrock_runtime_1 = require("./bedrock-runtime");
|
|
6
6
|
const dynamodb_1 = require("./dynamodb");
|
|
7
|
+
const secretsmanager_1 = require("./secretsmanager");
|
|
7
8
|
const sns_1 = require("./sns");
|
|
9
|
+
const stepfunctions_1 = require("./stepfunctions");
|
|
8
10
|
const lambda_1 = require("./lambda");
|
|
9
11
|
const s3_1 = require("./s3");
|
|
10
12
|
const kinesis_1 = require("./kinesis");
|
|
11
13
|
class ServicesExtensions {
|
|
12
14
|
services = new Map();
|
|
13
15
|
constructor() {
|
|
16
|
+
this.registerServices();
|
|
17
|
+
}
|
|
18
|
+
registerServices() {
|
|
19
|
+
this.services.set('SecretsManager', new secretsmanager_1.SecretsManagerServiceExtension());
|
|
20
|
+
this.services.set('SFN', new stepfunctions_1.StepFunctionsServiceExtension());
|
|
14
21
|
this.services.set('SQS', new sqs_1.SqsServiceExtension());
|
|
15
22
|
this.services.set('SNS', new sns_1.SnsServiceExtension());
|
|
16
23
|
this.services.set('DynamoDB', new dynamodb_1.DynamodbServiceExtension());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServicesExtensions.js","sourceRoot":"","sources":["../../../src/services/ServicesExtensions.ts"],"names":[],"mappings":";;;AAiBA,+BAA4C;AAM5C,uDAAmE;AACnE,yCAAsD;AACtD,+BAA4C;AAC5C,qCAAkD;AAClD,6BAA0C;AAC1C,uCAAoD;AAEpD,MAAa,kBAAkB;IAC7B,QAAQ,GAAkC,IAAI,GAAG,EAAE,CAAC;IAEpD;QACE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,yBAAmB,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,yBAAmB,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAA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DC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Tracer, Span, DiagLogger, Meter, HrTime } from '@opentelemetry/api';\nimport { ServiceExtension, RequestMetadata } from './ServiceExtension';\nimport { SqsServiceExtension } from './sqs';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport { BedrockRuntimeServiceExtension } from './bedrock-runtime';\nimport { DynamodbServiceExtension } from './dynamodb';\nimport { SecretsManagerServiceExtension } from './secretsmanager';\nimport { SnsServiceExtension } from './sns';\nimport { StepFunctionsServiceExtension } from './stepfunctions';\nimport { LambdaServiceExtension } from './lambda';\nimport { S3ServiceExtension } from './s3';\nimport { KinesisServiceExtension } from './kinesis';\n\nexport class ServicesExtensions implements ServiceExtension {\n services: Map<string, ServiceExtension> = new Map();\n\n constructor() {\n this.registerServices();\n }\n\n private registerServices() {\n this.services.set('SecretsManager', new SecretsManagerServiceExtension());\n this.services.set('SFN', new StepFunctionsServiceExtension());\n this.services.set('SQS', new SqsServiceExtension());\n this.services.set('SNS', new SnsServiceExtension());\n this.services.set('DynamoDB', new DynamodbServiceExtension());\n this.services.set('Lambda', new LambdaServiceExtension());\n this.services.set('S3', new S3ServiceExtension());\n this.services.set('Kinesis', new KinesisServiceExtension());\n this.services.set('BedrockRuntime', new BedrockRuntimeServiceExtension());\n }\n\n requestPreSpanHook(\n request: NormalizedRequest,\n config: AwsSdkInstrumentationConfig,\n diag: DiagLogger\n ): RequestMetadata {\n const serviceExtension = this.services.get(request.serviceName);\n if (!serviceExtension)\n return {\n isIncoming: false,\n };\n return serviceExtension.requestPreSpanHook(request, config, diag);\n }\n\n requestPostSpanHook(request: NormalizedRequest) {\n const serviceExtension = this.services.get(request.serviceName);\n if (!serviceExtension?.requestPostSpanHook) return;\n return serviceExtension.requestPostSpanHook(request);\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig,\n startTime: HrTime\n ) {\n const serviceExtension = this.services.get(response.request.serviceName);\n\n return serviceExtension?.responseHook?.(\n response,\n span,\n tracer,\n config,\n startTime\n );\n }\n\n updateMetricInstruments(meter: Meter) {\n for (const serviceExtension of this.services.values()) {\n serviceExtension.updateMetricInstruments?.(meter);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Span, Tracer } from '@opentelemetry/api';
|
|
2
|
+
import { RequestMetadata, ServiceExtension } from './ServiceExtension';
|
|
3
|
+
import { NormalizedRequest, NormalizedResponse, AwsSdkInstrumentationConfig } from '../types';
|
|
4
|
+
export declare class SecretsManagerServiceExtension implements ServiceExtension {
|
|
5
|
+
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata;
|
|
6
|
+
responseHook(response: NormalizedResponse, span: Span, tracer: Tracer, config: AwsSdkInstrumentationConfig): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=secretsmanager.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SecretsManagerServiceExtension = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright The OpenTelemetry Authors
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const api_1 = require("@opentelemetry/api");
|
|
20
|
+
const semconv_1 = require("../semconv");
|
|
21
|
+
class SecretsManagerServiceExtension {
|
|
22
|
+
requestPreSpanHook(request, _config) {
|
|
23
|
+
const secretId = request.commandInput?.SecretId;
|
|
24
|
+
const spanKind = api_1.SpanKind.CLIENT;
|
|
25
|
+
let spanName;
|
|
26
|
+
const spanAttributes = {};
|
|
27
|
+
if (typeof secretId === 'string' &&
|
|
28
|
+
secretId.startsWith('arn:aws:secretsmanager:')) {
|
|
29
|
+
spanAttributes[semconv_1.ATTR_AWS_SECRETSMANAGER_SECRET_ARN] = secretId;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
isIncoming: false,
|
|
33
|
+
spanAttributes,
|
|
34
|
+
spanKind,
|
|
35
|
+
spanName,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
responseHook(response, span, tracer, config) {
|
|
39
|
+
const secretArn = response.data?.ARN;
|
|
40
|
+
if (secretArn) {
|
|
41
|
+
span.setAttribute(semconv_1.ATTR_AWS_SECRETSMANAGER_SECRET_ARN, secretArn);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.SecretsManagerServiceExtension = SecretsManagerServiceExtension;
|
|
46
|
+
//# sourceMappingURL=secretsmanager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secretsmanager.js","sourceRoot":"","sources":["../../../src/services/secretsmanager.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAAwE;AACxE,wCAAgE;AAQhE,MAAa,8BAA8B;IACzC,kBAAkB,CAChB,OAA0B,EAC1B,OAAoC;QAEpC,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC;QAChD,MAAM,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QAC3C,IAAI,QAA4B,CAAC;QACjC,MAAM,cAAc,GAAe,EAAE,CAAC;QACtC,IACE,OAAO,QAAQ,KAAK,QAAQ;YAC5B,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAC9C;YACA,cAAc,CAAC,4CAAkC,CAAC,GAAG,QAAQ,CAAC;SAC/D;QAED,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,cAAc;YACd,QAAQ;YACR,QAAQ;SACT,CAAC;IACJ,CAAC;IAED,YAAY,CACV,QAA4B,EAC5B,IAAU,EACV,MAAc,EACd,MAAmC;QAEnC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;QACrC,IAAI,SAAS,EAAE;YACb,IAAI,CAAC,YAAY,CAAC,4CAAkC,EAAE,SAAS,CAAC,CAAC;SAClE;IACH,CAAC;CACF;AAnCD,wEAmCC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Attributes, Span, SpanKind, Tracer } from '@opentelemetry/api';\nimport { ATTR_AWS_SECRETSMANAGER_SECRET_ARN } from '../semconv';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport {\n NormalizedRequest,\n NormalizedResponse,\n AwsSdkInstrumentationConfig,\n} from '../types';\n\nexport class SecretsManagerServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const secretId = request.commandInput?.SecretId;\n const spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n const spanAttributes: Attributes = {};\n if (\n typeof secretId === 'string' &&\n secretId.startsWith('arn:aws:secretsmanager:')\n ) {\n spanAttributes[ATTR_AWS_SECRETSMANAGER_SECRET_ARN] = secretId;\n }\n\n return {\n isIncoming: false,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n responseHook(\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ): void {\n const secretArn = response.data?.ARN;\n if (secretArn) {\n span.setAttribute(ATTR_AWS_SECRETSMANAGER_SECRET_ARN, secretArn);\n }\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { AwsSdkInstrumentationConfig, NormalizedRequest, NormalizedResponse } fr
|
|
|
4
4
|
export declare class SqsServiceExtension implements ServiceExtension {
|
|
5
5
|
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata;
|
|
6
6
|
requestPostSpanHook: (request: NormalizedRequest) => void;
|
|
7
|
-
responseHook: (response: NormalizedResponse, span: Span,
|
|
7
|
+
responseHook: (response: NormalizedResponse, span: Span, _tracer: Tracer, config: AwsSdkInstrumentationConfig) => void;
|
|
8
8
|
extractQueueUrl: (commandInput: Record<string, any>) => string;
|
|
9
9
|
extractQueueNameFromUrl: (queueUrl: string) => string | undefined;
|
|
10
10
|
}
|
|
@@ -17,8 +17,8 @@ exports.SqsServiceExtension = void 0;
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const propagation_utils_1 = require("@opentelemetry/propagation-utils");
|
|
21
20
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
21
|
+
const semconv_1 = require("../semconv");
|
|
22
22
|
const MessageAttributes_1 = require("./MessageAttributes");
|
|
23
23
|
class SqsServiceExtension {
|
|
24
24
|
requestPreSpanHook(request, _config) {
|
|
@@ -27,10 +27,9 @@ class SqsServiceExtension {
|
|
|
27
27
|
let spanKind = api_1.SpanKind.CLIENT;
|
|
28
28
|
let spanName;
|
|
29
29
|
const spanAttributes = {
|
|
30
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_SYSTEM]: '
|
|
31
|
-
[
|
|
32
|
-
[semantic_conventions_1.
|
|
33
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_URL]: queueUrl,
|
|
30
|
+
[semantic_conventions_1.SEMATTRS_MESSAGING_SYSTEM]: 'aws_sqs',
|
|
31
|
+
[semconv_1.ATTR_MESSAGING_DESTINATION_NAME]: queueName,
|
|
32
|
+
[semantic_conventions_1.ATTR_URL_FULL]: queueUrl,
|
|
34
33
|
};
|
|
35
34
|
let isIncoming = false;
|
|
36
35
|
switch (request.commandName) {
|
|
@@ -39,8 +38,7 @@ class SqsServiceExtension {
|
|
|
39
38
|
isIncoming = true;
|
|
40
39
|
spanKind = api_1.SpanKind.CONSUMER;
|
|
41
40
|
spanName = `${queueName} receive`;
|
|
42
|
-
spanAttributes[
|
|
43
|
-
semantic_conventions_1.MESSAGINGOPERATIONVALUES_RECEIVE;
|
|
41
|
+
spanAttributes[semconv_1.ATTR_MESSAGING_OPERATION_TYPE] = 'receive';
|
|
44
42
|
request.commandInput.MessageAttributeNames =
|
|
45
43
|
(0, MessageAttributes_1.addPropagationFieldsToAttributeNames)(request.commandInput.MessageAttributeNames, api_1.propagation.fields());
|
|
46
44
|
}
|
|
@@ -81,38 +79,28 @@ class SqsServiceExtension {
|
|
|
81
79
|
break;
|
|
82
80
|
}
|
|
83
81
|
};
|
|
84
|
-
responseHook = (response, span,
|
|
82
|
+
responseHook = (response, span, _tracer, config) => {
|
|
85
83
|
switch (response.request.commandName) {
|
|
86
84
|
case 'SendMessage':
|
|
87
|
-
span.setAttribute(
|
|
85
|
+
span.setAttribute(semconv_1.ATTR_MESSAGING_MESSAGE_ID, response?.data?.MessageId);
|
|
88
86
|
break;
|
|
89
87
|
case 'SendMessageBatch':
|
|
90
88
|
// TODO: How should this be handled?
|
|
91
89
|
break;
|
|
92
90
|
case 'ReceiveMessage': {
|
|
93
|
-
const messages = response?.data?.Messages;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
messageToSpanDetails: (message) => ({
|
|
102
|
-
name: queueName ?? 'unknown',
|
|
103
|
-
parentContext: api_1.propagation.extract(api_1.ROOT_CONTEXT, (0, MessageAttributes_1.extractPropagationContext)(message, config.sqsExtractContextPropagationFromPayload), MessageAttributes_1.contextGetter),
|
|
91
|
+
const messages = response?.data?.Messages || [];
|
|
92
|
+
span.setAttribute(semconv_1.ATTR_MESSAGING_BATCH_MESSAGE_COUNT, messages.length);
|
|
93
|
+
for (const message of messages) {
|
|
94
|
+
const propagatedContext = api_1.propagation.extract(api_1.ROOT_CONTEXT, (0, MessageAttributes_1.extractPropagationContext)(message, config.sqsExtractContextPropagationFromPayload), MessageAttributes_1.contextGetter);
|
|
95
|
+
const spanContext = api_1.trace.getSpanContext(propagatedContext);
|
|
96
|
+
if (spanContext) {
|
|
97
|
+
span.addLink({
|
|
98
|
+
context: spanContext,
|
|
104
99
|
attributes: {
|
|
105
|
-
[
|
|
106
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION]: queueName,
|
|
107
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MESSAGINGDESTINATIONKINDVALUES_QUEUE,
|
|
108
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_MESSAGE_ID]: message.MessageId,
|
|
109
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_URL]: queueUrl,
|
|
110
|
-
[semantic_conventions_1.SEMATTRS_MESSAGING_OPERATION]: semantic_conventions_1.MESSAGINGOPERATIONVALUES_PROCESS,
|
|
100
|
+
[semconv_1.ATTR_MESSAGING_MESSAGE_ID]: message.MessageId,
|
|
111
101
|
},
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
propagation_utils_1.pubsubPropagation.patchArrayForProcessSpans(messages, tracer, api_1.context.active());
|
|
102
|
+
});
|
|
103
|
+
}
|
|
116
104
|
}
|
|
117
105
|
break;
|
|
118
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqs.js","sourceRoot":"","sources":["../../../src/services/sqs.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAS4B;AAC5B,wEAAqE;AAQrE,8EAU6C;AAC7C,2DAK6B;AAE7B,MAAa,mBAAmB;IAC9B,kBAAkB,CAChB,OAA0B,EAC1B,OAAoC;QAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QACzC,IAAI,QAA4B,CAAC;QAEjC,MAAM,cAAc,GAAe;YACjC,CAAC,gDAAyB,CAAC,EAAE,SAAS;YACtC,CAAC,0DAAmC,CAAC,EACnC,2DAAoC;YACtC,CAAC,qDAA8B,CAAC,EAAE,SAAS;YAC3C,CAAC,6CAAsB,CAAC,EAAE,QAAQ;SACnC,CAAC;QAEF,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,gBAAgB;gBACnB;oBACE,UAAU,GAAG,IAAI,CAAC;oBAClB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;oBAC7B,QAAQ,GAAG,GAAG,SAAS,UAAU,CAAC;oBAClC,cAAc,CAAC,mDAA4B,CAAC;wBAC1C,uDAAgC,CAAC;oBAEnC,OAA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,EAAE,CAAC;qBAC7C,CAAC,CAAC;oBAEH,qCAAiB,CAAC,yBAAyB,CACzC,QAAQ,EACR,MAAM,EACN,aAAO,CAAC,MAAM,EAAE,CACjB,CAAC;iBACH;gBACD,MAAM;aACP;SACF;IACH,CAAC,CAAC;IAEF,eAAe,GAAG,CAAC,YAAiC,EAAU,EAAE;QAC9D,OAAO,YAAY,EAAE,QAAQ,CAAC;IAChC,CAAC,CAAC;IAEF,uBAAuB,GAAG,CAAC,QAAgB,EAAsB,EAAE;QACjE,IAAI,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAC;QAEhC,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE5C,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC;CACH;AAhKD,kDAgKC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Tracer,\n SpanKind,\n Span,\n propagation,\n trace,\n context,\n ROOT_CONTEXT,\n Attributes,\n} from '@opentelemetry/api';\nimport { pubsubPropagation } from '@opentelemetry/propagation-utils';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport type { SQS } from '../aws-sdk.types';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport {\n MESSAGINGDESTINATIONKINDVALUES_QUEUE,\n MESSAGINGOPERATIONVALUES_PROCESS,\n MESSAGINGOPERATIONVALUES_RECEIVE,\n SEMATTRS_MESSAGING_DESTINATION,\n SEMATTRS_MESSAGING_DESTINATION_KIND,\n SEMATTRS_MESSAGING_MESSAGE_ID,\n SEMATTRS_MESSAGING_OPERATION,\n SEMATTRS_MESSAGING_SYSTEM,\n SEMATTRS_MESSAGING_URL,\n} from '@opentelemetry/semantic-conventions';\nimport {\n contextGetter,\n extractPropagationContext,\n injectPropagationContext,\n addPropagationFieldsToAttributeNames,\n} from './MessageAttributes';\n\nexport class SqsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const queueUrl = this.extractQueueUrl(request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n let spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n\n const spanAttributes: Attributes = {\n [SEMATTRS_MESSAGING_SYSTEM]: 'aws.sqs',\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_QUEUE,\n [SEMATTRS_MESSAGING_DESTINATION]: queueName,\n [SEMATTRS_MESSAGING_URL]: queueUrl,\n };\n\n let isIncoming = false;\n\n switch (request.commandName) {\n case 'ReceiveMessage':\n {\n isIncoming = true;\n spanKind = SpanKind.CONSUMER;\n spanName = `${queueName} receive`;\n spanAttributes[SEMATTRS_MESSAGING_OPERATION] =\n MESSAGINGOPERATIONVALUES_RECEIVE;\n\n request.commandInput.MessageAttributeNames =\n addPropagationFieldsToAttributeNames(\n request.commandInput.MessageAttributeNames,\n propagation.fields()\n );\n }\n break;\n\n case 'SendMessage':\n case 'SendMessageBatch':\n spanKind = SpanKind.PRODUCER;\n spanName = `${queueName} send`;\n break;\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n requestPostSpanHook = (request: NormalizedRequest) => {\n switch (request.commandName) {\n case 'SendMessage':\n {\n const origMessageAttributes =\n request.commandInput['MessageAttributes'] ?? {};\n if (origMessageAttributes) {\n request.commandInput['MessageAttributes'] =\n injectPropagationContext(origMessageAttributes);\n }\n }\n break;\n\n case 'SendMessageBatch':\n {\n const entries = request.commandInput?.Entries;\n if (Array.isArray(entries)) {\n entries.forEach(\n (messageParams: {\n MessageAttributes: SQS.MessageBodyAttributeMap;\n }) => {\n messageParams.MessageAttributes = injectPropagationContext(\n messageParams.MessageAttributes ?? {}\n );\n }\n );\n }\n }\n break;\n }\n };\n\n responseHook = (\n response: NormalizedResponse,\n span: Span,\n tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) => {\n switch (response.request.commandName) {\n case 'SendMessage':\n span.setAttribute(\n SEMATTRS_MESSAGING_MESSAGE_ID,\n response?.data?.MessageId\n );\n break;\n\n case 'SendMessageBatch':\n // TODO: How should this be handled?\n break;\n\n case 'ReceiveMessage': {\n const messages: SQS.Message[] = response?.data?.Messages;\n if (messages) {\n const queueUrl = this.extractQueueUrl(response.request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n\n pubsubPropagation.patchMessagesArrayToStartProcessSpans<SQS.Message>({\n messages,\n parentContext: trace.setSpan(context.active(), span),\n tracer,\n messageToSpanDetails: (message: SQS.Message) => ({\n name: queueName ?? 'unknown',\n parentContext: propagation.extract(\n ROOT_CONTEXT,\n extractPropagationContext(\n message,\n config.sqsExtractContextPropagationFromPayload\n ),\n contextGetter\n ),\n attributes: {\n [SEMATTRS_MESSAGING_SYSTEM]: 'aws.sqs',\n [SEMATTRS_MESSAGING_DESTINATION]: queueName,\n [SEMATTRS_MESSAGING_DESTINATION_KIND]:\n MESSAGINGDESTINATIONKINDVALUES_QUEUE,\n [SEMATTRS_MESSAGING_MESSAGE_ID]: message.MessageId,\n [SEMATTRS_MESSAGING_URL]: queueUrl,\n [SEMATTRS_MESSAGING_OPERATION]:\n MESSAGINGOPERATIONVALUES_PROCESS,\n },\n }),\n processHook: (span: Span, message: SQS.Message) =>\n config.sqsProcessHook?.(span, { message }),\n });\n\n pubsubPropagation.patchArrayForProcessSpans(\n messages,\n tracer,\n context.active()\n );\n }\n break;\n }\n }\n };\n\n extractQueueUrl = (commandInput: Record<string, any>): string => {\n return commandInput?.QueueUrl;\n };\n\n extractQueueNameFromUrl = (queueUrl: string): string | undefined => {\n if (!queueUrl) return undefined;\n\n const segments = queueUrl.split('/');\n if (segments.length === 0) return undefined;\n\n return segments[segments.length - 1];\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sqs.js","sourceRoot":"","sources":["../../../src/services/sqs.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAQ4B;AAQ5B,8EAG6C;AAC7C,wCAKoB;AACpB,2DAK6B;AAE7B,MAAa,mBAAmB;IAC9B,kBAAkB,CAChB,OAA0B,EAC1B,OAAoC;QAEpC,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QACzC,IAAI,QAA4B,CAAC;QAEjC,MAAM,cAAc,GAAe;YACjC,CAAC,gDAAyB,CAAC,EAAE,SAAS;YACtC,CAAC,yCAA+B,CAAC,EAAE,SAAS;YAC5C,CAAC,oCAAa,CAAC,EAAE,QAAQ;SAC1B,CAAC;QAEF,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,gBAAgB;gBACnB;oBACE,UAAU,GAAG,IAAI,CAAC;oBAClB,QAAQ,GAAG,cAAQ,CAAC,QAAQ,CAAC;oBAC7B,QAAQ,GAAG,GAAG,SAAS,UAAU,CAAC;oBAClC,cAAc,CAAC,uCAA6B,CAAC,GAAG,SAAS,CAAC;oBAE1D,OAAO,CAAC,YAAY,CAAC,qBAAqB;wBACxC,IAAA,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IC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n Tracer,\n SpanKind,\n Span,\n propagation,\n trace,\n ROOT_CONTEXT,\n Attributes,\n} from '@opentelemetry/api';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport type { SQS } from '../aws-sdk.types';\nimport {\n AwsSdkInstrumentationConfig,\n NormalizedRequest,\n NormalizedResponse,\n} from '../types';\nimport {\n ATTR_URL_FULL,\n SEMATTRS_MESSAGING_SYSTEM,\n} from '@opentelemetry/semantic-conventions';\nimport {\n ATTR_MESSAGING_BATCH_MESSAGE_COUNT,\n ATTR_MESSAGING_DESTINATION_NAME,\n ATTR_MESSAGING_MESSAGE_ID,\n ATTR_MESSAGING_OPERATION_TYPE,\n} from '../semconv';\nimport {\n contextGetter,\n extractPropagationContext,\n injectPropagationContext,\n addPropagationFieldsToAttributeNames,\n} from './MessageAttributes';\n\nexport class SqsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const queueUrl = this.extractQueueUrl(request.commandInput);\n const queueName = this.extractQueueNameFromUrl(queueUrl);\n let spanKind: SpanKind = SpanKind.CLIENT;\n let spanName: string | undefined;\n\n const spanAttributes: Attributes = {\n [SEMATTRS_MESSAGING_SYSTEM]: 'aws_sqs',\n [ATTR_MESSAGING_DESTINATION_NAME]: queueName,\n [ATTR_URL_FULL]: queueUrl,\n };\n\n let isIncoming = false;\n\n switch (request.commandName) {\n case 'ReceiveMessage':\n {\n isIncoming = true;\n spanKind = SpanKind.CONSUMER;\n spanName = `${queueName} receive`;\n spanAttributes[ATTR_MESSAGING_OPERATION_TYPE] = 'receive';\n\n request.commandInput.MessageAttributeNames =\n addPropagationFieldsToAttributeNames(\n request.commandInput.MessageAttributeNames,\n propagation.fields()\n );\n }\n break;\n\n case 'SendMessage':\n case 'SendMessageBatch':\n spanKind = SpanKind.PRODUCER;\n spanName = `${queueName} send`;\n break;\n }\n\n return {\n isIncoming,\n spanAttributes,\n spanKind,\n spanName,\n };\n }\n\n requestPostSpanHook = (request: NormalizedRequest) => {\n switch (request.commandName) {\n case 'SendMessage':\n {\n const origMessageAttributes =\n request.commandInput['MessageAttributes'] ?? {};\n if (origMessageAttributes) {\n request.commandInput['MessageAttributes'] =\n injectPropagationContext(origMessageAttributes);\n }\n }\n break;\n\n case 'SendMessageBatch':\n {\n const entries = request.commandInput?.Entries;\n if (Array.isArray(entries)) {\n entries.forEach(\n (messageParams: {\n MessageAttributes: SQS.MessageBodyAttributeMap;\n }) => {\n messageParams.MessageAttributes = injectPropagationContext(\n messageParams.MessageAttributes ?? {}\n );\n }\n );\n }\n }\n break;\n }\n };\n\n responseHook = (\n response: NormalizedResponse,\n span: Span,\n _tracer: Tracer,\n config: AwsSdkInstrumentationConfig\n ) => {\n switch (response.request.commandName) {\n case 'SendMessage':\n span.setAttribute(ATTR_MESSAGING_MESSAGE_ID, response?.data?.MessageId);\n break;\n\n case 'SendMessageBatch':\n // TODO: How should this be handled?\n break;\n\n case 'ReceiveMessage': {\n const messages: SQS.Message[] = response?.data?.Messages || [];\n\n span.setAttribute(ATTR_MESSAGING_BATCH_MESSAGE_COUNT, messages.length);\n\n for (const message of messages) {\n const propagatedContext = propagation.extract(\n ROOT_CONTEXT,\n extractPropagationContext(\n message,\n config.sqsExtractContextPropagationFromPayload\n ),\n contextGetter\n );\n\n const spanContext = trace.getSpanContext(propagatedContext);\n\n if (spanContext) {\n span.addLink({\n context: spanContext,\n attributes: {\n [ATTR_MESSAGING_MESSAGE_ID]: message.MessageId,\n },\n });\n }\n }\n break;\n }\n }\n };\n\n extractQueueUrl = (commandInput: Record<string, any>): string => {\n return commandInput?.QueueUrl;\n };\n\n extractQueueNameFromUrl = (queueUrl: string): string | undefined => {\n if (!queueUrl) return undefined;\n\n const segments = queueUrl.split('/');\n if (segments.length === 0) return undefined;\n\n return segments[segments.length - 1];\n };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestMetadata, ServiceExtension } from './ServiceExtension';
|
|
2
|
+
import { NormalizedRequest, AwsSdkInstrumentationConfig } from '../types';
|
|
3
|
+
export declare class StepFunctionsServiceExtension implements ServiceExtension {
|
|
4
|
+
requestPreSpanHook(request: NormalizedRequest, _config: AwsSdkInstrumentationConfig): RequestMetadata;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=stepfunctions.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StepFunctionsServiceExtension = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright The OpenTelemetry Authors
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
const api_1 = require("@opentelemetry/api");
|
|
20
|
+
const semconv_1 = require("../semconv");
|
|
21
|
+
class StepFunctionsServiceExtension {
|
|
22
|
+
requestPreSpanHook(request, _config) {
|
|
23
|
+
const stateMachineArn = request.commandInput?.stateMachineArn;
|
|
24
|
+
const activityArn = request.commandInput?.activityArn;
|
|
25
|
+
const spanKind = api_1.SpanKind.CLIENT;
|
|
26
|
+
const spanAttributes = {};
|
|
27
|
+
if (stateMachineArn) {
|
|
28
|
+
spanAttributes[semconv_1.ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN] =
|
|
29
|
+
stateMachineArn;
|
|
30
|
+
}
|
|
31
|
+
if (activityArn) {
|
|
32
|
+
spanAttributes[semconv_1.ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN] = activityArn;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
isIncoming: false,
|
|
36
|
+
spanAttributes,
|
|
37
|
+
spanKind,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.StepFunctionsServiceExtension = StepFunctionsServiceExtension;
|
|
42
|
+
//# sourceMappingURL=stepfunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stepfunctions.js","sourceRoot":"","sources":["../../../src/services/stepfunctions.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0D;AAC1D,wCAGoB;AAIpB,MAAa,6BAA6B;IACxC,kBAAkB,CAChB,OAA0B,EAC1B,OAAoC;QAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC;QAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,EAAE,WAAW,CAAC;QACtD,MAAM,QAAQ,GAAa,cAAQ,CAAC,MAAM,CAAC;QAC3C,MAAM,cAAc,GAAe,EAAE,CAAC;QAEtC,IAAI,eAAe,EAAE;YACnB,cAAc,CAAC,mDAAyC,CAAC;gBACvD,eAAe,CAAC;SACnB;QAED,IAAI,WAAW,EAAE;YACf,cAAc,CAAC,8CAAoC,CAAC,GAAG,WAAW,CAAC;SACpE;QAED,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,cAAc;YACd,QAAQ;SACT,CAAC;IACJ,CAAC;CACF;AAzBD,sEAyBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Attributes, SpanKind } from '@opentelemetry/api';\nimport {\n ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN,\n ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN,\n} from '../semconv';\nimport { RequestMetadata, ServiceExtension } from './ServiceExtension';\nimport { NormalizedRequest, AwsSdkInstrumentationConfig } from '../types';\n\nexport class StepFunctionsServiceExtension implements ServiceExtension {\n requestPreSpanHook(\n request: NormalizedRequest,\n _config: AwsSdkInstrumentationConfig\n ): RequestMetadata {\n const stateMachineArn = request.commandInput?.stateMachineArn;\n const activityArn = request.commandInput?.activityArn;\n const spanKind: SpanKind = SpanKind.CLIENT;\n const spanAttributes: Attributes = {};\n\n if (stateMachineArn) {\n spanAttributes[ATTR_AWS_STEP_FUNCTIONS_STATE_MACHINE_ARN] =\n stateMachineArn;\n }\n\n if (activityArn) {\n spanAttributes[ATTR_AWS_STEP_FUNCTIONS_ACTIVITY_ARN] = activityArn;\n }\n\n return {\n isIncoming: false,\n spanAttributes,\n spanKind,\n };\n }\n}\n"]}
|
package/build/src/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Span } from '@opentelemetry/api';
|
|
2
2
|
import { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { SQS } from './aws-sdk.types';
|
|
4
3
|
export type CommandInput = Record<string, any>;
|
|
5
4
|
/**
|
|
6
5
|
* These are normalized request and response.
|
|
@@ -37,11 +36,12 @@ export interface AwsSdkResponseHookInformation {
|
|
|
37
36
|
export interface AwsSdkResponseCustomAttributeFunction {
|
|
38
37
|
(span: Span, responseInfo: AwsSdkResponseHookInformation): void;
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
/**
|
|
40
|
+
* span can be used to modify the status.
|
|
41
|
+
* As we have no response object, the request can be used to determine the failed aws-sdk operation.
|
|
42
|
+
*/
|
|
43
|
+
export interface AwsSdkExceptionCustomAttributeFunction {
|
|
44
|
+
(span: Span, requestInfo: AwsSdkRequestHookInformation, err: any): void;
|
|
45
45
|
}
|
|
46
46
|
export type AwsSdkDynamoDBStatementSerializer = (operation: string, commandInput: CommandInput) => string | undefined;
|
|
47
47
|
export interface AwsSdkInstrumentationConfig extends InstrumentationConfig {
|
|
@@ -49,8 +49,11 @@ export interface AwsSdkInstrumentationConfig extends InstrumentationConfig {
|
|
|
49
49
|
preRequestHook?: AwsSdkRequestCustomAttributeFunction;
|
|
50
50
|
/** hook for adding custom attributes when response is received from aws */
|
|
51
51
|
responseHook?: AwsSdkResponseCustomAttributeFunction;
|
|
52
|
-
/**
|
|
53
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Hook for adding custom attributes when exception is received from aws.
|
|
54
|
+
* This hook is only available with aws sdk v3
|
|
55
|
+
*/
|
|
56
|
+
exceptionHook?: AwsSdkExceptionCustomAttributeFunction;
|
|
54
57
|
/** custom serializer function for the db.statement attribute in DynamoDB spans */
|
|
55
58
|
dynamoDBStatementSerializer?: AwsSdkDynamoDBStatementSerializer;
|
|
56
59
|
/**
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Span } from '@opentelemetry/api';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Span } from '@opentelemetry/api';\nimport { InstrumentationConfig } from '@opentelemetry/instrumentation';\n\nexport type CommandInput = Record<string, any>;\n\n/**\n * These are normalized request and response.\n * They organize the relevant data in one interface which can be processed in a\n * uniform manner in hooks\n */\nexport interface NormalizedRequest {\n serviceName: string;\n commandName: string;\n commandInput: CommandInput;\n region?: string;\n}\nexport interface NormalizedResponse {\n data: any;\n request: NormalizedRequest;\n requestId: string;\n}\n\nexport interface AwsSdkRequestHookInformation {\n moduleVersion?: string;\n request: NormalizedRequest;\n}\nexport interface AwsSdkRequestCustomAttributeFunction {\n (span: Span, requestInfo: AwsSdkRequestHookInformation): void;\n}\n\nexport interface AwsSdkResponseHookInformation {\n moduleVersion?: string;\n response: NormalizedResponse;\n}\n\n/**\n * span can be used to add custom attributes, or for any other need.\n * response is the object that is returned to the user calling the aws-sdk operation.\n * The response type and attributes on the response are client-specific.\n */\nexport interface AwsSdkResponseCustomAttributeFunction {\n (span: Span, responseInfo: AwsSdkResponseHookInformation): void;\n}\n\n/**\n * span can be used to modify the status.\n * As we have no response object, the request can be used to determine the failed aws-sdk operation.\n */\nexport interface AwsSdkExceptionCustomAttributeFunction {\n (span: Span, requestInfo: AwsSdkRequestHookInformation, err: any): void;\n}\n\nexport type AwsSdkDynamoDBStatementSerializer = (\n operation: string,\n commandInput: CommandInput\n) => string | undefined;\n\nexport interface AwsSdkInstrumentationConfig extends InstrumentationConfig {\n /** hook for adding custom attributes before request is sent to aws */\n preRequestHook?: AwsSdkRequestCustomAttributeFunction;\n\n /** hook for adding custom attributes when response is received from aws */\n responseHook?: AwsSdkResponseCustomAttributeFunction;\n\n /**\n * Hook for adding custom attributes when exception is received from aws.\n * This hook is only available with aws sdk v3\n */\n exceptionHook?: AwsSdkExceptionCustomAttributeFunction;\n\n /** custom serializer function for the db.statement attribute in DynamoDB spans */\n dynamoDBStatementSerializer?: AwsSdkDynamoDBStatementSerializer;\n\n /**\n * Most aws operation use http request under the hood.\n * if http instrumentation is enabled, each aws operation will also create\n * an http/s child describing the communication with amazon servers.\n * Setting the `suppressInternalInstrumentation` config value to `true` will\n * cause the instrumentation to suppress instrumentation of underlying operations,\n * effectively causing those http spans to be non-recordable.\n */\n suppressInternalInstrumentation?: boolean;\n\n /**\n * In some cases the context propagation headers may be found in the message payload\n * rather than the message attribute.\n * When this field is turned on the instrumentation will parse the payload and extract the\n * context from there.\n * Even if the field is on and MessageAttribute contains context propagation field are present,\n * the MessageAttribute will get priority.\n * By default it is off.\n */\n sqsExtractContextPropagationFromPayload?: boolean;\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
package/build/src/version.js
CHANGED
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PACKAGE_NAME = exports.PACKAGE_VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.PACKAGE_VERSION = '0.
|
|
20
|
+
exports.PACKAGE_VERSION = '0.58.0';
|
|
21
21
|
exports.PACKAGE_NAME = '@opentelemetry/instrumentation-aws-sdk';
|
|
22
22
|
//# sourceMappingURL=version.js.map
|
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,YAAY,GAAG,wCAAwC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const PACKAGE_VERSION = '0.58.0';\nexport const PACKAGE_NAME = '@opentelemetry/instrumentation-aws-sdk';\n"]}
|
package/doc/sqs.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SQS
|
|
2
2
|
|
|
3
|
-
SQS is
|
|
3
|
+
SQS is Amazon's managed message queue. Thus, it should follow the [OpenTelemetry specification for Messaging systems](https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/).
|
|
4
4
|
|
|
5
5
|
## Specific trace semantic
|
|
6
6
|
|
|
@@ -8,61 +8,12 @@ The following methods are automatically enhanced:
|
|
|
8
8
|
|
|
9
9
|
### sendMessage / sendMessageBatch
|
|
10
10
|
|
|
11
|
-
- [Messaging Attributes](https://
|
|
11
|
+
- [Messaging Attributes](https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes) are added by this instrumentation according to the spec.
|
|
12
12
|
- OpenTelemetry trace context is injected as SQS MessageAttributes, so the service receiving the message can link cascading spans to the trace which created the message.
|
|
13
13
|
|
|
14
14
|
### receiveMessage
|
|
15
15
|
|
|
16
|
-
- [Messaging Attributes](https://
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
Those processing spans are created by the library. This behavior is partially implemented, [See discussion below](#processing-spans).
|
|
20
|
-
- Sets the inter process context correctly, so that additional spans created through the process will be linked to parent spans correctly.
|
|
21
|
-
This behavior is partially implemented, [See discussion below](#processing-spans).
|
|
16
|
+
- [Messaging Attributes](https://opentelemetry.io/docs/specs/semconv/messaging/messaging-spans/#messaging-attributes) are added by this instrumentation according to the spec.
|
|
17
|
+
- Sets the inter process context correctly, so that additional spans created through the process will be linked to parent spans correctly.
|
|
18
|
+
When multiple messages are received, the instrumentation will attach spank links to the receiving span containing the trace context and message ID of each message.
|
|
22
19
|
- Extract trace context from SQS MessageAttributes, and set span's `parent` and `links` correctly according to the spec.
|
|
23
|
-
|
|
24
|
-
#### Processing Spans
|
|
25
|
-
|
|
26
|
-
See GH issue [here](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/707)
|
|
27
|
-
|
|
28
|
-
According to OpenTelemetry specification (and to reasonable expectation for trace structure), user of this library would expect to see one span for the operation of receiving messages batch from SQS, and then, **for each message**, a span with it's own sub-tree for the processing of this specific message.
|
|
29
|
-
|
|
30
|
-
For example, if a `receiveMessages` returned 2 messages:
|
|
31
|
-
|
|
32
|
-
- `msg1` resulting in storing something to a DB.
|
|
33
|
-
- `msg2` resulting in calling an external HTTP endpoint.
|
|
34
|
-
|
|
35
|
-
This will result in a creating a DB span that would be the child of `msg1` process span, and an HTTP span that would be the child of `msg2` process span (in opposed to mixing all those operations under the single `receive` span, or start a new trace for each of them).
|
|
36
|
-
|
|
37
|
-
Unfortunately, this is not so easy to implement in JS:
|
|
38
|
-
|
|
39
|
-
1. The SDK is calling a single callback for the messages batch, and it's not straightforward to understand when each individual message processing starts and ends (and set the context correctly for cascading spans).
|
|
40
|
-
2. If async/await is used, context can be lost when returning data from async functions, for example:
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
async function asyncRecv() {
|
|
44
|
-
const data = await sqs.receiveMessage(recvParams).promise();
|
|
45
|
-
// context of receiveMessage is set here
|
|
46
|
-
return data;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async function poll() {
|
|
50
|
-
const result = await asyncRecv();
|
|
51
|
-
// context is lost when asyncRecv returns. following spans are created with root context.
|
|
52
|
-
await Promise.all(
|
|
53
|
-
result.Messages.map((message) => this.processMessage(message))
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Current implementation partially solves this issue by patching the `map` \ `forEach` \ `Filter` functions on the `Messages` array of `receiveMessage` result. This handles issues like the one above, but will not handle situations where the processing is done in other patterns (multiple map\forEach calls, index access to the array, other array operations, etc). This is currently an open issue in the instrumentation.
|
|
59
|
-
|
|
60
|
-
User can add custom attributes to the `process` span, by setting a function to `sqsProcessHook` in instrumentation config. For example:
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
awsInstrumentationConfig = {
|
|
64
|
-
sqsProcessHook: (span, message) => {
|
|
65
|
-
span.setAttribute("sqs.receipt_handle", message.params?.ReceiptHandle);
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/instrumentation-aws-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"description": "OpenTelemetry instrumentation for `aws-sdk` and `@aws-sdk/client-*` clients for various AWS services",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aws",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"clean": "rimraf build/*",
|
|
35
|
-
"
|
|
35
|
+
"compile:with-dependencies": "nx run-many -t compile -p @opentelemetry/instrumentation-aws-sdk",
|
|
36
36
|
"compile": "tsc -p .",
|
|
37
|
-
"lint": "eslint . --ext
|
|
38
|
-
"lint:fix": "eslint . --ext
|
|
37
|
+
"lint": "eslint . --ext=ts,js,mjs",
|
|
38
|
+
"lint:fix": "eslint . --ext=ts,js,mjs --fix",
|
|
39
39
|
"lint:readme": "node ../../scripts/lint-readme.js",
|
|
40
40
|
"prepublishOnly": "npm run compile",
|
|
41
41
|
"tdd": "npm run test -- --watch-extensions ts --watch",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@opentelemetry/core": "^2.0.0",
|
|
52
52
|
"@opentelemetry/instrumentation": "^0.203.0",
|
|
53
|
-
"@opentelemetry/propagation-utils": "^0.31.3",
|
|
54
53
|
"@opentelemetry/semantic-conventions": "^1.34.0"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
@@ -59,13 +58,15 @@
|
|
|
59
58
|
"@aws-sdk/client-kinesis": "^3.85.0",
|
|
60
59
|
"@aws-sdk/client-lambda": "^3.85.0",
|
|
61
60
|
"@aws-sdk/client-s3": "^3.85.0",
|
|
61
|
+
"@aws-sdk/client-secrets-manager": "^3.85.0",
|
|
62
|
+
"@aws-sdk/client-sfn": "^3.85.0",
|
|
62
63
|
"@aws-sdk/client-sns": "^3.85.0",
|
|
63
64
|
"@aws-sdk/client-sqs": "^3.85.0",
|
|
64
65
|
"@aws-sdk/types": "^3.370.0",
|
|
65
66
|
"@opentelemetry/api": "^1.3.0",
|
|
66
67
|
"@opentelemetry/contrib-test-utils": "^0.49.0",
|
|
67
68
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
68
|
-
"@smithy/node-http-handler": "
|
|
69
|
+
"@smithy/node-http-handler": "4.1.1",
|
|
69
70
|
"@types/mocha": "10.0.10",
|
|
70
71
|
"@types/node": "18.18.14",
|
|
71
72
|
"@types/sinon": "17.0.4",
|
|
@@ -81,5 +82,5 @@
|
|
|
81
82
|
"engines": {
|
|
82
83
|
"node": "^18.19.0 || >=20.6.0"
|
|
83
84
|
},
|
|
84
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "5861c1dd6dd15a9d450a9f7d6d6616d533cc9a59"
|
|
85
86
|
}
|