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/kinesis.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkHMTKKKKP_cjs = require('./chunk-HMTKKKKP.cjs');
|
|
4
|
+
require('./chunk-UZEJV2YD.cjs');
|
|
5
|
+
require('./chunk-Q3DMMQ7K.cjs');
|
|
6
|
+
require('./chunk-JEQ2X3Z6.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "KinesisConsumer", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return chunkHMTKKKKP_cjs.KinesisConsumer; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "KinesisProducer", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return chunkHMTKKKKP_cjs.KinesisProducer; }
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "traceKinesis", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return chunkHMTKKKKP_cjs.traceKinesis; }
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=kinesis.cjs.map
|
|
23
|
+
//# sourceMappingURL=kinesis.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"kinesis.cjs"}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { TraceContext } from 'autotel';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Kinesis-specific instrumentation
|
|
5
|
+
*
|
|
6
|
+
* Provides semantic helpers for tracing Kinesis Data Streams operations with proper
|
|
7
|
+
* OpenTelemetry messaging semantic conventions.
|
|
8
|
+
*
|
|
9
|
+
* @example Put record to stream
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { traceKinesis } from 'autotel-aws/kinesis';
|
|
12
|
+
* import { KinesisClient, PutRecordCommand } from '@aws-sdk/client-kinesis';
|
|
13
|
+
*
|
|
14
|
+
* const kinesis = new KinesisClient({});
|
|
15
|
+
*
|
|
16
|
+
* export const putRecord = traceKinesis({
|
|
17
|
+
* operation: 'put',
|
|
18
|
+
* streamName: 'my-stream'
|
|
19
|
+
* })(ctx => async (data: object, partitionKey: string) => {
|
|
20
|
+
* const result = await kinesis.send(new PutRecordCommand({
|
|
21
|
+
* StreamName: 'my-stream',
|
|
22
|
+
* Data: Buffer.from(JSON.stringify(data)),
|
|
23
|
+
* PartitionKey: partitionKey
|
|
24
|
+
* }));
|
|
25
|
+
*
|
|
26
|
+
* ctx.setAttribute('aws.kinesis.shard_id', result.ShardId ?? '');
|
|
27
|
+
* ctx.setAttribute('aws.kinesis.sequence_number', result.SequenceNumber ?? '');
|
|
28
|
+
*
|
|
29
|
+
* return result;
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Usage: await putRecord({ event: 'click' }, 'user-123');
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example Get records from shard
|
|
36
|
+
* ```typescript
|
|
37
|
+
* export const getRecords = traceKinesis({
|
|
38
|
+
* operation: 'get',
|
|
39
|
+
* streamName: 'my-stream'
|
|
40
|
+
* })(ctx => async (shardIterator: string, limit: number) => {
|
|
41
|
+
* const result = await kinesis.send(new GetRecordsCommand({
|
|
42
|
+
* ShardIterator: shardIterator,
|
|
43
|
+
* Limit: limit
|
|
44
|
+
* }));
|
|
45
|
+
*
|
|
46
|
+
* ctx.setAttribute('messaging.batch.message_count', result.Records?.length ?? 0);
|
|
47
|
+
* return result;
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Kinesis operation configuration
|
|
54
|
+
*/
|
|
55
|
+
interface TraceKinesisConfig {
|
|
56
|
+
/**
|
|
57
|
+
* Kinesis operation type
|
|
58
|
+
* - 'put' - PutRecord, PutRecords
|
|
59
|
+
* - 'get' - GetRecords, GetShardIterator
|
|
60
|
+
*/
|
|
61
|
+
operation: 'put' | 'get';
|
|
62
|
+
/**
|
|
63
|
+
* Kinesis stream name
|
|
64
|
+
* Sets `messaging.destination.name` attribute.
|
|
65
|
+
*/
|
|
66
|
+
streamName: string;
|
|
67
|
+
/**
|
|
68
|
+
* Shard ID (if known at configuration time)
|
|
69
|
+
* Sets `aws.kinesis.shard_id` attribute.
|
|
70
|
+
*/
|
|
71
|
+
shardId?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Trace Kinesis operations with semantic attributes
|
|
75
|
+
*
|
|
76
|
+
* Creates a traced function that automatically sets Kinesis messaging semantic attributes
|
|
77
|
+
* following OpenTelemetry conventions.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Kinesis operation configuration
|
|
80
|
+
* @returns A higher-order function that wraps your Kinesis operation with tracing
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Semantic attributes set automatically:
|
|
84
|
+
* - `messaging.system` - 'aws_kinesis'
|
|
85
|
+
* - `messaging.destination.name` - Stream name
|
|
86
|
+
* - `messaging.operation` - 'put' or 'get'
|
|
87
|
+
* - `aws.kinesis.shard_id` - Shard ID (if provided)
|
|
88
|
+
*
|
|
89
|
+
* Additional attributes you should set in your handler:
|
|
90
|
+
* - `aws.kinesis.sequence_number` - Record sequence number
|
|
91
|
+
* - `messaging.batch.message_count` - Number of records in batch
|
|
92
|
+
*
|
|
93
|
+
* @see https://opentelemetry.io/docs/specs/semconv/messaging/aws-kinesis/
|
|
94
|
+
*/
|
|
95
|
+
declare function traceKinesis(config: TraceKinesisConfig): <TArgs extends unknown[], TReturn>(fn: (ctx: TraceContext) => (...args: TArgs) => Promise<TReturn>) => (...args: TArgs) => Promise<TReturn>;
|
|
96
|
+
/**
|
|
97
|
+
* Configuration for Kinesis Producer
|
|
98
|
+
*/
|
|
99
|
+
interface KinesisProducerConfig {
|
|
100
|
+
/**
|
|
101
|
+
* Kinesis stream name or ARN
|
|
102
|
+
*/
|
|
103
|
+
streamName: string;
|
|
104
|
+
/**
|
|
105
|
+
* Inject W3C Trace Context into record data
|
|
106
|
+
* Enables distributed tracing across producer/consumer
|
|
107
|
+
* @default true
|
|
108
|
+
*/
|
|
109
|
+
injectTraceContext?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Optional service name for tracing
|
|
112
|
+
*/
|
|
113
|
+
service?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Record to put via Kinesis Producer
|
|
117
|
+
*/
|
|
118
|
+
interface KinesisRecord {
|
|
119
|
+
/**
|
|
120
|
+
* Record data (will be serialized to JSON if object)
|
|
121
|
+
*/
|
|
122
|
+
data: string | object;
|
|
123
|
+
/**
|
|
124
|
+
* Partition key for sharding
|
|
125
|
+
*/
|
|
126
|
+
partitionKey: string;
|
|
127
|
+
/**
|
|
128
|
+
* Optional explicit hash key
|
|
129
|
+
*/
|
|
130
|
+
explicitHashKey?: string;
|
|
131
|
+
/**
|
|
132
|
+
* Optional sequence number for ordering
|
|
133
|
+
*/
|
|
134
|
+
sequenceNumberForOrdering?: string;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Kinesis Producer with automatic trace context injection
|
|
138
|
+
*
|
|
139
|
+
* Wraps a Kinesis client to automatically:
|
|
140
|
+
* - Create spans for put operations
|
|
141
|
+
* - Inject W3C Trace Context into record data
|
|
142
|
+
* - Set proper semantic attributes
|
|
143
|
+
*
|
|
144
|
+
* @example Basic usage
|
|
145
|
+
* ```typescript
|
|
146
|
+
* import { KinesisProducer } from 'autotel-aws/kinesis';
|
|
147
|
+
* import { KinesisClient } from '@aws-sdk/client-kinesis';
|
|
148
|
+
*
|
|
149
|
+
* const kinesis = new KinesisClient({ region: 'us-east-1' });
|
|
150
|
+
* const producer = new KinesisProducer(kinesis, {
|
|
151
|
+
* streamName: 'my-stream'
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* // Put with automatic trace context
|
|
155
|
+
* const result = await producer.putRecord({
|
|
156
|
+
* data: { event: 'click', userId: '123' },
|
|
157
|
+
* partitionKey: 'user-123'
|
|
158
|
+
* });
|
|
159
|
+
* console.log('Sequence:', result.sequenceNumber);
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @example Batch put
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const results = await producer.putRecords([
|
|
165
|
+
* { data: { event: 'click' }, partitionKey: 'user-1' },
|
|
166
|
+
* { data: { event: 'view' }, partitionKey: 'user-2' },
|
|
167
|
+
* { data: { event: 'scroll' }, partitionKey: 'user-3' }
|
|
168
|
+
* ]);
|
|
169
|
+
* console.log(`Put ${results.successful.length} records`);
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
declare class KinesisProducer<TClient extends {
|
|
173
|
+
send: (command: any) => Promise<any>;
|
|
174
|
+
} = any> {
|
|
175
|
+
private client;
|
|
176
|
+
private config;
|
|
177
|
+
constructor(client: TClient, config: KinesisProducerConfig);
|
|
178
|
+
/**
|
|
179
|
+
* Inject trace context into record data
|
|
180
|
+
*/
|
|
181
|
+
private injectContext;
|
|
182
|
+
/**
|
|
183
|
+
* Put a single record to the stream
|
|
184
|
+
*
|
|
185
|
+
* @param record - Record to put
|
|
186
|
+
* @returns Promise with shard ID and sequence number
|
|
187
|
+
*/
|
|
188
|
+
putRecord(record: KinesisRecord): Promise<{
|
|
189
|
+
shardId?: string;
|
|
190
|
+
sequenceNumber?: string;
|
|
191
|
+
encryptionType?: string;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Put multiple records in a batch
|
|
195
|
+
*
|
|
196
|
+
* @param records - Array of records to put (max 500)
|
|
197
|
+
* @returns Promise with successful and failed record results
|
|
198
|
+
*/
|
|
199
|
+
putRecords(records: KinesisRecord[]): Promise<{
|
|
200
|
+
successful: Array<{
|
|
201
|
+
shardId?: string;
|
|
202
|
+
sequenceNumber?: string;
|
|
203
|
+
}>;
|
|
204
|
+
failed: Array<{
|
|
205
|
+
errorCode?: string;
|
|
206
|
+
errorMessage?: string;
|
|
207
|
+
}>;
|
|
208
|
+
failedRecordCount: number;
|
|
209
|
+
}>;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Configuration for Kinesis Consumer
|
|
213
|
+
*/
|
|
214
|
+
interface KinesisConsumerConfig {
|
|
215
|
+
/**
|
|
216
|
+
* Kinesis stream name or ARN
|
|
217
|
+
*/
|
|
218
|
+
streamName: string;
|
|
219
|
+
/**
|
|
220
|
+
* Extract W3C Trace Context from record data
|
|
221
|
+
* Creates child spans linked to the producer
|
|
222
|
+
* @default true
|
|
223
|
+
*/
|
|
224
|
+
extractTraceContext?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Optional service name for tracing
|
|
227
|
+
*/
|
|
228
|
+
service?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Received Kinesis record with parsed data
|
|
232
|
+
*/
|
|
233
|
+
interface ReceivedKinesisRecord {
|
|
234
|
+
/**
|
|
235
|
+
* Sequence number
|
|
236
|
+
*/
|
|
237
|
+
sequenceNumber: string;
|
|
238
|
+
/**
|
|
239
|
+
* Approximate arrival timestamp
|
|
240
|
+
*/
|
|
241
|
+
approximateArrivalTimestamp?: Date;
|
|
242
|
+
/**
|
|
243
|
+
* Parsed data (JSON parsed if possible)
|
|
244
|
+
*/
|
|
245
|
+
data: any;
|
|
246
|
+
/**
|
|
247
|
+
* Raw data as string
|
|
248
|
+
*/
|
|
249
|
+
rawData: string;
|
|
250
|
+
/**
|
|
251
|
+
* Partition key
|
|
252
|
+
*/
|
|
253
|
+
partitionKey: string;
|
|
254
|
+
/**
|
|
255
|
+
* Encryption type
|
|
256
|
+
*/
|
|
257
|
+
encryptionType?: string;
|
|
258
|
+
/**
|
|
259
|
+
* Original AWS SDK record object
|
|
260
|
+
*/
|
|
261
|
+
raw: any;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Record processor function type
|
|
265
|
+
*/
|
|
266
|
+
type KinesisRecordProcessor = (record: ReceivedKinesisRecord, ctx: TraceContext) => Promise<void>;
|
|
267
|
+
/**
|
|
268
|
+
* Kinesis Consumer with automatic trace context extraction
|
|
269
|
+
*
|
|
270
|
+
* Wraps a Kinesis client to automatically:
|
|
271
|
+
* - Create spans for get operations
|
|
272
|
+
* - Extract W3C Trace Context from record data
|
|
273
|
+
* - Link consumer spans to producer spans
|
|
274
|
+
*
|
|
275
|
+
* @example Basic usage
|
|
276
|
+
* ```typescript
|
|
277
|
+
* import { KinesisConsumer } from 'autotel-aws/kinesis';
|
|
278
|
+
* import { KinesisClient } from '@aws-sdk/client-kinesis';
|
|
279
|
+
*
|
|
280
|
+
* const kinesis = new KinesisClient({ region: 'us-east-1' });
|
|
281
|
+
* const consumer = new KinesisConsumer(kinesis, {
|
|
282
|
+
* streamName: 'my-stream'
|
|
283
|
+
* });
|
|
284
|
+
*
|
|
285
|
+
* // Get shard iterator first
|
|
286
|
+
* const iterator = await consumer.getShardIterator('shardId-000000000000', 'LATEST');
|
|
287
|
+
*
|
|
288
|
+
* // Process records with automatic tracing
|
|
289
|
+
* const { nextIterator, records } = await consumer.getRecords(iterator, 100);
|
|
290
|
+
*
|
|
291
|
+
* for (const record of records) {
|
|
292
|
+
* console.log('Record:', record.data);
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* @example With processor function
|
|
297
|
+
* ```typescript
|
|
298
|
+
* await consumer.processRecords(iterator, async (record, ctx) => {
|
|
299
|
+
* ctx.setAttribute('event.type', record.data.event);
|
|
300
|
+
* await handleEvent(record.data);
|
|
301
|
+
* });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
declare class KinesisConsumer<TClient extends {
|
|
305
|
+
send: (command: any) => Promise<any>;
|
|
306
|
+
} = any> {
|
|
307
|
+
private client;
|
|
308
|
+
private config;
|
|
309
|
+
constructor(client: TClient, config: KinesisConsumerConfig);
|
|
310
|
+
/**
|
|
311
|
+
* Extract trace context from record data
|
|
312
|
+
*/
|
|
313
|
+
private extractContext;
|
|
314
|
+
/**
|
|
315
|
+
* Parse raw record data
|
|
316
|
+
*/
|
|
317
|
+
private parseRecord;
|
|
318
|
+
/**
|
|
319
|
+
* Get a shard iterator
|
|
320
|
+
*
|
|
321
|
+
* @param shardId - Shard ID
|
|
322
|
+
* @param type - Iterator type
|
|
323
|
+
* @param startingSequenceNumber - Starting sequence number (for AT_SEQUENCE_NUMBER, AFTER_SEQUENCE_NUMBER)
|
|
324
|
+
* @param timestamp - Starting timestamp (for AT_TIMESTAMP)
|
|
325
|
+
* @returns Shard iterator string
|
|
326
|
+
*/
|
|
327
|
+
getShardIterator(shardId: string, type: 'AT_SEQUENCE_NUMBER' | 'AFTER_SEQUENCE_NUMBER' | 'TRIM_HORIZON' | 'LATEST' | 'AT_TIMESTAMP', startingSequenceNumber?: string, timestamp?: Date): Promise<string>;
|
|
328
|
+
/**
|
|
329
|
+
* Get records from a shard iterator
|
|
330
|
+
*
|
|
331
|
+
* @param shardIterator - Shard iterator
|
|
332
|
+
* @param limit - Maximum records to return (max 10000)
|
|
333
|
+
* @returns Records and next shard iterator
|
|
334
|
+
*/
|
|
335
|
+
getRecords(shardIterator: string, limit?: number): Promise<{
|
|
336
|
+
records: ReceivedKinesisRecord[];
|
|
337
|
+
nextIterator?: string;
|
|
338
|
+
millisBehindLatest?: number;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* Process records with automatic trace context extraction
|
|
342
|
+
*
|
|
343
|
+
* @param shardIterator - Shard iterator
|
|
344
|
+
* @param processor - Function to process each record
|
|
345
|
+
* @param limit - Maximum records to process
|
|
346
|
+
* @returns Next shard iterator and count of processed records
|
|
347
|
+
*/
|
|
348
|
+
processRecords(shardIterator: string, processor: KinesisRecordProcessor, limit?: number): Promise<{
|
|
349
|
+
nextIterator?: string;
|
|
350
|
+
processedCount: number;
|
|
351
|
+
}>;
|
|
352
|
+
/**
|
|
353
|
+
* List shards for the stream
|
|
354
|
+
*
|
|
355
|
+
* @returns Array of shard IDs
|
|
356
|
+
*/
|
|
357
|
+
listShards(): Promise<string[]>;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export { KinesisConsumer, type KinesisConsumerConfig, KinesisProducer, type KinesisProducerConfig, type KinesisRecord, type KinesisRecordProcessor, type ReceivedKinesisRecord, type TraceKinesisConfig, traceKinesis };
|