Skip to content
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

fix(observability): propagate tracing span context in stream sink request building #19712

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vector logs and internal metrics emitted while in the context of stream sink request building, now correctly contain the component's automatic tags (`component_kind`, `component_type`, `component_id`).
neuronull marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions src/sinks/util/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::{
use futures_util::{stream::Map, Stream, StreamExt};
use pin_project::pin_project;
use tower::Service;
use tracing::Span;
use vector_lib::stream::{
batcher::{config::BatchConfig, Batcher},
ConcurrentMap, Driver, DriverResponse, ExpirationQueue, PartitionedBatcher,
Expand Down Expand Up @@ -115,10 +116,17 @@ pub trait SinkBuilderExt: Stream {
{
let builder = Arc::new(builder);

// The future passed into the concurrent map is spawned in a tokio thread so we must preserve
// the span context in order to propagate the sink's automatic tags.
let span = Arc::new(Span::current());

self.concurrent_map(limit, move |input| {
let builder = Arc::clone(&builder);
let span = Arc::clone(&span);

Box::pin(async move {
let _entered = span.enter();

// Split the input into metadata and events.
let (metadata, request_metadata_builder, events) = builder.split_input(input);

Expand Down
Loading