Skip to content

fix(aws sinks): ensure component_sent_bytes_total carries component and region labels#25915

Open
Clee2691 wants to merge 4 commits into
vectordotdev:masterfrom
Clee2691:fix_aws_component_labels
Open

fix(aws sinks): ensure component_sent_bytes_total carries component and region labels#25915
Clee2691 wants to merge 4 commits into
vectordotdev:masterfrom
Clee2691:fix_aws_component_labels

Conversation

@Clee2691

@Clee2691 Clee2691 commented Jul 21, 2026

Copy link
Copy Markdown

Summary

  • Suppress transport-level AwsBytesSent for all Driver-based AWS sinks to eliminate duplicate component_sent_bytes_total metrics missing component labels
  • Route byte reporting through the Driver, which runs within the component tracing span
  • Add generic .label(key, value) builder on Driver; each AWS sink uses it to add a region label

Vector configuration

Any AWS sink config

How did you test this PR?

  • Added integration tests for all changed AWS sinks
  • See functional tests for the ClusterLogging Operator (for Cloudwatch & S3 only)

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details on the dd-rust-license-tool.

@Clee2691
Clee2691 requested a review from a team as a code owner July 21, 2026 17:23
@github-actions github-actions Bot added the domain: sinks Anything related to the Vector's sinks label Jul 21, 2026
@Clee2691
Clee2691 force-pushed the fix_aws_component_labels branch from d109fe6 to aecbef0 Compare July 21, 2026 17:25
@Clee2691

Copy link
Copy Markdown
Author

FYI: Had to force push for a rebase

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d109fe6c24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/aws/mod.rs Outdated
client.send(records, stream_name).await.map(|mut r| {
// augment the response
r.events_byte_size = events_byte_size;
r.byte_size = byte_size;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accumulate bytes across Kinesis partial retries

With request_retry_partial enabled, Kinesis retry logic can retry an HTTP 200 response that contained failed records; Tower discards that first successful response and only returns the final retry response to the Driver. Since this commit disables transport-level byte metrics and records only the last response's byte_size, component_sent_bytes_total misses bytes for the initial successful attempt (or all but the last partial retry). Please accumulate bytes across retry attempts or keep transport measurement for these retrying Kinesis services.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With request_retry_partial enabled on Kinesis Streams, Tower discards intermediate responses internally, so the Driver only sees the final retry response's byte_size and bytes from records that succeeded on earlier attempts go unrecorded.

Worth noting this class of problem also existed with the previous transport-level metrics, just in the opposite direction — AwsBytesSent was emitted for every HTTP request body, so the failed records' bytes were counted both in the original request and again in the retry, resulting in over-counting.

The fix is straightforward: carry an accumulated_bytes field on BatchKinesisRequest, compute the succeeded portion in the RetryPartial closure (original_encoded_size - retry_encoded_size), and have KinesisResponse::bytes_sent() return self.byte_size + self.accumulated_bytes. This stays localized to the Kinesis sink code with no changes to the retry infrastructure.

Since request_retry_partial defaults to false and only Kinesis Streams uses RetryPartial (Firehose does full retries), this is a narrow edge case that was already inaccurate before this PR. This could be done in a follow-up PR.

Comment thread src/sinks/aws_s_s/sink.rs
Comment thread src/sinks/aws_kinesis/service.rs Outdated
@Clee2691
Clee2691 force-pushed the fix_aws_component_labels branch from aecbef0 to e5ead33 Compare July 22, 2026 18:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5ead33b74

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 233 to +237
svc.oneshot(events)
.map_ok(move |_x| CloudwatchResponse { events_byte_size })
.map_ok(move |_x| CloudwatchResponse {
events_byte_size,
byte_size,
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count CloudWatch bytes per inner PutLogEvents attempt

When a CloudWatch batch spans more than 24 hours, CloudwatchLogsSvc::process_events splits this one Driver request into multiple PutLogEvents calls, and the retry layer wraps the whole Vec<InputLogEvent>. If an early inner PutLogEvents succeeds but a later split fails or causes the whole request to be retried, this only returns a byte count after the final oneshot succeeds and only once, so bytes from successful inner attempts are no longer counted now that transport-level metrics are disabled. Track successful PutLogEvents byte counts inside the CloudWatch future or accumulate them across retries before reporting through the Driver.

Useful? React with 👍 / 👎.

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

Labels

domain: sinks Anything related to the Vector's sinks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty component_sent_bytes_total but not in component_sent_event_bytes_total

1 participant