fix(security): inherit component_type on confinement gauge from ambient span#25919
Draft
vladimir-dd wants to merge 2 commits into
Draft
fix(security): inherit component_type on confinement gauge from ambient span#25919vladimir-dd wants to merge 2 commits into
vladimir-dd wants to merge 2 commits into
Conversation
…nt span ConfinementConfig::set_confinement_gauge explicitly hardcoded component_type/component_kind labels from the calling sink's own Self::NAME, unlike every other per-component metric (e.g. component_sent_events_total), which inherits component_type from the ambient tracing span the topology builder opens around the whole SinkConfig::build call. This mismatch is harmless for a sink built directly, but breaks when one sink delegates its build to another SinkConfig::build internally (e.g. humio_metrics -> humio_logs), or when an external sink constructs and builds a Vector sink directly (e.g. Datadog's observability-pipelines-worker crowdstrike_next_gen_siem sink delegating to humio_logs, see DataDog/observability-pipelines-worker#2652) -- the gauge reports the delegate's own component type instead of the wrapping sink's, while every other metric on the same build correctly reports the wrapping sink's type. Drop the explicit labels and let the gauge inherit from the ambient span like everything else, so delegating/wrapping sinks report the correct component_type with no extra plumbing. Environment: Datadog workspace Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… inheritance Adds a unit test for the fix in 8eac9b0 that verifies the security_confinement_disabled gauge inherits component_type from the ambient tracing span (e.g. a wrapping external sink) rather than hardcoding the delegated sink's own type. Verified this test fails against the pre-fix behavior and passes against the fix. Environment: Datadog workspace Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConfinementConfig::set_confinement_gaugeexplicitly hardcodedcomponent_type/component_kindlabels from the calling sink's ownSelf::NAME. This is the only per-component metric in Vector that does this — every other one (e.g.component_sent_events_total,http_client_requests_sent_total) inheritscomponent_typefrom the ambient tracing span the topology builder opens around the wholeSinkConfig::buildcall (component_type = %sink.inner.get_component_name()insrc/topology/builder.rs).That's harmless when a sink is built directly, since
Self::NAMEmatches the ambient span's type anyway. But it breaks when:SinkConfig::buildinternally (e.g.humio_metrics→humio_logs), or.build()on it directly to wrap it.In both cases the gauge reports the delegate's own component type instead of the wrapping sink's — while every other metric on that same build correctly reports the wrapping sink's type, because they don't override the ambient span.
Fix
Drop the explicit
component_kind/component_typeparameters fromset_confinement_gaugeentirely and let it inherit from the ambient span like every other metric. Updated all 27 call sites across the sink modules accordingly. No behavior change for sinks built directly; delegating/wrapping sinks now report the correct component type with no extra plumbing.An earlier version of this fix instead widened
HumioLogsConfig::build_without_confinement_gauge's visibility so external wrappers could pass their own component name explicitly — that would have worked for this one case but wouldn't have fixed the general inconsistency (any future delegating/wrapping sink would hit the same bug), so this PR fixes the actual root cause instead.Vector configuration
N/A — this only changes internal metric tagging, not sink behavior or configuration surface.
How did you test this PR?
cargo check -p vector --lib --no-default-features --features sinks— clean, no errors/warnings.cargo clippy -p vector --lib --no-default-features --features sinks --no-deps— clean.cargo test -p vector --lib --no-default-features --features sinks template::— 42 passed, 0 failed.cargo fmtChange Type
Is this a breaking change?
Does this PR include user facing changes?
changelog.d/confinement_gauge_component_type_override.fix.md.References