autotel-aws 0.13.13 → 0.13.14
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/dist/attributes.cjs +155 -46
- package/dist/attributes.cjs.map +1 -1
- package/dist/attributes.d.cts +64 -62
- package/dist/attributes.d.cts.map +1 -0
- package/dist/attributes.d.ts +64 -62
- package/dist/attributes.d.ts.map +1 -0
- package/dist/attributes.js +146 -3
- package/dist/attributes.js.map +1 -1
- package/dist/cloudwatch.cjs +324 -358
- package/dist/cloudwatch.cjs.map +1 -1
- package/dist/cloudwatch.d.cts +126 -153
- package/dist/cloudwatch.d.cts.map +1 -0
- package/dist/cloudwatch.d.ts +126 -153
- package/dist/cloudwatch.d.ts.map +1 -0
- package/dist/cloudwatch.js +323 -356
- package/dist/cloudwatch.js.map +1 -1
- package/dist/config-D8QZwF1e.d.ts +123 -0
- package/dist/config-D8QZwF1e.d.ts.map +1 -0
- package/dist/config-SPkMWWXY.d.cts +123 -0
- package/dist/config-SPkMWWXY.d.cts.map +1 -0
- package/dist/dynamodb.cjs +89 -11
- package/dist/dynamodb.cjs.map +1 -1
- package/dist/dynamodb.d.cts +15 -63
- package/dist/dynamodb.d.cts.map +1 -0
- package/dist/dynamodb.d.ts +15 -63
- package/dist/dynamodb.d.ts.map +1 -0
- package/dist/dynamodb.js +90 -4
- package/dist/dynamodb.js.map +1 -1
- package/dist/eventbridge.cjs +423 -261
- package/dist/eventbridge.cjs.map +1 -1
- package/dist/eventbridge.d.cts +113 -174
- package/dist/eventbridge.d.cts.map +1 -0
- package/dist/eventbridge.d.ts +113 -174
- package/dist/eventbridge.d.ts.map +1 -0
- package/dist/eventbridge.js +422 -259
- package/dist/eventbridge.js.map +1 -1
- package/dist/index.cjs +117 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +42 -55
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +42 -55
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -41
- package/dist/index.js.map +1 -1
- package/dist/kinesis.cjs +485 -20
- package/dist/kinesis.cjs.map +1 -1
- package/dist/kinesis.d.cts +179 -226
- package/dist/kinesis.d.cts.map +1 -0
- package/dist/kinesis.d.ts +179 -226
- package/dist/kinesis.d.ts.map +1 -0
- package/dist/kinesis.js +484 -5
- package/dist/kinesis.js.map +1 -1
- package/dist/lambda-B0LQa5vS.d.ts +168 -0
- package/dist/lambda-B0LQa5vS.d.ts.map +1 -0
- package/dist/lambda-DR33vPpL.cjs +500 -0
- package/dist/lambda-DR33vPpL.cjs.map +1 -0
- package/dist/lambda-DYyKH-f-.js +453 -0
- package/dist/lambda-DYyKH-f-.js.map +1 -0
- package/dist/lambda-DnroO4Od.d.cts +168 -0
- package/dist/lambda-DnroO4Od.d.cts.map +1 -0
- package/dist/lambda-auto.cjs +33 -16
- package/dist/lambda-auto.cjs.map +1 -1
- package/dist/lambda-auto.d.cts +1 -2
- package/dist/lambda-auto.d.ts +1 -2
- package/dist/lambda-auto.js +35 -15
- package/dist/lambda-auto.js.map +1 -1
- package/dist/lambda.cjs +11 -42
- package/dist/lambda.d.cts +3 -231
- package/dist/lambda.d.ts +3 -231
- package/dist/lambda.js +3 -5
- package/dist/s3.cjs +70 -11
- package/dist/s3.cjs.map +1 -1
- package/dist/s3.d.cts +15 -51
- package/dist/s3.d.cts.map +1 -0
- package/dist/s3.d.ts +15 -51
- package/dist/s3.d.ts.map +1 -0
- package/dist/s3.js +71 -4
- package/dist/s3.js.map +1 -1
- package/dist/sdk-C-o7ngkk.js +198 -0
- package/dist/sdk-C-o7ngkk.js.map +1 -0
- package/dist/sdk-C9Nvlh7R.cjs +222 -0
- package/dist/sdk-C9Nvlh7R.cjs.map +1 -0
- package/dist/sdk-CXqc4o_q.d.ts +135 -0
- package/dist/sdk-CXqc4o_q.d.ts.map +1 -0
- package/dist/sdk-DkAItj4z.d.cts +135 -0
- package/dist/sdk-DkAItj4z.d.cts.map +1 -0
- package/dist/sdk-wrapper-BDrcyEQ_.cjs +161 -0
- package/dist/sdk-wrapper-BDrcyEQ_.cjs.map +1 -0
- package/dist/sdk-wrapper-BVr62EfA.js +120 -0
- package/dist/sdk-wrapper-BVr62EfA.js.map +1 -0
- package/dist/sdk.cjs +8 -31
- package/dist/sdk.d.cts +3 -156
- package/dist/sdk.d.ts +3 -156
- package/dist/sdk.js +3 -6
- package/dist/sns.cjs +305 -16
- package/dist/sns.cjs.map +1 -1
- package/dist/sns.d.cts +109 -155
- package/dist/sns.d.cts.map +1 -0
- package/dist/sns.d.ts +109 -155
- package/dist/sns.d.ts.map +1 -0
- package/dist/sns.js +305 -5
- package/dist/sns.js.map +1 -1
- package/dist/sqs.cjs +455 -20
- package/dist/sqs.cjs.map +1 -1
- package/dist/sqs.d.cts +191 -240
- package/dist/sqs.d.cts.map +1 -0
- package/dist/sqs.d.ts +191 -240
- package/dist/sqs.d.ts.map +1 -0
- package/dist/sqs.js +454 -5
- package/dist/sqs.js.map +1 -1
- package/dist/step-functions.cjs +557 -32
- package/dist/step-functions.cjs.map +1 -1
- package/dist/step-functions.d.cts +155 -210
- package/dist/step-functions.d.cts.map +1 -0
- package/dist/step-functions.d.ts +155 -210
- package/dist/step-functions.d.ts.map +1 -0
- package/dist/step-functions.js +553 -5
- package/dist/step-functions.js.map +1 -1
- package/dist/testing.cjs +60 -58
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +20 -23
- package/dist/testing.d.cts.map +1 -0
- package/dist/testing.d.ts +20 -23
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +59 -57
- package/dist/testing.js.map +1 -1
- package/dist/{types-B2Mi8Goj.d.cts → types-0uHbJsBN.d.ts} +5 -7
- package/dist/types-0uHbJsBN.d.ts.map +1 -0
- package/dist/types-DOUDks8I.d.cts +71 -0
- package/dist/types-DOUDks8I.d.cts.map +1 -0
- package/dist/types-DOUDks8I.d.ts +71 -0
- package/dist/types-DOUDks8I.d.ts.map +1 -0
- package/dist/{types-BqTI4s4V.d.ts → types-iyHj03Q1.d.cts} +5 -7
- package/dist/types-iyHj03Q1.d.cts.map +1 -0
- package/dist/xray-B46i6z6K.js +59 -0
- package/dist/xray-B46i6z6K.js.map +1 -0
- package/dist/xray-CG4jciQs.d.ts +19 -0
- package/dist/xray-CG4jciQs.d.ts.map +1 -0
- package/dist/xray-Cd2UiVRA.cjs +75 -0
- package/dist/xray-Cd2UiVRA.cjs.map +1 -0
- package/dist/xray-DDcKCKKo.d.cts +19 -0
- package/dist/xray-DDcKCKKo.d.cts.map +1 -0
- package/dist/xray.cjs +10 -23
- package/dist/xray.d.cts +3 -24
- package/dist/xray.d.ts +3 -24
- package/dist/xray.js +3 -5
- package/package.json +5 -5
- package/dist/chunk-35F3UBOO.cjs +0 -48
- package/dist/chunk-35F3UBOO.cjs.map +0 -1
- package/dist/chunk-4THGOYZL.js +0 -387
- package/dist/chunk-4THGOYZL.js.map +0 -1
- package/dist/chunk-CIGXV6HA.js +0 -192
- package/dist/chunk-CIGXV6HA.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -10
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-DHHLKZHI.cjs +0 -23
- package/dist/chunk-DHHLKZHI.cjs.map +0 -1
- package/dist/chunk-HMTKKKKP.cjs +0 -390
- package/dist/chunk-HMTKKKKP.cjs.map +0 -1
- package/dist/chunk-I4CKQ4RD.js +0 -153
- package/dist/chunk-I4CKQ4RD.js.map +0 -1
- package/dist/chunk-JEQ2X3Z6.cjs +0 -12
- package/dist/chunk-JEQ2X3Z6.cjs.map +0 -1
- package/dist/chunk-JL33WEVE.js +0 -341
- package/dist/chunk-JL33WEVE.js.map +0 -1
- package/dist/chunk-JMSFE6FJ.js +0 -24
- package/dist/chunk-JMSFE6FJ.js.map +0 -1
- package/dist/chunk-JPDJPOIB.js +0 -78
- package/dist/chunk-JPDJPOIB.js.map +0 -1
- package/dist/chunk-KNRQYDAS.cjs +0 -394
- package/dist/chunk-KNRQYDAS.cjs.map +0 -1
- package/dist/chunk-NQ65Y5AI.cjs +0 -195
- package/dist/chunk-NQ65Y5AI.cjs.map +0 -1
- package/dist/chunk-OB4XTAVK.cjs +0 -345
- package/dist/chunk-OB4XTAVK.cjs.map +0 -1
- package/dist/chunk-OHFR7WX5.js +0 -341
- package/dist/chunk-OHFR7WX5.js.map +0 -1
- package/dist/chunk-PZGYL7XZ.js +0 -40
- package/dist/chunk-PZGYL7XZ.js.map +0 -1
- package/dist/chunk-Q3DMMQ7K.cjs +0 -164
- package/dist/chunk-Q3DMMQ7K.cjs.map +0 -1
- package/dist/chunk-SPC4VYOI.cjs +0 -350
- package/dist/chunk-SPC4VYOI.cjs.map +0 -1
- package/dist/chunk-UZEJV2YD.cjs +0 -139
- package/dist/chunk-UZEJV2YD.cjs.map +0 -1
- package/dist/chunk-VZHQH75L.cjs +0 -26
- package/dist/chunk-VZHQH75L.cjs.map +0 -1
- package/dist/chunk-X6BY6PCK.js +0 -386
- package/dist/chunk-X6BY6PCK.js.map +0 -1
- package/dist/chunk-XOF2H2PI.cjs +0 -84
- package/dist/chunk-XOF2H2PI.cjs.map +0 -1
- package/dist/chunk-YG56NRIO.js +0 -131
- package/dist/chunk-YG56NRIO.js.map +0 -1
- package/dist/chunk-ZPDRKCAR.js +0 -21
- package/dist/chunk-ZPDRKCAR.js.map +0 -1
- package/dist/config-DbZv4bpy.d.ts +0 -125
- package/dist/config-srkLBXZH.d.cts +0 -125
- package/dist/lambda.cjs.map +0 -1
- package/dist/lambda.js.map +0 -1
- package/dist/sdk.cjs.map +0 -1
- package/dist/sdk.js.map +0 -1
- package/dist/types-B9IaHmGa.d.cts +0 -73
- package/dist/types-B9IaHmGa.d.ts +0 -73
- package/dist/xray.cjs.map +0 -1
- package/dist/xray.js.map +0 -1
package/dist/cloudwatch.cjs
CHANGED
|
@@ -1,389 +1,356 @@
|
|
|
1
|
-
'
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _opentelemetry_core = require("@opentelemetry/core");
|
|
3
|
+
let _opentelemetry_otlp_transformer = require("@opentelemetry/otlp-transformer");
|
|
4
|
+
let _opentelemetry_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var otlpTransformer = require('@opentelemetry/otlp-transformer');
|
|
6
|
-
var sdkMetrics = require('@opentelemetry/sdk-metrics');
|
|
7
|
-
|
|
8
|
-
// src/cloudwatch/endpoints.ts
|
|
6
|
+
//#region src/cloudwatch/endpoints.ts
|
|
7
|
+
/** Traces — signed against the `xray` service. */
|
|
9
8
|
function cloudWatchTracesEndpoint({ region }) {
|
|
10
|
-
|
|
9
|
+
return `https://xray.${region}.amazonaws.com/v1/traces`;
|
|
11
10
|
}
|
|
11
|
+
/** Logs — signed against the `logs` service. Requires log group/stream headers. */
|
|
12
12
|
function cloudWatchLogsEndpoint({ region }) {
|
|
13
|
-
|
|
13
|
+
return `https://logs.${region}.amazonaws.com/v1/logs`;
|
|
14
14
|
}
|
|
15
|
+
/** Metrics — signed against the `monitoring` service. */
|
|
15
16
|
function cloudWatchMetricsEndpoint({ region }) {
|
|
16
|
-
|
|
17
|
+
return `https://monitoring.${region}.amazonaws.com/v1/metrics`;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The SigV4 service name used when signing requests for each endpoint.
|
|
21
|
+
* These do NOT always match the host prefix — they're the canonical
|
|
22
|
+
* AWS service identifiers used by the SigV4 signer.
|
|
23
|
+
*/
|
|
24
|
+
const SIGV4_SERVICE = {
|
|
25
|
+
traces: "xray",
|
|
26
|
+
logs: "logs",
|
|
27
|
+
metrics: "monitoring"
|
|
22
28
|
};
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/cloudwatch/sigv4.ts
|
|
32
|
+
/**
|
|
33
|
+
* Compute SigV4-signed headers for an OTLP HTTP POST to a CloudWatch endpoint.
|
|
34
|
+
*
|
|
35
|
+
* Throws if the optional `@smithy/signature-v4` / `@aws-crypto/sha256-js`
|
|
36
|
+
* peer dependencies aren't installed — install them alongside autotel-aws
|
|
37
|
+
* when you want to ship telemetry directly from app code (no collector).
|
|
38
|
+
*/
|
|
25
39
|
async function signCloudWatchOtlpRequest(input) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
return signed.headers;
|
|
40
|
+
const { SignatureV4 } = await loadSigV4();
|
|
41
|
+
const { Sha256 } = await loadSha256();
|
|
42
|
+
const credentials = await resolveCredentials(input.credentials);
|
|
43
|
+
const parsed = new URL(input.url);
|
|
44
|
+
const contentType = input.contentType ?? "application/json";
|
|
45
|
+
const headers = {
|
|
46
|
+
host: parsed.host,
|
|
47
|
+
"content-type": contentType,
|
|
48
|
+
...input.contentEncoding && { "content-encoding": input.contentEncoding },
|
|
49
|
+
...input.additionalHeaders
|
|
50
|
+
};
|
|
51
|
+
return (await new SignatureV4({
|
|
52
|
+
service: SIGV4_SERVICE[input.signal],
|
|
53
|
+
region: input.region,
|
|
54
|
+
credentials,
|
|
55
|
+
sha256: Sha256
|
|
56
|
+
}).sign({
|
|
57
|
+
method: "POST",
|
|
58
|
+
protocol: parsed.protocol,
|
|
59
|
+
hostname: parsed.hostname,
|
|
60
|
+
port: parsed.port ? Number(parsed.port) : void 0,
|
|
61
|
+
path: parsed.pathname + parsed.search,
|
|
62
|
+
headers,
|
|
63
|
+
body: input.body
|
|
64
|
+
})).headers;
|
|
53
65
|
}
|
|
54
66
|
async function resolveCredentials(source) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
if (typeof source === "function") return source();
|
|
68
|
+
if (source) return source;
|
|
69
|
+
return loadDefaultCredentials();
|
|
58
70
|
}
|
|
59
71
|
async function loadDefaultCredentials() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"autotel-aws/cloudwatch: no credentials supplied and `@aws-sdk/credential-providers` is not installed. Either pass `credentials` explicitly or install the package.",
|
|
66
|
-
{ cause: error }
|
|
67
|
-
);
|
|
68
|
-
}
|
|
72
|
+
try {
|
|
73
|
+
return await (await import("@aws-sdk/credential-providers")).fromNodeProviderChain()();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
throw new Error("autotel-aws/cloudwatch: no credentials supplied and `@aws-sdk/credential-providers` is not installed. Either pass `credentials` explicitly or install the package.", { cause: error });
|
|
76
|
+
}
|
|
69
77
|
}
|
|
70
78
|
async function loadSigV4() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{ cause: error }
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
+
try {
|
|
80
|
+
return await import("@smithy/signature-v4");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error("autotel-aws/cloudwatch: `@smithy/signature-v4` is required to sign OTLP requests. Install it (and `@aws-crypto/sha256-js`) alongside autotel-aws.", { cause: error });
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
async function loadSha256() {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{ cause: error }
|
|
87
|
-
);
|
|
88
|
-
}
|
|
86
|
+
try {
|
|
87
|
+
return await import("@aws-crypto/sha256-js");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
throw new Error("autotel-aws/cloudwatch: `@aws-crypto/sha256-js` is required to sign OTLP requests. Install it alongside `@smithy/signature-v4`.", { cause: error });
|
|
90
|
+
}
|
|
89
91
|
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/cloudwatch/trace-exporter.ts
|
|
95
|
+
/**
|
|
96
|
+
* OTLP/JSON exporter for CloudWatch's traces endpoint.
|
|
97
|
+
*
|
|
98
|
+
* Use with `BatchSpanProcessor` or `SimpleSpanProcessor` from
|
|
99
|
+
* `@opentelemetry/sdk-trace-base`. For Lambda, `SimpleSpanProcessor`
|
|
100
|
+
* (synchronous export per span) is fine for small workloads;
|
|
101
|
+
* `BatchSpanProcessor` is better for higher-throughput functions but
|
|
102
|
+
* needs `forceFlush()` before the handler returns.
|
|
103
|
+
*/
|
|
90
104
|
var CloudWatchTraceExporter = class {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
response = await this.fetchImpl(this.endpoint, {
|
|
158
|
-
method: "POST",
|
|
159
|
-
headers,
|
|
160
|
-
body,
|
|
161
|
-
signal: controller.signal
|
|
162
|
-
});
|
|
163
|
-
} finally {
|
|
164
|
-
clearTimeout(timer);
|
|
165
|
-
}
|
|
166
|
-
if (!response.ok) {
|
|
167
|
-
const text = await safeReadText(response);
|
|
168
|
-
throw new Error(
|
|
169
|
-
`CloudWatchTraceExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim()
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
105
|
+
region;
|
|
106
|
+
endpoint;
|
|
107
|
+
credentials;
|
|
108
|
+
timeoutMs;
|
|
109
|
+
fetchImpl;
|
|
110
|
+
shutdownOnce = false;
|
|
111
|
+
constructor(config = {}) {
|
|
112
|
+
const region = config.region ?? process.env.AWS_REGION;
|
|
113
|
+
if (!region) throw new Error("CloudWatchTraceExporter: `region` is required (pass it explicitly or set AWS_REGION).");
|
|
114
|
+
this.region = region;
|
|
115
|
+
this.endpoint = config.endpoint ?? cloudWatchTracesEndpoint({ region });
|
|
116
|
+
this.credentials = config.credentials;
|
|
117
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
118
|
+
this.fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
119
|
+
if (typeof this.fetchImpl !== "function") throw new TypeError("CloudWatchTraceExporter: global `fetch` is not available — pass `fetchImpl` explicitly (Node 18+ has it natively).");
|
|
120
|
+
}
|
|
121
|
+
export(spans, resultCallback) {
|
|
122
|
+
if (this.shutdownOnce) {
|
|
123
|
+
resultCallback({
|
|
124
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
125
|
+
error: /* @__PURE__ */ new Error("CloudWatchTraceExporter: already shut down")
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (spans.length === 0) {
|
|
130
|
+
resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this.sendBatch(spans).then(() => resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS }), (error) => resultCallback({
|
|
134
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
135
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
async shutdown() {
|
|
139
|
+
this.shutdownOnce = true;
|
|
140
|
+
}
|
|
141
|
+
async forceFlush() {}
|
|
142
|
+
async sendBatch(spans) {
|
|
143
|
+
const body = _opentelemetry_otlp_transformer.JsonTraceSerializer.serializeRequest(spans);
|
|
144
|
+
if (!body) throw new Error("CloudWatchTraceExporter: serializer produced no body");
|
|
145
|
+
const headers = await signCloudWatchOtlpRequest({
|
|
146
|
+
url: this.endpoint,
|
|
147
|
+
body,
|
|
148
|
+
region: this.region,
|
|
149
|
+
signal: "traces",
|
|
150
|
+
credentials: this.credentials,
|
|
151
|
+
contentType: "application/json"
|
|
152
|
+
});
|
|
153
|
+
const controller = new AbortController();
|
|
154
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
155
|
+
let response;
|
|
156
|
+
try {
|
|
157
|
+
response = await this.fetchImpl(this.endpoint, {
|
|
158
|
+
method: "POST",
|
|
159
|
+
headers,
|
|
160
|
+
body,
|
|
161
|
+
signal: controller.signal
|
|
162
|
+
});
|
|
163
|
+
} finally {
|
|
164
|
+
clearTimeout(timer);
|
|
165
|
+
}
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
const text = await safeReadText$2(response);
|
|
168
|
+
throw new Error(`CloudWatchTraceExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim());
|
|
169
|
+
}
|
|
170
|
+
}
|
|
173
171
|
};
|
|
174
|
-
async function safeReadText(response) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
172
|
+
async function safeReadText$2(response) {
|
|
173
|
+
try {
|
|
174
|
+
return await response.text();
|
|
175
|
+
} catch {
|
|
176
|
+
return "";
|
|
177
|
+
}
|
|
180
178
|
}
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/cloudwatch/log-exporter.ts
|
|
181
182
|
var CloudWatchLogExporter = class {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
additionalHeaders
|
|
264
|
-
});
|
|
265
|
-
const controller = new AbortController();
|
|
266
|
-
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
267
|
-
let response;
|
|
268
|
-
try {
|
|
269
|
-
response = await this.fetchImpl(this.endpoint, {
|
|
270
|
-
method: "POST",
|
|
271
|
-
headers,
|
|
272
|
-
body,
|
|
273
|
-
signal: controller.signal
|
|
274
|
-
});
|
|
275
|
-
} finally {
|
|
276
|
-
clearTimeout(timer);
|
|
277
|
-
}
|
|
278
|
-
if (!response.ok) {
|
|
279
|
-
const text = await safeReadText2(response);
|
|
280
|
-
throw new Error(
|
|
281
|
-
`CloudWatchLogExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim()
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
183
|
+
region;
|
|
184
|
+
endpoint;
|
|
185
|
+
credentials;
|
|
186
|
+
logGroup;
|
|
187
|
+
logStream;
|
|
188
|
+
truncatableFields;
|
|
189
|
+
timeoutMs;
|
|
190
|
+
fetchImpl;
|
|
191
|
+
shutdownOnce = false;
|
|
192
|
+
constructor(config = {}) {
|
|
193
|
+
const region = config.region ?? process.env.AWS_REGION;
|
|
194
|
+
if (!region) throw new Error("CloudWatchLogExporter: `region` is required (pass it explicitly or set AWS_REGION).");
|
|
195
|
+
const logGroup = config.logGroup ?? process.env.AWS_LAMBDA_LOG_GROUP_NAME;
|
|
196
|
+
const logStream = config.logStream ?? process.env.AWS_LAMBDA_LOG_STREAM_NAME;
|
|
197
|
+
if (!logGroup || !logStream) throw new Error("CloudWatchLogExporter: `logGroup` and `logStream` are required (in Lambda they come from AWS_LAMBDA_LOG_GROUP_NAME / AWS_LAMBDA_LOG_STREAM_NAME).");
|
|
198
|
+
this.region = region;
|
|
199
|
+
this.endpoint = config.endpoint ?? cloudWatchLogsEndpoint({ region });
|
|
200
|
+
this.credentials = config.credentials;
|
|
201
|
+
this.logGroup = logGroup;
|
|
202
|
+
this.logStream = logStream;
|
|
203
|
+
this.truncatableFields = config.truncatableFields;
|
|
204
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
205
|
+
this.fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
206
|
+
if (typeof this.fetchImpl !== "function") throw new TypeError("CloudWatchLogExporter: global `fetch` is not available — pass `fetchImpl` explicitly.");
|
|
207
|
+
}
|
|
208
|
+
export(logs, resultCallback) {
|
|
209
|
+
if (this.shutdownOnce) {
|
|
210
|
+
resultCallback({
|
|
211
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
212
|
+
error: /* @__PURE__ */ new Error("CloudWatchLogExporter: already shut down")
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (logs.length === 0) {
|
|
217
|
+
resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS });
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.sendBatch(logs).then(() => resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS }), (error) => resultCallback({
|
|
221
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
222
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
async shutdown() {
|
|
226
|
+
this.shutdownOnce = true;
|
|
227
|
+
}
|
|
228
|
+
async forceFlush() {}
|
|
229
|
+
async sendBatch(logs) {
|
|
230
|
+
const body = _opentelemetry_otlp_transformer.JsonLogsSerializer.serializeRequest(logs);
|
|
231
|
+
if (!body) throw new Error("CloudWatchLogExporter: serializer produced no body");
|
|
232
|
+
const additionalHeaders = {
|
|
233
|
+
"x-aws-log-group": this.logGroup,
|
|
234
|
+
"x-aws-log-stream": this.logStream
|
|
235
|
+
};
|
|
236
|
+
if (this.truncatableFields) additionalHeaders["x-aws-truncatable-fields"] = this.truncatableFields;
|
|
237
|
+
const headers = await signCloudWatchOtlpRequest({
|
|
238
|
+
url: this.endpoint,
|
|
239
|
+
body,
|
|
240
|
+
region: this.region,
|
|
241
|
+
signal: "logs",
|
|
242
|
+
credentials: this.credentials,
|
|
243
|
+
contentType: "application/json",
|
|
244
|
+
additionalHeaders
|
|
245
|
+
});
|
|
246
|
+
const controller = new AbortController();
|
|
247
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
248
|
+
let response;
|
|
249
|
+
try {
|
|
250
|
+
response = await this.fetchImpl(this.endpoint, {
|
|
251
|
+
method: "POST",
|
|
252
|
+
headers,
|
|
253
|
+
body,
|
|
254
|
+
signal: controller.signal
|
|
255
|
+
});
|
|
256
|
+
} finally {
|
|
257
|
+
clearTimeout(timer);
|
|
258
|
+
}
|
|
259
|
+
if (!response.ok) {
|
|
260
|
+
const text = await safeReadText$1(response);
|
|
261
|
+
throw new Error(`CloudWatchLogExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim());
|
|
262
|
+
}
|
|
263
|
+
}
|
|
285
264
|
};
|
|
286
|
-
async function
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
265
|
+
async function safeReadText$1(response) {
|
|
266
|
+
try {
|
|
267
|
+
return await response.text();
|
|
268
|
+
} catch {
|
|
269
|
+
return "";
|
|
270
|
+
}
|
|
292
271
|
}
|
|
293
|
-
|
|
272
|
+
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/cloudwatch/metric-exporter.ts
|
|
275
|
+
const DEFAULT_TEMPORALITY = (_instrumentType) => _opentelemetry_sdk_metrics.AggregationTemporality.DELTA;
|
|
294
276
|
var CloudWatchMetricExporter = class {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
response = await this.fetchImpl(this.endpoint, {
|
|
363
|
-
method: "POST",
|
|
364
|
-
headers,
|
|
365
|
-
body,
|
|
366
|
-
signal: controller.signal
|
|
367
|
-
});
|
|
368
|
-
} finally {
|
|
369
|
-
clearTimeout(timer);
|
|
370
|
-
}
|
|
371
|
-
if (!response.ok) {
|
|
372
|
-
const text = await safeReadText3(response);
|
|
373
|
-
throw new Error(
|
|
374
|
-
`CloudWatchMetricExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim()
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
277
|
+
region;
|
|
278
|
+
endpoint;
|
|
279
|
+
credentials;
|
|
280
|
+
timeoutMs;
|
|
281
|
+
fetchImpl;
|
|
282
|
+
temporalitySelector;
|
|
283
|
+
shutdownOnce = false;
|
|
284
|
+
constructor(config = {}) {
|
|
285
|
+
const region = config.region ?? process.env.AWS_REGION;
|
|
286
|
+
if (!region) throw new Error("CloudWatchMetricExporter: `region` is required (pass it explicitly or set AWS_REGION).");
|
|
287
|
+
this.region = region;
|
|
288
|
+
this.endpoint = config.endpoint ?? cloudWatchMetricsEndpoint({ region });
|
|
289
|
+
this.credentials = config.credentials;
|
|
290
|
+
this.timeoutMs = config.timeoutMs ?? 1e4;
|
|
291
|
+
this.fetchImpl = config.fetchImpl ?? globalThis.fetch;
|
|
292
|
+
this.temporalitySelector = config.temporalitySelector ?? DEFAULT_TEMPORALITY;
|
|
293
|
+
if (typeof this.fetchImpl !== "function") throw new TypeError("CloudWatchMetricExporter: global `fetch` is not available — pass `fetchImpl` explicitly.");
|
|
294
|
+
}
|
|
295
|
+
export(metrics, resultCallback) {
|
|
296
|
+
if (this.shutdownOnce) {
|
|
297
|
+
resultCallback({
|
|
298
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
299
|
+
error: /* @__PURE__ */ new Error("CloudWatchMetricExporter: already shut down")
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.sendBatch(metrics).then(() => resultCallback({ code: _opentelemetry_core.ExportResultCode.SUCCESS }), (error) => resultCallback({
|
|
304
|
+
code: _opentelemetry_core.ExportResultCode.FAILED,
|
|
305
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
306
|
+
}));
|
|
307
|
+
}
|
|
308
|
+
async shutdown() {
|
|
309
|
+
this.shutdownOnce = true;
|
|
310
|
+
}
|
|
311
|
+
async forceFlush() {}
|
|
312
|
+
selectAggregationTemporality(instrumentType) {
|
|
313
|
+
return this.temporalitySelector(instrumentType);
|
|
314
|
+
}
|
|
315
|
+
async sendBatch(metrics) {
|
|
316
|
+
const body = _opentelemetry_otlp_transformer.JsonMetricsSerializer.serializeRequest(metrics);
|
|
317
|
+
if (!body) throw new Error("CloudWatchMetricExporter: serializer produced no body");
|
|
318
|
+
const headers = await signCloudWatchOtlpRequest({
|
|
319
|
+
url: this.endpoint,
|
|
320
|
+
body,
|
|
321
|
+
region: this.region,
|
|
322
|
+
signal: "metrics",
|
|
323
|
+
credentials: this.credentials,
|
|
324
|
+
contentType: "application/json"
|
|
325
|
+
});
|
|
326
|
+
const controller = new AbortController();
|
|
327
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
328
|
+
let response;
|
|
329
|
+
try {
|
|
330
|
+
response = await this.fetchImpl(this.endpoint, {
|
|
331
|
+
method: "POST",
|
|
332
|
+
headers,
|
|
333
|
+
body,
|
|
334
|
+
signal: controller.signal
|
|
335
|
+
});
|
|
336
|
+
} finally {
|
|
337
|
+
clearTimeout(timer);
|
|
338
|
+
}
|
|
339
|
+
if (!response.ok) {
|
|
340
|
+
const text = await safeReadText(response);
|
|
341
|
+
throw new Error(`CloudWatchMetricExporter: HTTP ${response.status} ${response.statusText} ${text}`.trim());
|
|
342
|
+
}
|
|
343
|
+
}
|
|
378
344
|
};
|
|
379
|
-
async function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
345
|
+
async function safeReadText(response) {
|
|
346
|
+
try {
|
|
347
|
+
return await response.text();
|
|
348
|
+
} catch {
|
|
349
|
+
return "";
|
|
350
|
+
}
|
|
385
351
|
}
|
|
386
352
|
|
|
353
|
+
//#endregion
|
|
387
354
|
exports.CloudWatchLogExporter = CloudWatchLogExporter;
|
|
388
355
|
exports.CloudWatchMetricExporter = CloudWatchMetricExporter;
|
|
389
356
|
exports.CloudWatchTraceExporter = CloudWatchTraceExporter;
|
|
@@ -392,5 +359,4 @@ exports.cloudWatchLogsEndpoint = cloudWatchLogsEndpoint;
|
|
|
392
359
|
exports.cloudWatchMetricsEndpoint = cloudWatchMetricsEndpoint;
|
|
393
360
|
exports.cloudWatchTracesEndpoint = cloudWatchTracesEndpoint;
|
|
394
361
|
exports.signCloudWatchOtlpRequest = signCloudWatchOtlpRequest;
|
|
395
|
-
//# sourceMappingURL=cloudwatch.cjs.map
|
|
396
362
|
//# sourceMappingURL=cloudwatch.cjs.map
|