Skip to content

[SVLS-8713] feat(logs-agent): add a retry-only method and an optional flush policy - #193

Draft
litianningdatadog wants to merge 1 commit into
tianning.li/logs-sc-3a-key-and-urlfrom
tianning.li/logs-sc-3b-retry-and-policy
Draft

litianningdatadog wants to merge 1 commit into
tianning.li/logs-sc-3a-key-and-urlfrom
tianning.li/logs-sc-3b-retry-and-policy

Conversation

@litianningdatadog

@litianningdatadog litianningdatadog commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  • LogFlusher::retry(Vec<RequestBuilder>): resends handed-back requests without draining the aggregator.
  • with_policy(FlushPolicy) with retry_client_errors, return_additional_endpoint_failures, parallel_additional_endpoints and failure_logging: FailureLogging { PerAttempt (default), OncePerRequest }. OncePerRequest writes one error line per failed request, including the cause (status or transport error).
  • #[non_exhaustive] on the new enums so variants can be added later.

Motivation

Part of SVLS-8713: bottlecap (the Datadog Lambda Extension) is replacing its own logs aggregator and flusher with this crate. Two rules for the whole stack:

  • Nothing changes for existing users of this crate (for example serverless-compat): every new behavior is opt-in, defaults and public API stay the same (additions only), no new environment variables, no new dependencies.
  • Nothing changes for Lambda users: the options let bottlecap reproduce its current behavior exactly.

bottlecap resends a failed request once on the next flush; doing that with flush() would also drain new logs whose results are then discarded, so logs would be lost. It also retries most 4xx (403 stays terminal), hands back failures from additional endpoints, sends to all endpoints at once, and writes one error line per failed request: the extension re-ingests its own output, so a warning per attempt would add log volume.

Additional Notes

FlushPolicy::default() is today's behavior, so nothing changes for existing users.

Describe how to test/QA your changes

109 tests pass (new: retry doesn't drain, each policy switch, the full bottlecap policy, one-error-per-request logging with the cause). All sc-0 tests unchanged.

Stack

Each PR is nested under the PR it builds on (and targets). Review and merge from the top down.

serverless-components (datadog-logs-agent options; merge first)

datadog-lambda-extension (bottlecap)

🤖 Generated with Claude Code

Why: bottlecap resends failed requests once on the next flush without pulling
new logs, retries most client errors, resends failures for additional
endpoints, sends to all endpoints at once, and writes one error line instead
of a warning per attempt. This crate did none of those, so bottlecap could not
use it without changing what Lambda users see.

What: the flusher gets retry(), which resends handed-back requests without
draining the aggregator, and with_policy(), which takes a FlushPolicy with
switches for those behaviors and a choice of failure logging.
FlushPolicy::default() is today's behavior, so nothing changes for existing
users.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@litianningdatadog
litianningdatadog force-pushed the tianning.li/logs-sc-3b-retry-and-policy branch from 5ac08a9 to a562801 Compare October 21, 2026 19:52
@litianningdatadog
litianningdatadog force-pushed the tianning.li/logs-sc-3a-key-and-url branch from a107102 to 7105107 Compare October 21, 2026 19:52

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant