aws_smithy_http_server/instrumentation/
plugin.rs1use crate::plugin::{HttpMarker, HttpPlugins, PluginStack};
7use crate::{operation::OperationShape, plugin::Plugin};
8
9use super::sensitivity::Sensitivity;
10use super::InstrumentOperation;
11
12#[derive(Debug)]
14pub struct InstrumentPlugin;
15
16impl<Ser, Op, T> Plugin<Ser, Op, T> for InstrumentPlugin
17where
18 Op: OperationShape,
19 Op: Sensitivity,
20{
21 type Output = InstrumentOperation<T, Op::RequestFmt, Op::ResponseFmt>;
22
23 fn apply(&self, input: T) -> Self::Output {
24 InstrumentOperation::new(input, Op::ID)
25 .request_fmt(Op::request_fmt())
26 .response_fmt(Op::response_fmt())
27 }
28}
29
30impl HttpMarker for InstrumentPlugin {}
31
32pub trait InstrumentExt<CurrentPlugin> {
34 fn instrument(self) -> HttpPlugins<PluginStack<InstrumentPlugin, CurrentPlugin>>;
39}
40
41impl<CurrentPlugin> InstrumentExt<CurrentPlugin> for HttpPlugins<CurrentPlugin> {
42 fn instrument(self) -> HttpPlugins<PluginStack<InstrumentPlugin, CurrentPlugin>> {
43 self.push(InstrumentPlugin)
44 }
45}