telemetry_rust/middleware/aws/operations/
firehose.rs

1use crate::{KeyValue, StringValue, semconv};
2
3use super::*;
4
5/// Builder for Firehose-specific OpenTelemetry spans.
6///
7/// This enum serves as a namespace for Firehose operation span builders.
8/// Each operation provides a specific method to create properly configured
9/// spans with Firehose-specific messaging attributes.
10pub enum FirehoseSpanBuilder {}
11
12impl AwsSpanBuilder<'_> {
13    /// Creates a Firehose operation span builder.
14    ///
15    /// This method creates a span builder configured for Firehose operations with
16    /// appropriate messaging semantic attributes.
17    ///
18    /// # Arguments
19    ///
20    /// * `operation_kind` - The type of messaging operation being performed
21    /// * `method` - The Firehose operation method name
22    /// * `stream_name` - Optional stream name for operations that target specific streams
23    pub fn firehose(
24        operation_kind: MessagingOperationKind,
25        method: impl Into<StringValue>,
26        stream_name: Option<impl Into<StringValue>>,
27    ) -> Self {
28        let mut attributes = vec![
29            KeyValue::new(semconv::MESSAGING_SYSTEM, "aws_firehose"),
30            KeyValue::new(semconv::MESSAGING_OPERATION_TYPE, operation_kind.as_str()),
31        ];
32        if let Some(stream_name) = stream_name {
33            attributes.push(KeyValue::new(
34                semconv::MESSAGING_DESTINATION_NAME,
35                stream_name.into(),
36            ))
37        }
38        Self::new(operation_kind.into(), "Firehose", method, attributes)
39    }
40}
41
42macro_rules! firehose_global_operation {
43    ($op: ident) => {
44        impl FirehoseSpanBuilder {
45            #[doc = concat!("Creates a span builder for the Firehose ", stringify!($op), " global operation.")]
46            #[inline]
47            pub fn $op<'a>() -> AwsSpanBuilder<'a> {
48                AwsSpanBuilder::firehose(
49                    MessagingOperationKind::Control,
50                    stringify_camel!($op),
51                    None::<StringValue>,
52                )
53            }
54        }
55    };
56}
57
58macro_rules! firehose_publish_operation {
59    ($op: ident, $kind: expr) => {
60        impl FirehoseSpanBuilder {
61            #[doc = concat!("Creates a span builder for the Firehose ", stringify!($op), " operation.")]
62            ///
63            /// # Arguments
64            ///
65            /// * `stream_name` - The name of the Firehose delivery stream
66            pub fn $op<'a>(stream_name: impl Into<StringValue>) -> AwsSpanBuilder<'a> {
67                AwsSpanBuilder::firehose($kind, stringify_camel!($op), Some(stream_name))
68            }
69        }
70    };
71}
72
73macro_rules! firehose_stream_operation {
74    ($op: ident) => {
75        impl FirehoseSpanBuilder {
76            #[doc = concat!("Creates a span builder for the Firehose ", stringify!($op), " stream operation.")]
77            ///
78            /// # Arguments
79            ///
80            /// * `stream_name` - The name of the Firehose delivery stream
81            pub fn $op<'a>(stream_name: impl Into<StringValue>) -> AwsSpanBuilder<'a> {
82                AwsSpanBuilder::firehose(
83                    MessagingOperationKind::Control,
84                    stringify_camel!($op),
85                    Some(stream_name),
86                )
87            }
88        }
89    };
90}
91
92// publish operation
93firehose_publish_operation!(put_record, MessagingOperationKind::Create);
94firehose_publish_operation!(put_record_batch, MessagingOperationKind::Send);
95
96// global operations
97firehose_global_operation!(list_delivery_streams);
98
99// control plane stream operations
100firehose_stream_operation!(create_delivery_stream);
101firehose_stream_operation!(delete_delivery_stream);
102firehose_stream_operation!(describe_delivery_stream);
103firehose_stream_operation!(list_tags_for_delivery_stream);
104firehose_stream_operation!(start_delivery_stream_encryption);
105firehose_stream_operation!(stop_delivery_stream_encryption);
106firehose_stream_operation!(tag_delivery_stream);
107firehose_stream_operation!(untag_delivery_stream);
108firehose_stream_operation!(update_destination);