Skip to content

feat(new transform): add a simple delay transform#25407

Open
esensar wants to merge 10 commits into
vectordotdev:masterfrom
esensar:feature/delay-transform
Open

feat(new transform): add a simple delay transform#25407
esensar wants to merge 10 commits into
vectordotdev:masterfrom
esensar:feature/delay-transform

Conversation

@esensar
Copy link
Copy Markdown
Contributor

@esensar esensar commented May 11, 2026

Summary

Adds a new transform which delays each event in the pipeline by a fixed duration.

Vector configuration

sources:
  demo_logs_test:
    type: "demo_logs"
    format: "json"

transforms:
  delay_transform:
    inputs: ["demo_logs_test"]
    type: "delay"
    delay_per_event: 5

sinks:
  console:
    inputs: ["delay_transform"]
    target: "stdout"
    type: "console"
    acknowledgements:
      enabled: false
    encoding:
      codec: "json"

How did you test this PR?

Ran the included test and ran Vector with the above configuration to confirm that events were correctly delayed.

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.

Sponsored by Quad9

@esensar esensar requested review from a team as code owners May 11, 2026 08:53
@github-actions github-actions Bot added domain: transforms Anything related to Vector's transform components domain: external docs Anything related to Vector's external, public documentation docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. labels May 11, 2026
Copy link
Copy Markdown

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

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: c81015ff6f

ℹ️ 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/transforms/delay.rs
Copy link
Copy Markdown
Member

@pront pront left a comment

Choose a reason for hiding this comment

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

One idea worth considering is adding a VRL condition for each event in order to answer "do i want to forward this event now?". We could also add retries + exponential backoff. Non-blocking but something worth considering.

Copy link
Copy Markdown
Member

@thomasqueirozb thomasqueirozb left a comment

Choose a reason for hiding this comment

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

Hi @esensar. Thanks for this! I thought about implementing this myself a couple of times before.

This is missing website/cue/reference/components/transforms/delay.cue and website/content/en/docs/reference/configuration/transforms/delay.md

Comment thread src/transforms/delay.rs Outdated
@thomasqueirozb thomasqueirozb added transform: new Request or implementation of a new transform meta: awaiting author Pull requests that are awaiting their author. labels May 13, 2026
@esensar
Copy link
Copy Markdown
Contributor Author

esensar commented May 14, 2026

One idea worth considering is adding a VRL condition for each event in order to answer "do i want to forward this event now?". We could also add retries + exponential backoff. Non-blocking but something worth considering.

That sounds good. This is probably too simple the way it is (even though it could probably be combined with other components to achieve some of these things).

I am not sure about retries though. What would we be retrying here?

Co-authored-by: Thomas <thomasqueirozb@gmail.com>
@github-actions github-actions Bot removed the meta: awaiting author Pull requests that are awaiting their author. label May 14, 2026
@esensar
Copy link
Copy Markdown
Contributor Author

esensar commented May 14, 2026

Hi @esensar. Thanks for this! I thought about implementing this myself a couple of times before.

This is missing website/cue/reference/components/transforms/delay.cue and website/content/en/docs/reference/configuration/transforms/delay.md

I just ran generate-component-docs, I forget that new components need some new files too. I will update.

Copy link
Copy Markdown

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

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: 7d93ced0b2

ℹ️ 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/transforms/delay.rs
@pront
Copy link
Copy Markdown
Member

pront commented May 14, 2026

I am not sure about retries though. What would we be retrying here?

@esensar some condition until it is evaluates to true and the event can be forwarded

@esensar
Copy link
Copy Markdown
Contributor Author

esensar commented May 14, 2026

I am not sure about retries though. What would we be retrying here?

@esensar some condition until it is evaluates to true and the event can be forwarded

Oh, alright, that is interesting. I will see about adding that in too.

Copy link
Copy Markdown

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

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: cc922cb2ff

ℹ️ 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/transforms/delay.rs Outdated
@esensar
Copy link
Copy Markdown
Contributor Author

esensar commented May 14, 2026

I am not sure about retries though. What would we be retrying here?

@esensar some condition until it is evaluates to true and the event can be forwarded

What do we do if it never evaluates to true? Or do we just leave that to the user to ensure? (with some warning probably)

@esensar
Copy link
Copy Markdown
Contributor Author

esensar commented May 14, 2026

I am not sure about retries though. What would we be retrying here?

@esensar some condition until it is evaluates to true and the event can be forwarded

I just realized that the static condition that I added is not useful at all, since that functionality can be provided by filter transform before the delay transform, while that delay until some condition is met can be more useful.

Copy link
Copy Markdown

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

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: 03c62f57fa

ℹ️ 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/transforms/delay.rs
Comment on lines +141 to +142
while capacity.get() <= self.queue.len() && let Some(next) = self.queue.next().await {
yield next.into_inner();
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 Apply delay condition when unblocking a full queue

When queue_capacity is set and the default overflow_strategy = "block" is used, this path drains an expired queued event directly to the output to make room for the new event. That bypasses the delay_until_condition.check(...) logic used in the normal queue-expiry branch, so a queued event is emitted as soon as its first delay expires even if delay_until_condition is still false whenever the queue is full and another input event arrives.

Useful? React with 👍 / 👎.

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

Labels

docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain: external docs Anything related to Vector's external, public documentation domain: transforms Anything related to Vector's transform components transform: new Request or implementation of a new transform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: sleep() function for inserting delay into processing chain

4 participants