Skip to content

fix(core): unreadable interval_ms #23361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 14, 2025
Merged

Conversation

thomasqueirozb
Copy link
Contributor

@thomasqueirozb thomasqueirozb commented Jul 11, 2025

Summary

Make interval_ms readable from VRL

Vector configuration

sources:
  s0:
    type: static_metrics
    interval_secs: 1
    metrics:
      - name: response_time
        kind: incremental
        value:
          counter:
            value: 1
        tags: {}



transforms:
  t0:
    type: remap
    inputs:
      - s0
    source: |-
      .tags.exists_in_t0_start = to_string(exists(.interval_ms)) # true
      .tags.original_interval_ms = to_string!(.interval_ms) # 1000
      del(.interval_ms)
      .tags.exists_in_t0_end = to_string(exists(.interval_ms)) # false
  t1:
    type: remap
    inputs:
      - t0
    source: |-
      .tags.exists_in_t1_start = to_string(exists(.interval_ms)) # false
      .interval_ms = 666
      .tags.exists_in_t1_end = to_string(exists(.interval_ms)) # true
  t2:
    type: remap
    inputs:
      - t1
    source: |-
      .tags.exists_in_t2_start = to_string(exists(.interval_ms)) # true
      .tags.last_interval_ms = to_string!(.interval_ms) # 666


sinks:
  console:
    type: console
    inputs:
      - t2
    target: stdout
    encoding:
      codec: json
      json:
        pretty: true

How did you test this PR?

Ran the vector config, output should look something like this:

{
  "name": "response_time",
  "namespace": "static",
  "tags": {
    "exists_in_t0_end": "false",
    "exists_in_t0_start": "true",
    "exists_in_t1_end": "true",
    "exists_in_t1_start": "false",
    "exists_in_t2_start": "true",
    "last_interval_ms": "666",
    "original_interval_ms": "1000"
  },
  "timestamp": "2025-07-14T13:23:48.976670Z",
  "interval_ms": 666,
  "kind": "incremental",
  "counter": {
    "value": 1.0
  }
}

Change Type

  • Bug fix
  • New feature
  • 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

Closes: #23358
Related: #23221
Caused by: #23217

@github-actions github-actions bot added the domain: core Anything related to core crates i.e. vector-core, core-common, etc label Jul 11, 2025
@datadog-vectordotdev
Copy link

datadog-vectordotdev bot commented Jul 11, 2025

Datadog Report

Branch report: fix-unreadable-interval-ms
Commit report: d1c772c
Test service: vector

✅ 0 Failed, 591 Passed, 0 Skipped, 4m 7.63s Total Time

@thomasqueirozb thomasqueirozb marked this pull request as ready for review July 11, 2025 19:24
@thomasqueirozb thomasqueirozb requested a review from a team as a code owner July 11, 2025 19:24
@pront pront requested a review from Copilot July 11, 2025 19:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how metric properties are populated in precompute_metric_value and adds support for exposing interval_ms in VRL, including updates to tests.

  • Refactored property insertion to use a MetricProperty helper struct for cleaner logic.
  • Added interval_ms as a first‐class metric property in both code and tests.
Comments suppressed due to low confidence (2)

lib/vector-core/src/event/vrl_target.rs:557

  • [nitpick] Consider renaming the set field to something more descriptive like inserted or populated to clearly convey its purpose.
        set: bool,

lib/vector-core/src/event/vrl_target.rs:587

  • Add a test case for when metric.interval_ms is None and requested in VRL to verify that the field is correctly omitted or handled.
        MetricProperty::new("interval_ms", |metric| metric.interval_ms().map(Into::into));

Co-authored-by: Pavlos Rontidis <pavlos.rontidis@gmail.com>
@pront pront added the domain: vrl Anything related to the Vector Remap Language label Jul 11, 2025
@github-actions github-actions bot removed the domain: vrl Anything related to the Vector Remap Language label Jul 11, 2025
@thomasqueirozb thomasqueirozb enabled auto-merge July 11, 2025 20:00
@pront
Copy link
Member

pront commented Jul 14, 2025

@thomasqueirozb thomasqueirozb added this pull request to the merge queue Jul 14, 2025
Merged via the queue into master with commit 8d95e23 Jul 14, 2025
77 checks passed
@thomasqueirozb thomasqueirozb deleted the fix-unreadable-interval-ms branch July 14, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: core Anything related to core crates i.e. vector-core, core-common, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

interval_ms field cannot be read
2 participants