Skip to content

Commit

Permalink
add span for firehose
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypadma committed Jan 24, 2024
1 parent afbe6da commit 9b45f6d
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ futures-util = { version = "0.3.30", default_features = false, features = [], op
hyper = { version = "1.1.0", default-features = false, features = ["http1", "client"], optional = true }
http-body-util = { version = "0.1.0", optional = true }
aws-sdk-dynamodb = { version = "1.7.0", optional = true }
aws-sdk-firehose = { version = "1.7.0", optional = true }


[dev-dependencies]
assert2 = "0.3.11"
Expand All @@ -50,8 +52,9 @@ otlp = ["opentelemetry-otlp/http-proto", "tracer", "dep:tracing-opentelemetry-in
tracer = ["dep:opentelemetry-semantic-conventions"]
integration_test = ["axum", "dep:serde", "dep:serde_json", "dep:opentelemetry_api", "dep:rand", "dep:hyper", "dep:http-body-util"]
axum = ["dep:axum", "dep:tower", "dep:futures-util", "dep:pin-project-lite", "dep:tracing-opentelemetry-instrumentation-sdk"]
aws = ["aws-dynamodb"]
aws = ["aws-dynamodb", "aws-firehose"]
aws-dynamodb = ["dep:aws-sdk-dynamodb"]
aws-firehose = ["dep:aws-sdk-firehose"]

[profile.dev]
lto = false
Expand Down
38 changes: 37 additions & 1 deletion src/middleware/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn info_span_dynamo(
service = tracing::field::Empty,
cloud.region = tracing::field::Empty,
http_client = tracing::field::Empty,
status = tracing::field::Empty,
success = false,
);
let _ = span.enter();
span.record("dynamoDB", &"true");
Expand All @@ -42,3 +42,39 @@ pub fn info_span_dynamo(
}
}
}

#[cfg(any(feature = "aws", feature = "aws_firehose"))]
pub fn info_span_firehose(
firehose_client: &aws_sdk_firehose::Client,
firehose_stream_name: &str,
operation: &str,
method: &str,
) -> tracing::Span {
{
// Spans will be sent to the configured OpenTelemetry exporter
// use telemetry_rust::OpenTelemetrySpanExt;
let config = firehose_client.config();
if let Some(region) = config.region() {
let span = tracing::info_span!(
"aws_firehose",
firehose = tracing::field::Empty,
operation = tracing::field::Empty,
firehose_stream_name = tracing::field::Empty,
method = tracing::field::Empty,
service = tracing::field::Empty,
cloud.region = tracing::field::Empty,
status = tracing::field::Empty,
);
let _ = span.enter();
span.record("firehose", &"true");
span.record("operation", &operation);
span.record("firehose_stream_name", &firehose_stream_name);
span.record("method", &method);
span.record("service", "AWS::Firehose");
span.record("cloud.region", region.as_ref());
span
} else {
tracing::Span::none()
}
}
}

0 comments on commit 9b45f6d

Please sign in to comment.