diff --git a/Cargo.lock b/Cargo.lock index 6ab71f7..4d5dd6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -145,6 +145,29 @@ dependencies = [ "tracing", ] +[[package]] +name = "aws-sdk-firehose" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebdf18cbbbe402d1d5254da7b2d406cd94f85f23f142127100d99855c44b2de6" +dependencies = [ + "aws-credential-types", + "aws-http", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.11", + "once_cell", + "regex-lite", + "tracing", +] + [[package]] name = "aws-sigv4" version = "1.1.3" @@ -1959,6 +1982,7 @@ version = "1.0.1" dependencies = [ "assert2", "aws-sdk-dynamodb", + "aws-sdk-firehose", "axum 0.7.4", "futures-util", "http 1.0.0", diff --git a/Cargo.toml b/Cargo.toml index b6e8509..54d057d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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 diff --git a/src/middleware/aws.rs b/src/middleware/aws.rs index b59a014..c7d1b5b 100644 --- a/src/middleware/aws.rs +++ b/src/middleware/aws.rs @@ -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"); @@ -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() + } + } +}