devtools_wire_format/generated/
rs.devtools.instrument.rs

1// This file is @generated by prost-build.
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct InstrumentRequest {
5    /// Allows filtering the log events.
6    #[prost(message, optional, tag = "2")]
7    pub log_filter: ::core::option::Option<Filter>,
8    /// Allows filtering the span events.
9    #[prost(message, optional, tag = "3")]
10    pub span_filter: ::core::option::Option<Filter>,
11}
12/// A filter configuration
13/// You can filter by level, file, log message or a combination of all three.
14#[allow(clippy::derive_partial_eq_without_eq)]
15#[derive(Clone, PartialEq, ::prost::Message)]
16pub struct Filter {
17    #[prost(enumeration = "super::common::metadata::Level", optional, tag = "1")]
18    pub level: ::core::option::Option<i32>,
19    #[prost(string, optional, tag = "2")]
20    pub file: ::core::option::Option<::prost::alloc::string::String>,
21    #[prost(string, optional, tag = "3")]
22    pub text: ::core::option::Option<::prost::alloc::string::String>,
23}
24/// An update about the state of the instrumented application.
25///
26/// An updated is comprised of a set of sub-updates about each tracked data source,
27/// they are combined into one message however to reduce the complexity for both
28/// the server and client as well as deduplicate data between updates:
29/// - a single timestamp for all updates
30/// - a single place for new_metadata
31#[allow(clippy::derive_partial_eq_without_eq)]
32#[derive(Clone, PartialEq, ::prost::Message)]
33pub struct Update {
34    /// The system time when this update was recorded.
35    #[prost(message, optional, tag = "1")]
36    pub at: ::core::option::Option<::prost_types::Timestamp>,
37    /// Any new metadata that was registered since the last update.
38    ///
39    /// The metadata_id fields in `LogEvent` and `Span` refer back to metadata registered through these updates.
40    #[prost(message, repeated, tag = "2")]
41    pub new_metadata: ::prost::alloc::vec::Vec<super::common::NewMetadata>,
42    /// Log events update.
43    #[prost(message, optional, tag = "3")]
44    pub logs_update: ::core::option::Option<super::logs::Update>,
45    /// Span events update.
46    #[prost(message, optional, tag = "4")]
47    pub spans_update: ::core::option::Option<super::spans::Update>,
48}
49/// Generated server implementations.
50#[allow(clippy::all)]
51pub mod instrument_server {
52    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
53    use tonic::codegen::*;
54    /// Generated trait containing gRPC methods that should be implemented for use with InstrumentServer.
55    #[async_trait]
56    pub trait Instrument: Send + Sync + 'static {
57        /// Server streaming response type for the WatchUpdates method.
58        type WatchUpdatesStream: tonic::codegen::tokio_stream::Stream<
59                Item = std::result::Result<super::Update, tonic::Status>,
60            >
61            + Send
62            + 'static;
63        /// Produces a stream of updates about the behavior of the  instrumented application.
64        async fn watch_updates(
65            &self,
66            request: tonic::Request<super::InstrumentRequest>,
67        ) -> std::result::Result<
68            tonic::Response<Self::WatchUpdatesStream>,
69            tonic::Status,
70        >;
71    }
72    /// Real time updates about components of an instrumented application.
73    #[derive(Debug)]
74    pub struct InstrumentServer<T: Instrument> {
75        inner: _Inner<T>,
76        accept_compression_encodings: EnabledCompressionEncodings,
77        send_compression_encodings: EnabledCompressionEncodings,
78        max_decoding_message_size: Option<usize>,
79        max_encoding_message_size: Option<usize>,
80    }
81    struct _Inner<T>(Arc<T>);
82    impl<T: Instrument> InstrumentServer<T> {
83        pub fn new(inner: T) -> Self {
84            Self::from_arc(Arc::new(inner))
85        }
86        pub fn from_arc(inner: Arc<T>) -> Self {
87            let inner = _Inner(inner);
88            Self {
89                inner,
90                accept_compression_encodings: Default::default(),
91                send_compression_encodings: Default::default(),
92                max_decoding_message_size: None,
93                max_encoding_message_size: None,
94            }
95        }
96        pub fn with_interceptor<F>(
97            inner: T,
98            interceptor: F,
99        ) -> InterceptedService<Self, F>
100        where
101            F: tonic::service::Interceptor,
102        {
103            InterceptedService::new(Self::new(inner), interceptor)
104        }
105        /// Enable decompressing requests with the given encoding.
106        #[must_use]
107        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
108            self.accept_compression_encodings.enable(encoding);
109            self
110        }
111        /// Compress responses with the given encoding, if the client supports it.
112        #[must_use]
113        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
114            self.send_compression_encodings.enable(encoding);
115            self
116        }
117        /// Limits the maximum size of a decoded message.
118        ///
119        /// Default: `4MB`
120        #[must_use]
121        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
122            self.max_decoding_message_size = Some(limit);
123            self
124        }
125        /// Limits the maximum size of an encoded message.
126        ///
127        /// Default: `usize::MAX`
128        #[must_use]
129        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
130            self.max_encoding_message_size = Some(limit);
131            self
132        }
133    }
134    impl<T, B> tonic::codegen::Service<http::Request<B>> for InstrumentServer<T>
135    where
136        T: Instrument,
137        B: Body + Send + 'static,
138        B::Error: Into<StdError> + Send + 'static,
139    {
140        type Response = http::Response<tonic::body::BoxBody>;
141        type Error = std::convert::Infallible;
142        type Future = BoxFuture<Self::Response, Self::Error>;
143        fn poll_ready(
144            &mut self,
145            _cx: &mut Context<'_>,
146        ) -> Poll<std::result::Result<(), Self::Error>> {
147            Poll::Ready(Ok(()))
148        }
149        fn call(&mut self, req: http::Request<B>) -> Self::Future {
150            let inner = self.inner.clone();
151            match req.uri().path() {
152                "/rs.devtools.instrument.Instrument/WatchUpdates" => {
153                    #[allow(non_camel_case_types)]
154                    struct WatchUpdatesSvc<T: Instrument>(pub Arc<T>);
155                    impl<
156                        T: Instrument,
157                    > tonic::server::ServerStreamingService<super::InstrumentRequest>
158                    for WatchUpdatesSvc<T> {
159                        type Response = super::Update;
160                        type ResponseStream = T::WatchUpdatesStream;
161                        type Future = BoxFuture<
162                            tonic::Response<Self::ResponseStream>,
163                            tonic::Status,
164                        >;
165                        fn call(
166                            &mut self,
167                            request: tonic::Request<super::InstrumentRequest>,
168                        ) -> Self::Future {
169                            let inner = Arc::clone(&self.0);
170                            let fut = async move {
171                                <T as Instrument>::watch_updates(&inner, request).await
172                            };
173                            Box::pin(fut)
174                        }
175                    }
176                    let accept_compression_encodings = self.accept_compression_encodings;
177                    let send_compression_encodings = self.send_compression_encodings;
178                    let max_decoding_message_size = self.max_decoding_message_size;
179                    let max_encoding_message_size = self.max_encoding_message_size;
180                    let inner = self.inner.clone();
181                    let fut = async move {
182                        let inner = inner.0;
183                        let method = WatchUpdatesSvc(inner);
184                        let codec = tonic::codec::ProstCodec::default();
185                        let mut grpc = tonic::server::Grpc::new(codec)
186                            .apply_compression_config(
187                                accept_compression_encodings,
188                                send_compression_encodings,
189                            )
190                            .apply_max_message_size_config(
191                                max_decoding_message_size,
192                                max_encoding_message_size,
193                            );
194                        let res = grpc.server_streaming(method, req).await;
195                        Ok(res)
196                    };
197                    Box::pin(fut)
198                }
199                _ => {
200                    Box::pin(async move {
201                        Ok(
202                            http::Response::builder()
203                                .status(200)
204                                .header("grpc-status", "12")
205                                .header("content-type", "application/grpc")
206                                .body(empty_body())
207                                .unwrap(),
208                        )
209                    })
210                }
211            }
212        }
213    }
214    impl<T: Instrument> Clone for InstrumentServer<T> {
215        fn clone(&self) -> Self {
216            let inner = self.inner.clone();
217            Self {
218                inner,
219                accept_compression_encodings: self.accept_compression_encodings,
220                send_compression_encodings: self.send_compression_encodings,
221                max_decoding_message_size: self.max_decoding_message_size,
222                max_encoding_message_size: self.max_encoding_message_size,
223            }
224        }
225    }
226    impl<T: Instrument> Clone for _Inner<T> {
227        fn clone(&self) -> Self {
228            Self(Arc::clone(&self.0))
229        }
230    }
231    impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
232        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
233            write!(f, "{:?}", self.0)
234        }
235    }
236    impl<T: Instrument> tonic::server::NamedService for InstrumentServer<T> {
237        const NAME: &'static str = "rs.devtools.instrument.Instrument";
238    }
239}