use aws_smithy_runtime::client::sdk_feature::SmithySdkFeature;
use aws_smithy_runtime_api::{
box_error::BoxError,
client::interceptors::{context::BeforeSerializationInterceptorContextRef, Intercept},
};
use aws_smithy_types::config_bag::ConfigBag;
#[derive(Debug, Default)]
pub(crate) struct ObservabilityFeatureTrackerInterceptor;
impl Intercept for ObservabilityFeatureTrackerInterceptor {
fn name(&self) -> &'static str {
"ObservabilityFeatureTrackerInterceptor"
}
fn read_before_execution(&self, _context: &BeforeSerializationInterceptorContextRef<'_>, cfg: &mut ConfigBag) -> Result<(), BoxError> {
if let Ok(telemetry_provider) = aws_smithy_observability::global::get_telemetry_provider() {
let meter_provider = telemetry_provider.meter_provider();
if meter_provider.provider_name() == "AwsSmithyObservabilityOtelProvider" {
cfg.interceptor_state().store_append(SmithySdkFeature::ObservabilityOtelMetrics);
}
}
Ok(())
}
}