• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / f32ddf78-b8ca-49ab-9751-2526b355995f

27 Mar 2025 01:39PM UTC coverage: 86.88% (+0.03%) from 86.854%
f32ddf78-b8ca-49ab-9751-2526b355995f

push

circleci

web-flow
add localstack 4.3 blog to the README (#12445)

63268 of 72822 relevant lines covered (86.88%)

0.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.73
/localstack-core/localstack/services/lambda_/event_source_mapping/pollers/stream_poller.py
1
import json
1✔
2
import logging
1✔
3
import threading
1✔
4
from abc import abstractmethod
1✔
5
from collections import defaultdict
1✔
6
from datetime import datetime
1✔
7
from typing import Iterator
1✔
8

9
from botocore.client import BaseClient
1✔
10
from botocore.exceptions import ClientError
1✔
11

12
from localstack.aws.api.pipes import (
1✔
13
    OnPartialBatchItemFailureStreams,
14
)
15
from localstack.services.lambda_.event_source_mapping.event_processor import (
1✔
16
    BatchFailureError,
17
    CustomerInvocationError,
18
    EventProcessor,
19
    PartialBatchFailureError,
20
    PipeInternalError,
21
)
22
from localstack.services.lambda_.event_source_mapping.pipe_utils import (
1✔
23
    get_current_time,
24
    get_datetime_from_timestamp,
25
    get_internal_client,
26
)
27
from localstack.services.lambda_.event_source_mapping.pollers.poller import (
1✔
28
    EmptyPollResultsException,
29
    Poller,
30
    get_batch_item_failures,
31
)
32
from localstack.services.lambda_.event_source_mapping.pollers.sqs_poller import get_queue_url
1✔
33
from localstack.services.lambda_.event_source_mapping.senders.sender_utils import (
1✔
34
    batched,
35
)
36
from localstack.utils.aws.arns import parse_arn, s3_bucket_name
1✔
37
from localstack.utils.backoff import ExponentialBackoff
1✔
38
from localstack.utils.batch_policy import Batcher
1✔
39
from localstack.utils.strings import long_uid
1✔
40

41
LOG = logging.getLogger(__name__)
1✔
42

43

44
# TODO: fix this poller to support resharding
45
#   https://docs.aws.amazon.com/streams/latest/dev/kinesis-using-sdk-java-resharding.html
46
class StreamPoller(Poller):
1✔
47
    # Mapping of shard id => shard iterator
48
    shards: dict[str, str]
1✔
49
    # Iterator for round-robin polling from different shards because a batch cannot contain events from different shards
50
    # This is a workaround for not handling shards in parallel.
51
    iterator_over_shards: Iterator[tuple[str, str]] | None
1✔
52
    # ESM UUID is needed in failure processing to form s3 failure destination object key
53
    esm_uuid: str | None
1✔
54

55
    # The ARN of the processor (e.g., Pipe ARN)
56
    partner_resource_arn: str | None
1✔
57

58
    # Used for backing-off between retries and breaking the retry loop
59
    _is_shutdown: threading.Event
1✔
60

61
    # Collects and flushes a batch of records based on a batching policy
62
    shard_batcher: dict[str, Batcher[dict]]
1✔
63

64
    def __init__(
1✔
65
        self,
66
        source_arn: str,
67
        source_parameters: dict | None = None,
68
        source_client: BaseClient | None = None,
69
        processor: EventProcessor | None = None,
70
        partner_resource_arn: str | None = None,
71
        esm_uuid: str | None = None,
72
    ):
73
        super().__init__(source_arn, source_parameters, source_client, processor)
1✔
74
        self.partner_resource_arn = partner_resource_arn
1✔
75
        self.esm_uuid = esm_uuid
1✔
76
        self.shards = {}
1✔
77
        self.iterator_over_shards = None
1✔
78

79
        self._is_shutdown = threading.Event()
1✔
80

81
        self.shard_batcher = defaultdict(
1✔
82
            lambda: Batcher(
83
                max_count=self.stream_parameters.get("BatchSize", 100),
84
                max_window=self.stream_parameters.get("MaximumBatchingWindowInSeconds", 0),
85
            )
86
        )
87

88
    @abstractmethod
1✔
89
    def transform_into_events(self, records: list[dict], shard_id) -> list[dict]:
1✔
90
        pass
×
91

92
    @property
1✔
93
    @abstractmethod
1✔
94
    def stream_parameters(self) -> dict:
1✔
95
        pass
×
96

97
    @abstractmethod
1✔
98
    def initialize_shards(self) -> dict[str, str]:
1✔
99
        """Returns a shard dict mapping from shard id -> shard iterator
100
        The implementations for Kinesis and DynamoDB are similar but differ in various ways:
101
        * Kinesis uses "StreamARN" and DynamoDB uses "StreamArn" as source parameter
102
        * Kinesis uses "StreamStatus.ACTIVE" and DynamoDB uses "StreamStatus.ENABLED"
103
        * Only Kinesis supports the additional StartingPosition called "AT_TIMESTAMP" using "StartingPositionTimestamp"
104
        """
105
        pass
×
106

107
    @abstractmethod
1✔
108
    def stream_arn_param(self) -> dict:
1✔
109
        """Returns a dict of the correct key/value pair for the stream arn used in GetRecords.
110
        Either StreamARN for Kinesis or {} for DynamoDB (unsupported)"""
111
        pass
×
112

113
    @abstractmethod
1✔
114
    def failure_payload_details_field_name(self) -> str:
1✔
115
        pass
×
116

117
    @abstractmethod
1✔
118
    def get_approximate_arrival_time(self, record: dict) -> float:
1✔
119
        pass
×
120

121
    @abstractmethod
1✔
122
    def format_datetime(self, time: datetime) -> str:
1✔
123
        """Formats a datetime in the correct format for DynamoDB (with ms) or Kinesis (without ms)"""
124
        pass
×
125

126
    @abstractmethod
1✔
127
    def get_sequence_number(self, record: dict) -> str:
1✔
128
        pass
×
129

130
    def close(self):
1✔
131
        self._is_shutdown.set()
1✔
132

133
    def pre_filter(self, events: list[dict]) -> list[dict]:
1✔
134
        return events
1✔
135

136
    def post_filter(self, events: list[dict]) -> list[dict]:
1✔
137
        return events
1✔
138

139
    def poll_events(self):
1✔
140
        """Generalized poller for streams such as Kinesis or DynamoDB
141
        Examples of Kinesis consumers:
142
        * StackOverflow: https://stackoverflow.com/a/22403036/6875981
143
        * AWS Sample: https://github.com/aws-samples/kinesis-poster-worker/blob/master/worker.py
144
        Examples of DynamoDB consumers:
145
        * Blogpost: https://www.tecracer.com/blog/2022/05/getting-a-near-real-time-view-of-a-dynamodb-stream-with-python.html
146
        """
147
        # TODO: consider potential shard iterator timeout after 300 seconds (likely not relevant with short-polling):
148
        #   https://docs.aws.amazon.com/streams/latest/dev/troubleshooting-consumers.html#shard-iterator-expires-unexpectedly
149
        #  Does this happen if no records are received for 300 seconds?
150
        if not self.shards:
1✔
151
            self.shards = self.initialize_shards()
1✔
152

153
        if not self.shards:
1✔
154
            LOG.debug("No shards found for %s.", self.source_arn)
1✔
155
            raise EmptyPollResultsException(service=self.event_source(), source_arn=self.source_arn)
1✔
156
        else:
157
            LOG.debug("Event source %s has %d shards.", self.source_arn, len(self.shards))
1✔
158
            # Remove all shard batchers without corresponding shards
159
            for shard_id in self.shard_batcher.keys() - self.shards.keys():
1✔
160
                self.shard_batcher.pop(shard_id, None)
×
161

162
        # TODO: improve efficiency because this currently limits the throughput to at most batch size per poll interval
163
        # Handle shards round-robin. Re-initialize current shard iterator once all shards are handled.
164
        if self.iterator_over_shards is None:
1✔
165
            self.iterator_over_shards = iter(self.shards.items())
1✔
166

167
        current_shard_tuple = next(self.iterator_over_shards, None)
1✔
168
        if not current_shard_tuple:
1✔
169
            self.iterator_over_shards = iter(self.shards.items())
1✔
170
            current_shard_tuple = next(self.iterator_over_shards, None)
1✔
171

172
        # TODO Better handling when shards are initialised and the iterator returns nothing
173
        if not current_shard_tuple:
1✔
174
            raise PipeInternalError(
×
175
                "Failed to retrieve any shards for stream polling despite initialization."
176
            )
177

178
        try:
1✔
179
            self.poll_events_from_shard(*current_shard_tuple)
1✔
180
        except PipeInternalError:
1✔
181
            # TODO: standardize logging
182
            # Ignore and wait for the next polling interval, which will do retry
183
            pass
1✔
184

185
    def poll_events_from_shard(self, shard_id: str, shard_iterator: str):
1✔
186
        get_records_response = self.get_records(shard_iterator)
1✔
187
        records: list[dict] = get_records_response.get("Records", [])
1✔
188
        next_shard_iterator = get_records_response["NextShardIterator"]
1✔
189

190
        # We cannot reliably back-off when no records found since an iterator
191
        # may have to move multiple times until records are returned.
192
        # See https://docs.aws.amazon.com/streams/latest/dev/troubleshooting-consumers.html#getrecords-returns-empty
193
        # However, we still need to check if batcher should be triggered due to time-based batching.
194
        should_flush = self.shard_batcher[shard_id].add(records)
1✔
195
        if not should_flush:
1✔
196
            self.shards[shard_id] = next_shard_iterator
1✔
197
            return
1✔
198

199
        # Retrieve and drain all events in batcher
200
        collected_records = self.shard_batcher[shard_id].flush()
1✔
201
        # If there is overflow (i.e 1k BatchSize and 1.2K returned in flush), further split up the batch.
202
        for batch in batched(collected_records, self.stream_parameters.get("BatchSize")):
1✔
203
            # This could potentially lead to data loss if forward_events_to_target raises an exception after a flush
204
            # which would otherwise be solved with checkpointing.
205
            # TODO: Implement checkpointing, leasing, etc. from https://docs.aws.amazon.com/streams/latest/dev/kcl-concepts.html
206
            self.forward_events_to_target(shard_id, next_shard_iterator, batch)
1✔
207

208
    def forward_events_to_target(self, shard_id, next_shard_iterator, records):
1✔
209
        polled_events = self.transform_into_events(records, shard_id)
1✔
210

211
        abort_condition = None
1✔
212
        # Check MaximumRecordAgeInSeconds
213
        if maximum_record_age_in_seconds := self.stream_parameters.get("MaximumRecordAgeInSeconds"):
1✔
214
            arrival_timestamp_of_last_event = polled_events[-1]["approximateArrivalTimestamp"]
×
215
            now = get_current_time().timestamp()
×
216
            record_age_in_seconds = now - arrival_timestamp_of_last_event
×
217
            if record_age_in_seconds > maximum_record_age_in_seconds:
×
218
                abort_condition = "RecordAgeExpired"
×
219

220
        # TODO: implement format detection behavior (e.g., for JSON body):
221
        #  https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-filtering.html
222
        #  Check whether we need poller-specific filter-preprocessing here without modifying the actual event!
223
        # convert to json for filtering (HACK for fixing parity with v1 and getting regression tests passing)
224
        # localstack.services.lambda_.event_source_listeners.kinesis_event_source_listener.KinesisEventSourceListener._filter_records
225
        # TODO: explore better abstraction for the entire filtering, including the set_data and get_data remapping
226
        #  We need better clarify which transformations happen before and after filtering -> fix missing test coverage
227
        parsed_events = self.pre_filter(polled_events)
1✔
228
        # TODO: advance iterator past matching events!
229
        #  We need to checkpoint the sequence number for each shard and then advance the shard iterator using
230
        #  GetShardIterator with a given sequence number
231
        #  https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html
232
        #  Failing to do so kinda blocks the stream resulting in very high latency.
233
        matching_events = self.filter_events(parsed_events)
1✔
234
        matching_events_post_filter = self.post_filter(matching_events)
1✔
235

236
        # TODO: implement MaximumBatchingWindowInSeconds flush condition (before or after filter?)
237
        # Don't trigger upon empty events
238
        if len(matching_events_post_filter) == 0:
1✔
239
            # Update shard iterator if no records match the filter
240
            self.shards[shard_id] = next_shard_iterator
1✔
241
            return
1✔
242
        events = self.add_source_metadata(matching_events_post_filter)
1✔
243
        LOG.debug("Polled %d events from %s in shard %s", len(events), self.source_arn, shard_id)
1✔
244
        # TODO: A retry should probably re-trigger fetching the record from the stream again?!
245
        #  -> This could be tested by setting a high retry number, using a long pipe execution, and a relatively
246
        #  short record expiration age at the source. Check what happens if the record expires at the source.
247
        #  A potential implementation could use checkpointing based on the iterator position (within shard scope)
248
        # TODO: handle partial batch failure (see poller.py:parse_batch_item_failures)
249
        # TODO: think about how to avoid starvation of other shards if one shard runs into infinite retries
250
        attempts = 0
1✔
251
        error_payload = {}
1✔
252

253
        max_retries = self.stream_parameters.get("MaximumRetryAttempts", -1)
1✔
254
        # NOTE: max_retries == 0 means exponential backoff is disabled
255
        boff = ExponentialBackoff(max_retries=max_retries)
1✔
256
        while (
1✔
257
            not abort_condition
258
            and not self.max_retries_exceeded(attempts)
259
            and not self._is_shutdown.is_set()
260
        ):
261
            try:
1✔
262
                if attempts > 0:
1✔
263
                    # TODO: Should we always backoff (with jitter) before processing since we may not want multiple pollers
264
                    # all starting up and polling simultaneously
265
                    # For example: 500 persisted ESMs starting up and requesting concurrently could flood gateway
266
                    self._is_shutdown.wait(boff.next_backoff())
1✔
267

268
                self.processor.process_events_batch(events)
1✔
269
                boff.reset()
1✔
270

271
                # Update shard iterator if execution is successful
272
                self.shards[shard_id] = next_shard_iterator
1✔
273
                return
1✔
274
            except PartialBatchFailureError as ex:
1✔
275
                # TODO: add tests for partial batch failure scenarios
276
                if (
1✔
277
                    self.stream_parameters.get("OnPartialBatchItemFailure")
278
                    == OnPartialBatchItemFailureStreams.AUTOMATIC_BISECT
279
                ):
280
                    # TODO: implement and test splitting batches in half until batch size 1
281
                    #  https://docs.aws.amazon.com/eventbridge/latest/pipes-reference/API_PipeSourceKinesisStreamParameters.html
282
                    LOG.warning(
×
283
                        "AUTOMATIC_BISECT upon partial batch item failure is not yet implemented. Retrying the entire batch."
284
                    )
285
                error_payload = ex.error
1✔
286

287
                # Extract all sequence numbers from events in batch. This allows us to fail the whole batch if
288
                # an unknown itemidentifier is returned.
289
                batch_sequence_numbers = {
1✔
290
                    self.get_sequence_number(event) for event in matching_events
291
                }
292

293
                # If the batchItemFailures array contains multiple items, Lambda uses the record with the lowest sequence number as the checkpoint.
294
                # Lambda then retries all records starting from that checkpoint.
295
                failed_sequence_ids: list[int] | None = get_batch_item_failures(
1✔
296
                    ex.partial_failure_payload, batch_sequence_numbers
297
                )
298

299
                # If None is returned, consider the entire batch a failure.
300
                if failed_sequence_ids is None:
1✔
301
                    continue
1✔
302

303
                # This shouldn't be possible since a PartialBatchFailureError was raised
304
                if len(failed_sequence_ids) == 0:
1✔
305
                    assert failed_sequence_ids, (
×
306
                        "Invalid state encountered: PartialBatchFailureError raised but no batch item failures found."
307
                    )
308

309
                lowest_sequence_id: str = min(failed_sequence_ids, key=int)
1✔
310

311
                # Discard all successful events and re-process from sequence number of failed event
312
                _, events = self.bisect_events(lowest_sequence_id, events)
1✔
313
            except (BatchFailureError, Exception) as ex:
1✔
314
                if isinstance(ex, BatchFailureError):
1✔
315
                    error_payload = ex.error
1✔
316

317
                # FIXME partner_resource_arn is not defined in ESM
318
                LOG.debug(
1✔
319
                    "Attempt %d failed while processing %s with events: %s",
320
                    attempts,
321
                    self.partner_resource_arn or self.source_arn,
322
                    events,
323
                )
324
            finally:
325
                # Retry polling until the record expires at the source
326
                attempts += 1
1✔
327

328
        # Send failed events to potential DLQ
329
        abort_condition = abort_condition or "RetryAttemptsExhausted"
1✔
330
        failure_context = self.processor.generate_event_failure_context(
1✔
331
            abort_condition=abort_condition,
332
            error=error_payload,
333
            attempts_count=attempts,
334
            partner_resource_arn=self.partner_resource_arn,
335
        )
336
        self.send_events_to_dlq(shard_id, events, context=failure_context)
1✔
337
        # Update shard iterator if the execution failed but the events are sent to a DLQ
338
        self.shards[shard_id] = next_shard_iterator
1✔
339

340
    def get_records(self, shard_iterator: str) -> dict:
1✔
341
        """Returns a GetRecordsOutput from the GetRecords endpoint of streaming services such as Kinesis or DynamoDB"""
342
        try:
1✔
343
            get_records_response = self.source_client.get_records(
1✔
344
                # TODO: add test for cross-account scenario
345
                # Differs for Kinesis and DynamoDB but required for cross-account scenario
346
                **self.stream_arn_param(),
347
                ShardIterator=shard_iterator,
348
                Limit=self.stream_parameters["BatchSize"],
349
            )
350
            return get_records_response
1✔
351
        # TODO: test iterator expired with conditional error scenario (requires failure destinations)
352
        except self.source_client.exceptions.ExpiredIteratorException as e:
1✔
353
            LOG.debug(
1✔
354
                "Shard iterator %s expired for stream %s, re-initializing shards",
355
                shard_iterator,
356
                self.source_arn,
357
            )
358
            # TODO: test TRIM_HORIZON and AT_TIMESTAMP scenarios for this case. We don't want to start from scratch and
359
            #  might need to think about checkpointing here.
360
            self.shards = self.initialize_shards()
1✔
361
            raise PipeInternalError from e
1✔
362
        except ClientError as e:
1✔
363
            if "AccessDeniedException" in str(e):
1✔
364
                LOG.warning(
×
365
                    "Insufficient permissions to get records from stream %s: %s",
366
                    self.source_arn,
367
                    e,
368
                )
369
                raise CustomerInvocationError from e
×
370
            elif "ResourceNotFoundException" in str(e):
1✔
371
                # FIXME: The 'Invalid ShardId in ShardIterator' error is returned by DynamoDB-local. Unsure when/why this is returned.
372
                if "Invalid ShardId in ShardIterator" in str(e):
×
373
                    LOG.warning(
×
374
                        "Invalid ShardId in ShardIterator for %s. Re-initializing shards.",
375
                        self.source_arn,
376
                    )
377
                    self.shards = self.initialize_shards()
×
378
                else:
379
                    LOG.warning(
×
380
                        "Source stream %s does not exist: %s",
381
                        self.source_arn,
382
                        e,
383
                    )
384
                    raise CustomerInvocationError from e
×
385
            elif "TrimmedDataAccessException" in str(e):
1✔
386
                LOG.debug(
×
387
                    "Attempted to iterate over trimmed record or expired shard iterator %s for stream %s, re-initializing shards",
388
                    shard_iterator,
389
                    self.source_arn,
390
                )
391
                self.shards = self.initialize_shards()
×
392
            else:
393
                LOG.debug("ClientError during get_records for stream %s: %s", self.source_arn, e)
1✔
394
            raise PipeInternalError from e
1✔
395

396
    def send_events_to_dlq(self, shard_id, events, context) -> None:
1✔
397
        dlq_arn = self.stream_parameters.get("DeadLetterConfig", {}).get("Arn")
1✔
398
        if dlq_arn:
1✔
399
            failure_timstamp = get_current_time()
1✔
400
            dlq_event = self.create_dlq_event(shard_id, events, context, failure_timstamp)
1✔
401
            # Send DLQ event to DLQ target
402
            parsed_arn = parse_arn(dlq_arn)
1✔
403
            service = parsed_arn["service"]
1✔
404
            # TODO: use a sender instance here, likely inject via DI into poller (what if it updates?)
405
            if service == "sqs":
1✔
406
                # TODO: inject and cache SQS client using proper IAM role (supports cross-account operations)
407
                sqs_client = get_internal_client(dlq_arn)
1✔
408
                # TODO: check if the DLQ exists
409
                dlq_url = get_queue_url(dlq_arn)
1✔
410
                # TODO: validate no FIFO queue because they are unsupported
411
                sqs_client.send_message(QueueUrl=dlq_url, MessageBody=json.dumps(dlq_event))
1✔
412
            elif service == "sns":
1✔
413
                sns_client = get_internal_client(dlq_arn)
1✔
414
                sns_client.publish(TopicArn=dlq_arn, Message=json.dumps(dlq_event))
1✔
415
            elif service == "s3":
1✔
416
                s3_client = get_internal_client(dlq_arn)
1✔
417
                dlq_event_with_payload = {
1✔
418
                    **dlq_event,
419
                    "payload": {
420
                        "Records": events,
421
                    },
422
                }
423
                s3_client.put_object(
1✔
424
                    Bucket=s3_bucket_name(dlq_arn),
425
                    Key=get_failure_s3_object_key(self.esm_uuid, shard_id, failure_timstamp),
426
                    Body=json.dumps(dlq_event_with_payload),
427
                )
428
            else:
429
                LOG.warning("Unsupported DLQ service %s", service)
×
430

431
    def create_dlq_event(
1✔
432
        self, shard_id: str, events: list[dict], context: dict, failure_timestamp: datetime
433
    ) -> dict:
434
        first_record = events[0]
1✔
435
        first_record_arrival = get_datetime_from_timestamp(
1✔
436
            self.get_approximate_arrival_time(first_record)
437
        )
438

439
        last_record = events[-1]
1✔
440
        last_record_arrival = get_datetime_from_timestamp(
1✔
441
            self.get_approximate_arrival_time(last_record)
442
        )
443
        return {
1✔
444
            **context,
445
            self.failure_payload_details_field_name(): {
446
                "approximateArrivalOfFirstRecord": self.format_datetime(first_record_arrival),
447
                "approximateArrivalOfLastRecord": self.format_datetime(last_record_arrival),
448
                "batchSize": len(events),
449
                "endSequenceNumber": self.get_sequence_number(last_record),
450
                "shardId": shard_id,
451
                "startSequenceNumber": self.get_sequence_number(first_record),
452
                "streamArn": self.source_arn,
453
            },
454
            "timestamp": failure_timestamp.isoformat(timespec="milliseconds").replace(
455
                "+00:00", "Z"
456
            ),
457
            "version": "1.0",
458
        }
459

460
    def max_retries_exceeded(self, attempts: int) -> bool:
1✔
461
        maximum_retry_attempts = self.stream_parameters.get("MaximumRetryAttempts", -1)
1✔
462
        # Infinite retries until the source expires
463
        if maximum_retry_attempts == -1:
1✔
464
            return False
1✔
465
        return attempts > maximum_retry_attempts
1✔
466

467
    def bisect_events(
1✔
468
        self, sequence_number: str, events: list[dict]
469
    ) -> tuple[list[dict], list[dict]]:
470
        """Splits list of events in two, where a sequence number equals a passed parameter `sequence_number`.
471
        This is used for:
472
          - `ReportBatchItemFailures`: Discarding events in a batch following a failure when is set.
473
          - `BisectBatchOnFunctionError`: Used to split a failed batch in two when doing a retry (not implemented)."""
474
        for i, event in enumerate(events):
1✔
475
            if self.get_sequence_number(event) == sequence_number:
1✔
476
                return events[:i], events[i:]
1✔
477

478
        return events, []
×
479

480

481
def get_failure_s3_object_key(esm_uuid: str, shard_id: str, failure_datetime: datetime) -> str:
1✔
482
    """
483
    From https://docs.aws.amazon.com/lambda/latest/dg/kinesis-on-failure-destination.html:
484

485
    The S3 object containing the invocation record uses the following naming convention:
486
    aws/lambda/<ESM-UUID>/<shardID>/YYYY/MM/DD/YYYY-MM-DDTHH.MM.SS-<Random UUID>
487

488
    :return: Key for s3 object that invocation failure record will be put to
489
    """
490
    timestamp = failure_datetime.strftime("%Y-%m-%dT%H.%M.%S")
1✔
491
    year_month_day = failure_datetime.strftime("%Y/%m/%d")
1✔
492
    random_uuid = long_uid()
1✔
493
    return f"aws/lambda/{esm_uuid}/{shard_id}/{year_month_day}/{timestamp}-{random_uuid}"
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc