autotel-aws 0.2.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/LICENSE +21 -0
- package/README.md +540 -0
- package/dist/attributes.cjs +49 -0
- package/dist/attributes.cjs.map +1 -0
- package/dist/attributes.d.cts +117 -0
- package/dist/attributes.d.ts +117 -0
- package/dist/attributes.js +4 -0
- package/dist/attributes.js.map +1 -0
- package/dist/chunk-35F3UBOO.cjs +48 -0
- package/dist/chunk-35F3UBOO.cjs.map +1 -0
- package/dist/chunk-4TGVGEUN.cjs +84 -0
- package/dist/chunk-4TGVGEUN.cjs.map +1 -0
- package/dist/chunk-CIGXV6HA.js +192 -0
- package/dist/chunk-CIGXV6HA.js.map +1 -0
- package/dist/chunk-D5INYMRP.cjs +350 -0
- package/dist/chunk-D5INYMRP.cjs.map +1 -0
- package/dist/chunk-DF5PT3JK.js +387 -0
- package/dist/chunk-DF5PT3JK.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +10 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-DHHLKZHI.cjs +23 -0
- package/dist/chunk-DHHLKZHI.cjs.map +1 -0
- package/dist/chunk-FKZOELBT.js +78 -0
- package/dist/chunk-FKZOELBT.js.map +1 -0
- package/dist/chunk-HMTKKKKP.cjs +390 -0
- package/dist/chunk-HMTKKKKP.cjs.map +1 -0
- package/dist/chunk-I4CKQ4RD.js +153 -0
- package/dist/chunk-I4CKQ4RD.js.map +1 -0
- package/dist/chunk-JEQ2X3Z6.cjs +12 -0
- package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
- package/dist/chunk-JMSFE6FJ.js +24 -0
- package/dist/chunk-JMSFE6FJ.js.map +1 -0
- package/dist/chunk-KUIOI74B.cjs +394 -0
- package/dist/chunk-KUIOI74B.cjs.map +1 -0
- package/dist/chunk-NQ65Y5AI.cjs +195 -0
- package/dist/chunk-NQ65Y5AI.cjs.map +1 -0
- package/dist/chunk-OB4XTAVK.cjs +345 -0
- package/dist/chunk-OB4XTAVK.cjs.map +1 -0
- package/dist/chunk-OHFR7WX5.js +341 -0
- package/dist/chunk-OHFR7WX5.js.map +1 -0
- package/dist/chunk-PZGYL7XZ.js +40 -0
- package/dist/chunk-PZGYL7XZ.js.map +1 -0
- package/dist/chunk-Q3DMMQ7K.cjs +164 -0
- package/dist/chunk-Q3DMMQ7K.cjs.map +1 -0
- package/dist/chunk-UZEJV2YD.cjs +139 -0
- package/dist/chunk-UZEJV2YD.cjs.map +1 -0
- package/dist/chunk-V4IQWFYN.js +341 -0
- package/dist/chunk-V4IQWFYN.js.map +1 -0
- package/dist/chunk-VZHQH75L.cjs +26 -0
- package/dist/chunk-VZHQH75L.cjs.map +1 -0
- package/dist/chunk-X6BY6PCK.js +386 -0
- package/dist/chunk-X6BY6PCK.js.map +1 -0
- package/dist/chunk-YG56NRIO.js +131 -0
- package/dist/chunk-YG56NRIO.js.map +1 -0
- package/dist/chunk-ZPDRKCAR.js +21 -0
- package/dist/chunk-ZPDRKCAR.js.map +1 -0
- package/dist/config-C7zV8Zm6.d.cts +125 -0
- package/dist/config-DxjTT8jd.d.ts +125 -0
- package/dist/dynamodb.cjs +14 -0
- package/dist/dynamodb.cjs.map +1 -0
- package/dist/dynamodb.d.cts +93 -0
- package/dist/dynamodb.d.ts +93 -0
- package/dist/dynamodb.js +5 -0
- package/dist/dynamodb.js.map +1 -0
- package/dist/eventbridge.cjs +279 -0
- package/dist/eventbridge.cjs.map +1 -0
- package/dist/eventbridge.d.cts +360 -0
- package/dist/eventbridge.d.ts +360 -0
- package/dist/eventbridge.js +273 -0
- package/dist/eventbridge.js.map +1 -0
- package/dist/index.cjs +251 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +126 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/kinesis.cjs +23 -0
- package/dist/kinesis.cjs.map +1 -0
- package/dist/kinesis.d.cts +360 -0
- package/dist/kinesis.d.ts +360 -0
- package/dist/kinesis.js +6 -0
- package/dist/kinesis.js.map +1 -0
- package/dist/lambda-auto.cjs +19 -0
- package/dist/lambda-auto.cjs.map +1 -0
- package/dist/lambda-auto.d.cts +2 -0
- package/dist/lambda-auto.d.ts +2 -0
- package/dist/lambda-auto.js +17 -0
- package/dist/lambda-auto.js.map +1 -0
- package/dist/lambda.cjs +42 -0
- package/dist/lambda.cjs.map +1 -0
- package/dist/lambda.d.cts +231 -0
- package/dist/lambda.d.ts +231 -0
- package/dist/lambda.js +5 -0
- package/dist/lambda.js.map +1 -0
- package/dist/s3.cjs +14 -0
- package/dist/s3.cjs.map +1 -0
- package/dist/s3.d.cts +77 -0
- package/dist/s3.d.ts +77 -0
- package/dist/s3.js +5 -0
- package/dist/s3.js.map +1 -0
- package/dist/sdk.cjs +31 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.cts +155 -0
- package/dist/sdk.d.ts +155 -0
- package/dist/sdk.js +6 -0
- package/dist/sdk.js.map +1 -0
- package/dist/sns.cjs +19 -0
- package/dist/sns.cjs.map +1 -0
- package/dist/sns.d.cts +256 -0
- package/dist/sns.d.ts +256 -0
- package/dist/sns.js +6 -0
- package/dist/sns.js.map +1 -0
- package/dist/sqs.cjs +23 -0
- package/dist/sqs.cjs.map +1 -0
- package/dist/sqs.d.cts +384 -0
- package/dist/sqs.d.ts +384 -0
- package/dist/sqs.js +6 -0
- package/dist/sqs.js.map +1 -0
- package/dist/step-functions.cjs +35 -0
- package/dist/step-functions.cjs.map +1 -0
- package/dist/step-functions.d.cts +423 -0
- package/dist/step-functions.d.ts +423 -0
- package/dist/step-functions.js +6 -0
- package/dist/step-functions.js.map +1 -0
- package/dist/testing.cjs +61 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +39 -0
- package/dist/testing.d.ts +39 -0
- package/dist/testing.js +58 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-3_ak5jhy.d.cts +76 -0
- package/dist/types-3_ak5jhy.d.ts +76 -0
- package/dist/types-UiBv_I_M.d.ts +16 -0
- package/dist/types-kTFVdSqO.d.cts +16 -0
- package/dist/xray.cjs +26 -0
- package/dist/xray.cjs.map +1 -0
- package/dist/xray.d.cts +23 -0
- package/dist/xray.d.ts +23 -0
- package/dist/xray.js +5 -0
- package/dist/xray.js.map +1 -0
- package/package.json +184 -0
package/dist/sdk.d.cts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Client } from '@aws-sdk/smithy-client';
|
|
2
|
+
import { S as SDKInstrumentationConfig } from './config-C7zV8Zm6.cjs';
|
|
3
|
+
import './types-3_ak5jhy.cjs';
|
|
4
|
+
import '@opentelemetry/api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* AWS SDK v3 auto-instrumentation
|
|
8
|
+
*
|
|
9
|
+
* Provides multiple approaches for instrumenting AWS SDK v3 clients:
|
|
10
|
+
* 1. `instrumentSDK()` - Wrap an existing client instance
|
|
11
|
+
* 2. `createTracedClient()` - Create a pre-instrumented client
|
|
12
|
+
* 3. `autoInstrumentAWS()` - Globally patch all AWS SDK clients
|
|
13
|
+
*
|
|
14
|
+
* @example Basic instrumentation
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { instrumentSDK } from 'autotel-aws/sdk';
|
|
17
|
+
* import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
18
|
+
*
|
|
19
|
+
* const s3 = instrumentSDK(new S3Client({ region: 'us-east-1' }));
|
|
20
|
+
*
|
|
21
|
+
* // All send() calls are now traced
|
|
22
|
+
* await s3.send(new PutObjectCommand({ Bucket: 'my-bucket', Key: 'file.txt' }));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Instrument an existing AWS SDK v3 client
|
|
28
|
+
*
|
|
29
|
+
* Wraps the client's `send()` method to automatically create spans
|
|
30
|
+
* for all AWS API calls with proper semantic attributes.
|
|
31
|
+
*
|
|
32
|
+
* @param client - An AWS SDK v3 client instance
|
|
33
|
+
* @param config - Optional instrumentation configuration
|
|
34
|
+
* @returns The instrumented client (same instance, modified)
|
|
35
|
+
*
|
|
36
|
+
* @example Basic usage
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { instrumentSDK } from 'autotel-aws/sdk';
|
|
39
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
40
|
+
*
|
|
41
|
+
* const s3 = instrumentSDK(new S3Client({ region: 'us-east-1' }));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example With configuration
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const s3 = instrumentSDK(new S3Client({}), {
|
|
47
|
+
* service: 's3',
|
|
48
|
+
* captureRequest: true,
|
|
49
|
+
* captureResponse: true
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Semantic attributes set automatically:
|
|
55
|
+
* - `rpc.system` - 'aws-api'
|
|
56
|
+
* - `rpc.service` - AWS service name (e.g., 'S3', 'DynamoDB')
|
|
57
|
+
* - `rpc.method` - Operation name (e.g., 'GetObject', 'PutItem')
|
|
58
|
+
* - `aws.request_id` - AWS request ID from response
|
|
59
|
+
* - `http.status_code` - HTTP status code
|
|
60
|
+
*
|
|
61
|
+
* @see https://opentelemetry.io/docs/specs/semconv/cloud-providers/aws-sdk/
|
|
62
|
+
*/
|
|
63
|
+
declare function instrumentSDK<T extends Client<unknown, unknown, unknown, unknown>>(client: T, config?: SDKInstrumentationConfig): T;
|
|
64
|
+
/**
|
|
65
|
+
* Create a pre-instrumented AWS SDK v3 client
|
|
66
|
+
*
|
|
67
|
+
* Convenience factory that creates and instruments a client in one call.
|
|
68
|
+
*
|
|
69
|
+
* @param ClientClass - The AWS SDK client class constructor
|
|
70
|
+
* @param config - Client configuration merged with instrumentation config
|
|
71
|
+
* @returns A new instrumented client instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { createTracedClient } from 'autotel-aws/sdk';
|
|
76
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
77
|
+
* import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
78
|
+
*
|
|
79
|
+
* // Create instrumented clients
|
|
80
|
+
* const s3 = createTracedClient(S3Client, { region: 'us-east-1' });
|
|
81
|
+
* const dynamodb = createTracedClient(DynamoDBClient, {
|
|
82
|
+
* region: 'us-east-1',
|
|
83
|
+
* captureRequest: true
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare function createTracedClient<T extends new (...args: any[]) => Client<unknown, unknown, unknown, unknown>>(ClientClass: T, config?: SDKInstrumentationConfig & ConstructorParameters<T>[0]): InstanceType<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Auto-instrument all AWS SDK v3 clients globally
|
|
90
|
+
*
|
|
91
|
+
* Patches the AWS SDK's base Client class to automatically instrument
|
|
92
|
+
* all client instances created after this call. This is the most convenient
|
|
93
|
+
* approach but requires the AWS SDK to be installed.
|
|
94
|
+
*
|
|
95
|
+
* Call this once at application startup, before creating any clients.
|
|
96
|
+
*
|
|
97
|
+
* @param config - Optional default instrumentation configuration
|
|
98
|
+
*
|
|
99
|
+
* @example Basic usage
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { autoInstrumentAWS } from 'autotel-aws/sdk';
|
|
102
|
+
*
|
|
103
|
+
* // Call once at startup
|
|
104
|
+
* autoInstrumentAWS();
|
|
105
|
+
*
|
|
106
|
+
* // All subsequent clients are automatically instrumented
|
|
107
|
+
* const s3 = new S3Client({ region: 'us-east-1' });
|
|
108
|
+
* const dynamodb = new DynamoDBClient({ region: 'us-east-1' });
|
|
109
|
+
*
|
|
110
|
+
* // Both are traced automatically
|
|
111
|
+
* await s3.send(new GetObjectCommand({ Bucket: 'b', Key: 'k' }));
|
|
112
|
+
* await dynamodb.send(new GetItemCommand({ TableName: 't', Key: {} }));
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example With default configuration
|
|
116
|
+
* ```typescript
|
|
117
|
+
* autoInstrumentAWS({
|
|
118
|
+
* captureRequest: false,
|
|
119
|
+
* captureResponse: false
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* - This function is idempotent - calling it multiple times has no effect
|
|
125
|
+
* - Clients created before calling this function are NOT instrumented
|
|
126
|
+
* - Use `instrumentSDK()` for clients created before auto-instrumentation
|
|
127
|
+
* - Requires `@aws-sdk/smithy-client` to be installed (peer dependency)
|
|
128
|
+
*
|
|
129
|
+
* @throws Error if AWS SDK is not installed
|
|
130
|
+
*/
|
|
131
|
+
declare function autoInstrumentAWS(config?: SDKInstrumentationConfig): void;
|
|
132
|
+
/**
|
|
133
|
+
* Disable global auto-instrumentation
|
|
134
|
+
*
|
|
135
|
+
* Restores the original AWS SDK behavior. Useful for testing or
|
|
136
|
+
* when you need to disable instrumentation temporarily.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* import { autoInstrumentAWS, disableAutoInstrumentAWS } from 'autotel-aws/sdk';
|
|
141
|
+
*
|
|
142
|
+
* autoInstrumentAWS();
|
|
143
|
+
* // ... use instrumented clients ...
|
|
144
|
+
*
|
|
145
|
+
* disableAutoInstrumentAWS();
|
|
146
|
+
* // Subsequent operations are not traced
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare function disableAutoInstrumentAWS(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Check if global auto-instrumentation is enabled
|
|
152
|
+
*/
|
|
153
|
+
declare function isAutoInstrumentEnabled(): boolean;
|
|
154
|
+
|
|
155
|
+
export { SDKInstrumentationConfig, autoInstrumentAWS, createTracedClient, disableAutoInstrumentAWS, instrumentSDK, isAutoInstrumentEnabled };
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Client } from '@aws-sdk/smithy-client';
|
|
2
|
+
import { S as SDKInstrumentationConfig } from './config-DxjTT8jd.js';
|
|
3
|
+
import './types-3_ak5jhy.js';
|
|
4
|
+
import '@opentelemetry/api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* AWS SDK v3 auto-instrumentation
|
|
8
|
+
*
|
|
9
|
+
* Provides multiple approaches for instrumenting AWS SDK v3 clients:
|
|
10
|
+
* 1. `instrumentSDK()` - Wrap an existing client instance
|
|
11
|
+
* 2. `createTracedClient()` - Create a pre-instrumented client
|
|
12
|
+
* 3. `autoInstrumentAWS()` - Globally patch all AWS SDK clients
|
|
13
|
+
*
|
|
14
|
+
* @example Basic instrumentation
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { instrumentSDK } from 'autotel-aws/sdk';
|
|
17
|
+
* import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
18
|
+
*
|
|
19
|
+
* const s3 = instrumentSDK(new S3Client({ region: 'us-east-1' }));
|
|
20
|
+
*
|
|
21
|
+
* // All send() calls are now traced
|
|
22
|
+
* await s3.send(new PutObjectCommand({ Bucket: 'my-bucket', Key: 'file.txt' }));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Instrument an existing AWS SDK v3 client
|
|
28
|
+
*
|
|
29
|
+
* Wraps the client's `send()` method to automatically create spans
|
|
30
|
+
* for all AWS API calls with proper semantic attributes.
|
|
31
|
+
*
|
|
32
|
+
* @param client - An AWS SDK v3 client instance
|
|
33
|
+
* @param config - Optional instrumentation configuration
|
|
34
|
+
* @returns The instrumented client (same instance, modified)
|
|
35
|
+
*
|
|
36
|
+
* @example Basic usage
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { instrumentSDK } from 'autotel-aws/sdk';
|
|
39
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
40
|
+
*
|
|
41
|
+
* const s3 = instrumentSDK(new S3Client({ region: 'us-east-1' }));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example With configuration
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const s3 = instrumentSDK(new S3Client({}), {
|
|
47
|
+
* service: 's3',
|
|
48
|
+
* captureRequest: true,
|
|
49
|
+
* captureResponse: true
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* Semantic attributes set automatically:
|
|
55
|
+
* - `rpc.system` - 'aws-api'
|
|
56
|
+
* - `rpc.service` - AWS service name (e.g., 'S3', 'DynamoDB')
|
|
57
|
+
* - `rpc.method` - Operation name (e.g., 'GetObject', 'PutItem')
|
|
58
|
+
* - `aws.request_id` - AWS request ID from response
|
|
59
|
+
* - `http.status_code` - HTTP status code
|
|
60
|
+
*
|
|
61
|
+
* @see https://opentelemetry.io/docs/specs/semconv/cloud-providers/aws-sdk/
|
|
62
|
+
*/
|
|
63
|
+
declare function instrumentSDK<T extends Client<unknown, unknown, unknown, unknown>>(client: T, config?: SDKInstrumentationConfig): T;
|
|
64
|
+
/**
|
|
65
|
+
* Create a pre-instrumented AWS SDK v3 client
|
|
66
|
+
*
|
|
67
|
+
* Convenience factory that creates and instruments a client in one call.
|
|
68
|
+
*
|
|
69
|
+
* @param ClientClass - The AWS SDK client class constructor
|
|
70
|
+
* @param config - Client configuration merged with instrumentation config
|
|
71
|
+
* @returns A new instrumented client instance
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* import { createTracedClient } from 'autotel-aws/sdk';
|
|
76
|
+
* import { S3Client } from '@aws-sdk/client-s3';
|
|
77
|
+
* import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
78
|
+
*
|
|
79
|
+
* // Create instrumented clients
|
|
80
|
+
* const s3 = createTracedClient(S3Client, { region: 'us-east-1' });
|
|
81
|
+
* const dynamodb = createTracedClient(DynamoDBClient, {
|
|
82
|
+
* region: 'us-east-1',
|
|
83
|
+
* captureRequest: true
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare function createTracedClient<T extends new (...args: any[]) => Client<unknown, unknown, unknown, unknown>>(ClientClass: T, config?: SDKInstrumentationConfig & ConstructorParameters<T>[0]): InstanceType<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Auto-instrument all AWS SDK v3 clients globally
|
|
90
|
+
*
|
|
91
|
+
* Patches the AWS SDK's base Client class to automatically instrument
|
|
92
|
+
* all client instances created after this call. This is the most convenient
|
|
93
|
+
* approach but requires the AWS SDK to be installed.
|
|
94
|
+
*
|
|
95
|
+
* Call this once at application startup, before creating any clients.
|
|
96
|
+
*
|
|
97
|
+
* @param config - Optional default instrumentation configuration
|
|
98
|
+
*
|
|
99
|
+
* @example Basic usage
|
|
100
|
+
* ```typescript
|
|
101
|
+
* import { autoInstrumentAWS } from 'autotel-aws/sdk';
|
|
102
|
+
*
|
|
103
|
+
* // Call once at startup
|
|
104
|
+
* autoInstrumentAWS();
|
|
105
|
+
*
|
|
106
|
+
* // All subsequent clients are automatically instrumented
|
|
107
|
+
* const s3 = new S3Client({ region: 'us-east-1' });
|
|
108
|
+
* const dynamodb = new DynamoDBClient({ region: 'us-east-1' });
|
|
109
|
+
*
|
|
110
|
+
* // Both are traced automatically
|
|
111
|
+
* await s3.send(new GetObjectCommand({ Bucket: 'b', Key: 'k' }));
|
|
112
|
+
* await dynamodb.send(new GetItemCommand({ TableName: 't', Key: {} }));
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @example With default configuration
|
|
116
|
+
* ```typescript
|
|
117
|
+
* autoInstrumentAWS({
|
|
118
|
+
* captureRequest: false,
|
|
119
|
+
* captureResponse: false
|
|
120
|
+
* });
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* - This function is idempotent - calling it multiple times has no effect
|
|
125
|
+
* - Clients created before calling this function are NOT instrumented
|
|
126
|
+
* - Use `instrumentSDK()` for clients created before auto-instrumentation
|
|
127
|
+
* - Requires `@aws-sdk/smithy-client` to be installed (peer dependency)
|
|
128
|
+
*
|
|
129
|
+
* @throws Error if AWS SDK is not installed
|
|
130
|
+
*/
|
|
131
|
+
declare function autoInstrumentAWS(config?: SDKInstrumentationConfig): void;
|
|
132
|
+
/**
|
|
133
|
+
* Disable global auto-instrumentation
|
|
134
|
+
*
|
|
135
|
+
* Restores the original AWS SDK behavior. Useful for testing or
|
|
136
|
+
* when you need to disable instrumentation temporarily.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* import { autoInstrumentAWS, disableAutoInstrumentAWS } from 'autotel-aws/sdk';
|
|
141
|
+
*
|
|
142
|
+
* autoInstrumentAWS();
|
|
143
|
+
* // ... use instrumented clients ...
|
|
144
|
+
*
|
|
145
|
+
* disableAutoInstrumentAWS();
|
|
146
|
+
* // Subsequent operations are not traced
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare function disableAutoInstrumentAWS(): void;
|
|
150
|
+
/**
|
|
151
|
+
* Check if global auto-instrumentation is enabled
|
|
152
|
+
*/
|
|
153
|
+
declare function isAutoInstrumentEnabled(): boolean;
|
|
154
|
+
|
|
155
|
+
export { SDKInstrumentationConfig, autoInstrumentAWS, createTracedClient, disableAutoInstrumentAWS, instrumentSDK, isAutoInstrumentEnabled };
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { autoInstrumentAWS, createTracedClient, disableAutoInstrumentAWS, instrumentSDK, isAutoInstrumentEnabled } from './chunk-FKZOELBT.js';
|
|
2
|
+
import './chunk-YG56NRIO.js';
|
|
3
|
+
import './chunk-I4CKQ4RD.js';
|
|
4
|
+
import './chunk-DGUM43GV.js';
|
|
5
|
+
//# sourceMappingURL=sdk.js.map
|
|
6
|
+
//# sourceMappingURL=sdk.js.map
|
package/dist/sdk.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sdk.js"}
|
package/dist/sns.cjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkNQ65Y5AI_cjs = require('./chunk-NQ65Y5AI.cjs');
|
|
4
|
+
require('./chunk-UZEJV2YD.cjs');
|
|
5
|
+
require('./chunk-Q3DMMQ7K.cjs');
|
|
6
|
+
require('./chunk-JEQ2X3Z6.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "SNSPublisher", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkNQ65Y5AI_cjs.SNSPublisher; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "traceSNS", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkNQ65Y5AI_cjs.traceSNS; }
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=sns.cjs.map
|
|
19
|
+
//# sourceMappingURL=sns.cjs.map
|
package/dist/sns.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"sns.cjs"}
|
package/dist/sns.d.cts
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { TraceContext } from 'autotel';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SNS-specific instrumentation
|
|
5
|
+
*
|
|
6
|
+
* Provides semantic helpers for tracing SNS operations with proper OpenTelemetry
|
|
7
|
+
* messaging semantic conventions. Automatically sets `messaging.*` attributes.
|
|
8
|
+
*
|
|
9
|
+
* @example Publish to topic
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { traceSNS } from 'autotel-aws/sns';
|
|
12
|
+
* import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
|
|
13
|
+
*
|
|
14
|
+
* const sns = new SNSClient({});
|
|
15
|
+
*
|
|
16
|
+
* export const publishNotification = traceSNS({
|
|
17
|
+
* topicArn: 'arn:aws:sns:us-east-1:123456789:notifications'
|
|
18
|
+
* })(ctx => async (message: string, subject?: string) => {
|
|
19
|
+
* const result = await sns.send(new PublishCommand({
|
|
20
|
+
* TopicArn: 'arn:aws:sns:us-east-1:123456789:notifications',
|
|
21
|
+
* Message: message,
|
|
22
|
+
* Subject: subject
|
|
23
|
+
* }));
|
|
24
|
+
*
|
|
25
|
+
* if (result.MessageId) {
|
|
26
|
+
* ctx.setAttribute('messaging.message.id', result.MessageId);
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* return result;
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Usage: await publishNotification('User signed up', 'New User');
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Publish to mobile endpoint
|
|
36
|
+
* ```typescript
|
|
37
|
+
* export const sendPushNotification = traceSNS({
|
|
38
|
+
* operation: 'publish',
|
|
39
|
+
* topicArn: 'arn:aws:sns:us-east-1:123456789:app/APNS/my-app'
|
|
40
|
+
* })(ctx => async (endpointArn: string, payload: object) => {
|
|
41
|
+
* ctx.setAttribute('aws.sns.target_arn', endpointArn);
|
|
42
|
+
* return await sns.send(new PublishCommand({
|
|
43
|
+
* TargetArn: endpointArn,
|
|
44
|
+
* Message: JSON.stringify(payload),
|
|
45
|
+
* MessageStructure: 'json'
|
|
46
|
+
* }));
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* SNS operation configuration
|
|
53
|
+
*/
|
|
54
|
+
interface TraceSNSConfig {
|
|
55
|
+
/**
|
|
56
|
+
* SNS topic ARN
|
|
57
|
+
* Sets `messaging.destination.name` attribute.
|
|
58
|
+
*/
|
|
59
|
+
topicArn: string;
|
|
60
|
+
/**
|
|
61
|
+
* Operation type (defaults to 'publish')
|
|
62
|
+
*/
|
|
63
|
+
operation?: 'publish' | 'subscribe' | 'unsubscribe';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Trace SNS operations with semantic attributes
|
|
67
|
+
*
|
|
68
|
+
* Creates a traced function that automatically sets SNS messaging semantic attributes
|
|
69
|
+
* following OpenTelemetry conventions.
|
|
70
|
+
*
|
|
71
|
+
* @param config - SNS operation configuration
|
|
72
|
+
* @returns A higher-order function that wraps your SNS operation with tracing
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* Semantic attributes set automatically:
|
|
76
|
+
* - `messaging.system` - 'aws_sns'
|
|
77
|
+
* - `messaging.destination.name` - Topic ARN
|
|
78
|
+
* - `messaging.operation` - 'publish'
|
|
79
|
+
*
|
|
80
|
+
* Additional attributes you should set in your handler:
|
|
81
|
+
* - `messaging.message.id` - Message ID from response
|
|
82
|
+
* - `aws.sns.target_arn` - Target ARN for direct publishing
|
|
83
|
+
*
|
|
84
|
+
* @see https://opentelemetry.io/docs/specs/semconv/messaging/aws-sns/
|
|
85
|
+
*/
|
|
86
|
+
declare function traceSNS(config: TraceSNSConfig): <TArgs extends unknown[], TReturn>(fn: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>) => (...args: TArgs) => Promise<TReturn>;
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for SNS Publisher
|
|
89
|
+
*/
|
|
90
|
+
interface SNSPublisherConfig {
|
|
91
|
+
/**
|
|
92
|
+
* SNS Topic ARN
|
|
93
|
+
*/
|
|
94
|
+
topicArn: string;
|
|
95
|
+
/**
|
|
96
|
+
* Inject W3C Trace Context into message attributes
|
|
97
|
+
* Enables distributed tracing to SNS subscribers (e.g., Lambda, SQS)
|
|
98
|
+
* @default true
|
|
99
|
+
*/
|
|
100
|
+
injectTraceContext?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Optional service name for tracing
|
|
103
|
+
*/
|
|
104
|
+
service?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Message to publish via SNS Publisher
|
|
108
|
+
*/
|
|
109
|
+
interface SNSPublishMessage {
|
|
110
|
+
/**
|
|
111
|
+
* Message body (string or JSON for message structure)
|
|
112
|
+
*/
|
|
113
|
+
message: string;
|
|
114
|
+
/**
|
|
115
|
+
* Optional subject (for email/SMS subscriptions)
|
|
116
|
+
*/
|
|
117
|
+
subject?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Optional message attributes
|
|
120
|
+
*/
|
|
121
|
+
attributes?: Record<string, {
|
|
122
|
+
StringValue: string;
|
|
123
|
+
DataType: string;
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Optional target ARN for direct endpoint publishing
|
|
127
|
+
*/
|
|
128
|
+
targetArn?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Optional phone number for SMS
|
|
131
|
+
*/
|
|
132
|
+
phoneNumber?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Optional message structure ('json' for platform-specific messages)
|
|
135
|
+
*/
|
|
136
|
+
messageStructure?: 'json';
|
|
137
|
+
/**
|
|
138
|
+
* Optional message group ID (for FIFO topics)
|
|
139
|
+
*/
|
|
140
|
+
messageGroupId?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Optional deduplication ID (for FIFO topics)
|
|
143
|
+
*/
|
|
144
|
+
messageDeduplicationId?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* SNS Publisher with automatic trace context injection
|
|
148
|
+
*
|
|
149
|
+
* Wraps an SNS client to automatically:
|
|
150
|
+
* - Create spans for publish operations
|
|
151
|
+
* - Inject W3C Trace Context into message attributes
|
|
152
|
+
* - Set proper semantic attributes
|
|
153
|
+
*
|
|
154
|
+
* @example Basic usage
|
|
155
|
+
* ```typescript
|
|
156
|
+
* import { SNSPublisher } from 'autotel-aws/sns';
|
|
157
|
+
* import { SNSClient } from '@aws-sdk/client-sns';
|
|
158
|
+
*
|
|
159
|
+
* const sns = new SNSClient({ region: 'us-east-1' });
|
|
160
|
+
* const publisher = new SNSPublisher(sns, {
|
|
161
|
+
* topicArn: 'arn:aws:sns:us-east-1:123456789:my-topic'
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // Publish with automatic trace context
|
|
165
|
+
* const result = await publisher.publish({
|
|
166
|
+
* message: 'Order completed',
|
|
167
|
+
* subject: 'Order #12345'
|
|
168
|
+
* });
|
|
169
|
+
* console.log('Message ID:', result.messageId);
|
|
170
|
+
* ```
|
|
171
|
+
*
|
|
172
|
+
* @example With custom attributes
|
|
173
|
+
* ```typescript
|
|
174
|
+
* await publisher.publish({
|
|
175
|
+
* message: JSON.stringify({ orderId: '12345', status: 'completed' }),
|
|
176
|
+
* attributes: {
|
|
177
|
+
* 'eventType': { StringValue: 'ORDER_COMPLETED', DataType: 'String' },
|
|
178
|
+
* 'priority': { StringValue: 'high', DataType: 'String' }
|
|
179
|
+
* }
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example Batch publish
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const results = await publisher.publishBatch([
|
|
186
|
+
* { message: 'Event 1' },
|
|
187
|
+
* { message: 'Event 2' },
|
|
188
|
+
* { message: 'Event 3' }
|
|
189
|
+
* ]);
|
|
190
|
+
* console.log(`Published ${results.successful.length} messages`);
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example Direct endpoint publish
|
|
194
|
+
* ```typescript
|
|
195
|
+
* await publisher.publishToEndpoint({
|
|
196
|
+
* targetArn: 'arn:aws:sns:us-east-1:123456789:endpoint/APNS/my-app/device-token',
|
|
197
|
+
* message: JSON.stringify({
|
|
198
|
+
* APNS: JSON.stringify({ aps: { alert: 'Hello!' } })
|
|
199
|
+
* }),
|
|
200
|
+
* messageStructure: 'json'
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare class SNSPublisher<TClient extends {
|
|
205
|
+
send: (command: any) => Promise<any>;
|
|
206
|
+
} = any> {
|
|
207
|
+
private client;
|
|
208
|
+
private config;
|
|
209
|
+
private topicName;
|
|
210
|
+
constructor(client: TClient, config: SNSPublisherConfig);
|
|
211
|
+
/**
|
|
212
|
+
* Inject trace context into message attributes
|
|
213
|
+
*/
|
|
214
|
+
private injectContext;
|
|
215
|
+
/**
|
|
216
|
+
* Publish a message to the topic
|
|
217
|
+
*
|
|
218
|
+
* @param message - Message to publish
|
|
219
|
+
* @returns Promise with message ID and sequence number
|
|
220
|
+
*/
|
|
221
|
+
publish(message: SNSPublishMessage): Promise<{
|
|
222
|
+
messageId?: string;
|
|
223
|
+
sequenceNumber?: string;
|
|
224
|
+
}>;
|
|
225
|
+
/**
|
|
226
|
+
* Publish multiple messages in a batch
|
|
227
|
+
*
|
|
228
|
+
* @param messages - Array of messages to publish (max 10)
|
|
229
|
+
* @returns Promise with successful and failed message results
|
|
230
|
+
*/
|
|
231
|
+
publishBatch(messages: SNSPublishMessage[]): Promise<{
|
|
232
|
+
successful: Array<{
|
|
233
|
+
id: string;
|
|
234
|
+
messageId?: string;
|
|
235
|
+
sequenceNumber?: string;
|
|
236
|
+
}>;
|
|
237
|
+
failed: Array<{
|
|
238
|
+
id: string;
|
|
239
|
+
code?: string;
|
|
240
|
+
message?: string;
|
|
241
|
+
}>;
|
|
242
|
+
}>;
|
|
243
|
+
/**
|
|
244
|
+
* Publish to a specific endpoint (mobile push, etc.)
|
|
245
|
+
*
|
|
246
|
+
* @param message - Message with targetArn set
|
|
247
|
+
* @returns Promise with message ID
|
|
248
|
+
*/
|
|
249
|
+
publishToEndpoint(message: Omit<SNSPublishMessage, 'targetArn'> & {
|
|
250
|
+
targetArn: string;
|
|
251
|
+
}): Promise<{
|
|
252
|
+
messageId?: string;
|
|
253
|
+
}>;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export { type SNSPublishMessage, SNSPublisher, type SNSPublisherConfig, type TraceSNSConfig, traceSNS };
|