opentelemetry_proto/proto/tonic/
opentelemetry.proto.collector.trace.v1.rs

1// This file is @generated by prost-build.
2#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
3#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
4#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
5#[allow(clippy::derive_partial_eq_without_eq)]
6#[derive(Clone, PartialEq, ::prost::Message)]
7pub struct ExportTraceServiceRequest {
8    /// An array of ResourceSpans.
9    /// For data coming from a single resource this array will typically contain one
10    /// element. Intermediary nodes (such as OpenTelemetry Collector) that receive
11    /// data from multiple origins typically batch the data before forwarding further and
12    /// in that case this array will contain multiple elements.
13    #[prost(message, repeated, tag = "1")]
14    pub resource_spans: ::prost::alloc::vec::Vec<
15        super::super::super::trace::v1::ResourceSpans,
16    >,
17}
18#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
19#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
20#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
21#[allow(clippy::derive_partial_eq_without_eq)]
22#[derive(Clone, PartialEq, ::prost::Message)]
23pub struct ExportTraceServiceResponse {
24    /// The details of a partially successful export request.
25    ///
26    /// If the request is only partially accepted
27    /// (i.e. when the server accepts only parts of the data and rejects the rest)
28    /// the server MUST initialize the `partial_success` field and MUST
29    /// set the `rejected_<signal>` with the number of items it rejected.
30    ///
31    /// Servers MAY also make use of the `partial_success` field to convey
32    /// warnings/suggestions to senders even when the request was fully accepted.
33    /// In such cases, the `rejected_<signal>` MUST have a value of `0` and
34    /// the `error_message` MUST be non-empty.
35    ///
36    /// A `partial_success` message with an empty value (rejected_<signal> = 0 and
37    /// `error_message` = "") is equivalent to it not being set/present. Senders
38    /// SHOULD interpret it the same way as in the full success case.
39    #[prost(message, optional, tag = "1")]
40    pub partial_success: ::core::option::Option<ExportTracePartialSuccess>,
41}
42#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
43#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
44#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
45#[allow(clippy::derive_partial_eq_without_eq)]
46#[derive(Clone, PartialEq, ::prost::Message)]
47pub struct ExportTracePartialSuccess {
48    /// The number of rejected spans.
49    ///
50    /// A `rejected_<signal>` field holding a `0` value indicates that the
51    /// request was fully accepted.
52    #[prost(int64, tag = "1")]
53    pub rejected_spans: i64,
54    /// A developer-facing human-readable message in English. It should be used
55    /// either to explain why the server rejected parts of the data during a partial
56    /// success or to convey warnings/suggestions during a full success. The message
57    /// should offer guidance on how users can address such issues.
58    ///
59    /// error_message is an optional field. An error_message with an empty value
60    /// is equivalent to it not being set.
61    #[prost(string, tag = "2")]
62    pub error_message: ::prost::alloc::string::String,
63}
64/// Generated client implementations.
65#[cfg(feature = "gen-tonic")]
66pub mod trace_service_client {
67    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
68    use tonic::codegen::*;
69    use tonic::codegen::http::Uri;
70    /// Service that can be used to push spans between one Application instrumented with
71    /// OpenTelemetry and a collector, or between a collector and a central collector (in this
72    /// case spans are sent/received to/from multiple Applications).
73    #[derive(Debug, Clone)]
74    pub struct TraceServiceClient<T> {
75        inner: tonic::client::Grpc<T>,
76    }
77    impl TraceServiceClient<tonic::transport::Channel> {
78        /// Attempt to create a new client by connecting to a given endpoint.
79        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
80        where
81            D: TryInto<tonic::transport::Endpoint>,
82            D::Error: Into<StdError>,
83        {
84            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
85            Ok(Self::new(conn))
86        }
87    }
88    impl<T> TraceServiceClient<T>
89    where
90        T: tonic::client::GrpcService<tonic::body::BoxBody>,
91        T::Error: Into<StdError>,
92        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
93        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
94    {
95        pub fn new(inner: T) -> Self {
96            let inner = tonic::client::Grpc::new(inner);
97            Self { inner }
98        }
99        pub fn with_origin(inner: T, origin: Uri) -> Self {
100            let inner = tonic::client::Grpc::with_origin(inner, origin);
101            Self { inner }
102        }
103        pub fn with_interceptor<F>(
104            inner: T,
105            interceptor: F,
106        ) -> TraceServiceClient<InterceptedService<T, F>>
107        where
108            F: tonic::service::Interceptor,
109            T::ResponseBody: Default,
110            T: tonic::codegen::Service<
111                http::Request<tonic::body::BoxBody>,
112                Response = http::Response<
113                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
114                >,
115            >,
116            <T as tonic::codegen::Service<
117                http::Request<tonic::body::BoxBody>,
118            >>::Error: Into<StdError> + Send + Sync,
119        {
120            TraceServiceClient::new(InterceptedService::new(inner, interceptor))
121        }
122        /// Compress requests with the given encoding.
123        ///
124        /// This requires the server to support it otherwise it might respond with an
125        /// error.
126        #[must_use]
127        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
128            self.inner = self.inner.send_compressed(encoding);
129            self
130        }
131        /// Enable decompressing responses.
132        #[must_use]
133        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
134            self.inner = self.inner.accept_compressed(encoding);
135            self
136        }
137        /// Limits the maximum size of a decoded message.
138        ///
139        /// Default: `4MB`
140        #[must_use]
141        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
142            self.inner = self.inner.max_decoding_message_size(limit);
143            self
144        }
145        /// Limits the maximum size of an encoded message.
146        ///
147        /// Default: `usize::MAX`
148        #[must_use]
149        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
150            self.inner = self.inner.max_encoding_message_size(limit);
151            self
152        }
153        /// For performance reasons, it is recommended to keep this RPC
154        /// alive for the entire life of the application.
155        pub async fn export(
156            &mut self,
157            request: impl tonic::IntoRequest<super::ExportTraceServiceRequest>,
158        ) -> std::result::Result<
159            tonic::Response<super::ExportTraceServiceResponse>,
160            tonic::Status,
161        > {
162            self.inner
163                .ready()
164                .await
165                .map_err(|e| {
166                    tonic::Status::new(
167                        tonic::Code::Unknown,
168                        format!("Service was not ready: {}", e.into()),
169                    )
170                })?;
171            let codec = tonic::codec::ProstCodec::default();
172            let path = http::uri::PathAndQuery::from_static(
173                "/opentelemetry.proto.collector.trace.v1.TraceService/Export",
174            );
175            let mut req = request.into_request();
176            req.extensions_mut()
177                .insert(
178                    GrpcMethod::new(
179                        "opentelemetry.proto.collector.trace.v1.TraceService",
180                        "Export",
181                    ),
182                );
183            self.inner.unary(req, path, codec).await
184        }
185    }
186}
187/// Generated server implementations.
188#[cfg(feature = "gen-tonic")]
189pub mod trace_service_server {
190    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
191    use tonic::codegen::*;
192    /// Generated trait containing gRPC methods that should be implemented for use with TraceServiceServer.
193    #[async_trait]
194    pub trait TraceService: Send + Sync + 'static {
195        /// For performance reasons, it is recommended to keep this RPC
196        /// alive for the entire life of the application.
197        async fn export(
198            &self,
199            request: tonic::Request<super::ExportTraceServiceRequest>,
200        ) -> std::result::Result<
201            tonic::Response<super::ExportTraceServiceResponse>,
202            tonic::Status,
203        >;
204    }
205    /// Service that can be used to push spans between one Application instrumented with
206    /// OpenTelemetry and a collector, or between a collector and a central collector (in this
207    /// case spans are sent/received to/from multiple Applications).
208    #[derive(Debug)]
209    pub struct TraceServiceServer<T: TraceService> {
210        inner: Arc<T>,
211        accept_compression_encodings: EnabledCompressionEncodings,
212        send_compression_encodings: EnabledCompressionEncodings,
213        max_decoding_message_size: Option<usize>,
214        max_encoding_message_size: Option<usize>,
215    }
216    impl<T: TraceService> TraceServiceServer<T> {
217        pub fn new(inner: T) -> Self {
218            Self::from_arc(Arc::new(inner))
219        }
220        pub fn from_arc(inner: Arc<T>) -> Self {
221            Self {
222                inner,
223                accept_compression_encodings: Default::default(),
224                send_compression_encodings: Default::default(),
225                max_decoding_message_size: None,
226                max_encoding_message_size: None,
227            }
228        }
229        pub fn with_interceptor<F>(
230            inner: T,
231            interceptor: F,
232        ) -> InterceptedService<Self, F>
233        where
234            F: tonic::service::Interceptor,
235        {
236            InterceptedService::new(Self::new(inner), interceptor)
237        }
238        /// Enable decompressing requests with the given encoding.
239        #[must_use]
240        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
241            self.accept_compression_encodings.enable(encoding);
242            self
243        }
244        /// Compress responses with the given encoding, if the client supports it.
245        #[must_use]
246        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
247            self.send_compression_encodings.enable(encoding);
248            self
249        }
250        /// Limits the maximum size of a decoded message.
251        ///
252        /// Default: `4MB`
253        #[must_use]
254        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
255            self.max_decoding_message_size = Some(limit);
256            self
257        }
258        /// Limits the maximum size of an encoded message.
259        ///
260        /// Default: `usize::MAX`
261        #[must_use]
262        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
263            self.max_encoding_message_size = Some(limit);
264            self
265        }
266    }
267    impl<T, B> tonic::codegen::Service<http::Request<B>> for TraceServiceServer<T>
268    where
269        T: TraceService,
270        B: Body + Send + 'static,
271        B::Error: Into<StdError> + Send + 'static,
272    {
273        type Response = http::Response<tonic::body::BoxBody>;
274        type Error = std::convert::Infallible;
275        type Future = BoxFuture<Self::Response, Self::Error>;
276        fn poll_ready(
277            &mut self,
278            _cx: &mut Context<'_>,
279        ) -> Poll<std::result::Result<(), Self::Error>> {
280            Poll::Ready(Ok(()))
281        }
282        fn call(&mut self, req: http::Request<B>) -> Self::Future {
283            match req.uri().path() {
284                "/opentelemetry.proto.collector.trace.v1.TraceService/Export" => {
285                    #[allow(non_camel_case_types)]
286                    struct ExportSvc<T: TraceService>(pub Arc<T>);
287                    impl<
288                        T: TraceService,
289                    > tonic::server::UnaryService<super::ExportTraceServiceRequest>
290                    for ExportSvc<T> {
291                        type Response = super::ExportTraceServiceResponse;
292                        type Future = BoxFuture<
293                            tonic::Response<Self::Response>,
294                            tonic::Status,
295                        >;
296                        fn call(
297                            &mut self,
298                            request: tonic::Request<super::ExportTraceServiceRequest>,
299                        ) -> Self::Future {
300                            let inner = Arc::clone(&self.0);
301                            let fut = async move {
302                                <T as TraceService>::export(&inner, request).await
303                            };
304                            Box::pin(fut)
305                        }
306                    }
307                    let accept_compression_encodings = self.accept_compression_encodings;
308                    let send_compression_encodings = self.send_compression_encodings;
309                    let max_decoding_message_size = self.max_decoding_message_size;
310                    let max_encoding_message_size = self.max_encoding_message_size;
311                    let inner = self.inner.clone();
312                    let fut = async move {
313                        let method = ExportSvc(inner);
314                        let codec = tonic::codec::ProstCodec::default();
315                        let mut grpc = tonic::server::Grpc::new(codec)
316                            .apply_compression_config(
317                                accept_compression_encodings,
318                                send_compression_encodings,
319                            )
320                            .apply_max_message_size_config(
321                                max_decoding_message_size,
322                                max_encoding_message_size,
323                            );
324                        let res = grpc.unary(method, req).await;
325                        Ok(res)
326                    };
327                    Box::pin(fut)
328                }
329                _ => {
330                    Box::pin(async move {
331                        Ok(
332                            http::Response::builder()
333                                .status(200)
334                                .header("grpc-status", tonic::Code::Unimplemented as i32)
335                                .header(
336                                    http::header::CONTENT_TYPE,
337                                    tonic::metadata::GRPC_CONTENT_TYPE,
338                                )
339                                .body(empty_body())
340                                .unwrap(),
341                        )
342                    })
343                }
344            }
345        }
346    }
347    impl<T: TraceService> Clone for TraceServiceServer<T> {
348        fn clone(&self) -> Self {
349            let inner = self.inner.clone();
350            Self {
351                inner,
352                accept_compression_encodings: self.accept_compression_encodings,
353                send_compression_encodings: self.send_compression_encodings,
354                max_decoding_message_size: self.max_decoding_message_size,
355                max_encoding_message_size: self.max_encoding_message_size,
356            }
357        }
358    }
359    impl<T: TraceService> tonic::server::NamedService for TraceServiceServer<T> {
360        const NAME: &'static str = "opentelemetry.proto.collector.trace.v1.TraceService";
361    }
362}