opentelemetry_proto/proto/tonic/
opentelemetry.proto.collector.logs.v1.rs1#[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#[derive(Clone, PartialEq, ::prost::Message)]
6pub struct ExportLogsServiceRequest {
7 #[prost(message, repeated, tag = "1")]
13 pub resource_logs: ::prost::alloc::vec::Vec<
14 super::super::super::logs::v1::ResourceLogs,
15 >,
16}
17#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
18#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
19#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
20#[derive(Clone, PartialEq, ::prost::Message)]
21pub struct ExportLogsServiceResponse {
22 #[prost(message, optional, tag = "1")]
38 pub partial_success: ::core::option::Option<ExportLogsPartialSuccess>,
39}
40#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
41#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
42#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
43#[derive(Clone, PartialEq, ::prost::Message)]
44pub struct ExportLogsPartialSuccess {
45 #[prost(int64, tag = "1")]
50 pub rejected_log_records: i64,
51 #[prost(string, tag = "2")]
59 pub error_message: ::prost::alloc::string::String,
60}
61#[cfg(feature = "gen-tonic")]
63pub mod logs_service_client {
64 #![allow(
65 unused_variables,
66 dead_code,
67 missing_docs,
68 clippy::wildcard_imports,
69 clippy::let_unit_value,
70 )]
71 use tonic::codegen::*;
72 use tonic::codegen::http::Uri;
73 #[derive(Debug, Clone)]
77 pub struct LogsServiceClient<T> {
78 inner: tonic::client::Grpc<T>,
79 }
80 impl LogsServiceClient<tonic::transport::Channel> {
81 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
83 where
84 D: TryInto<tonic::transport::Endpoint>,
85 D::Error: Into<StdError>,
86 {
87 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
88 Ok(Self::new(conn))
89 }
90 }
91 impl<T> LogsServiceClient<T>
92 where
93 T: tonic::client::GrpcService<tonic::body::BoxBody>,
94 T::Error: Into<StdError>,
95 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
96 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
97 {
98 pub fn new(inner: T) -> Self {
99 let inner = tonic::client::Grpc::new(inner);
100 Self { inner }
101 }
102 pub fn with_origin(inner: T, origin: Uri) -> Self {
103 let inner = tonic::client::Grpc::with_origin(inner, origin);
104 Self { inner }
105 }
106 pub fn with_interceptor<F>(
107 inner: T,
108 interceptor: F,
109 ) -> LogsServiceClient<InterceptedService<T, F>>
110 where
111 F: tonic::service::Interceptor,
112 T::ResponseBody: Default,
113 T: tonic::codegen::Service<
114 http::Request<tonic::body::BoxBody>,
115 Response = http::Response<
116 <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
117 >,
118 >,
119 <T as tonic::codegen::Service<
120 http::Request<tonic::body::BoxBody>,
121 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
122 {
123 LogsServiceClient::new(InterceptedService::new(inner, interceptor))
124 }
125 #[must_use]
130 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
131 self.inner = self.inner.send_compressed(encoding);
132 self
133 }
134 #[must_use]
136 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
137 self.inner = self.inner.accept_compressed(encoding);
138 self
139 }
140 #[must_use]
144 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
145 self.inner = self.inner.max_decoding_message_size(limit);
146 self
147 }
148 #[must_use]
152 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
153 self.inner = self.inner.max_encoding_message_size(limit);
154 self
155 }
156 pub async fn export(
159 &mut self,
160 request: impl tonic::IntoRequest<super::ExportLogsServiceRequest>,
161 ) -> std::result::Result<
162 tonic::Response<super::ExportLogsServiceResponse>,
163 tonic::Status,
164 > {
165 self.inner
166 .ready()
167 .await
168 .map_err(|e| {
169 tonic::Status::unknown(
170 format!("Service was not ready: {}", e.into()),
171 )
172 })?;
173 let codec = tonic::codec::ProstCodec::default();
174 let path = http::uri::PathAndQuery::from_static(
175 "/opentelemetry.proto.collector.logs.v1.LogsService/Export",
176 );
177 let mut req = request.into_request();
178 req.extensions_mut()
179 .insert(
180 GrpcMethod::new(
181 "opentelemetry.proto.collector.logs.v1.LogsService",
182 "Export",
183 ),
184 );
185 self.inner.unary(req, path, codec).await
186 }
187 }
188}
189#[cfg(feature = "gen-tonic")]
191pub mod logs_service_server {
192 #![allow(
193 unused_variables,
194 dead_code,
195 missing_docs,
196 clippy::wildcard_imports,
197 clippy::let_unit_value,
198 )]
199 use tonic::codegen::*;
200 #[async_trait]
202 pub trait LogsService: std::marker::Send + std::marker::Sync + 'static {
203 async fn export(
206 &self,
207 request: tonic::Request<super::ExportLogsServiceRequest>,
208 ) -> std::result::Result<
209 tonic::Response<super::ExportLogsServiceResponse>,
210 tonic::Status,
211 >;
212 }
213 #[derive(Debug)]
217 pub struct LogsServiceServer<T> {
218 inner: Arc<T>,
219 accept_compression_encodings: EnabledCompressionEncodings,
220 send_compression_encodings: EnabledCompressionEncodings,
221 max_decoding_message_size: Option<usize>,
222 max_encoding_message_size: Option<usize>,
223 }
224 impl<T> LogsServiceServer<T> {
225 pub fn new(inner: T) -> Self {
226 Self::from_arc(Arc::new(inner))
227 }
228 pub fn from_arc(inner: Arc<T>) -> Self {
229 Self {
230 inner,
231 accept_compression_encodings: Default::default(),
232 send_compression_encodings: Default::default(),
233 max_decoding_message_size: None,
234 max_encoding_message_size: None,
235 }
236 }
237 pub fn with_interceptor<F>(
238 inner: T,
239 interceptor: F,
240 ) -> InterceptedService<Self, F>
241 where
242 F: tonic::service::Interceptor,
243 {
244 InterceptedService::new(Self::new(inner), interceptor)
245 }
246 #[must_use]
248 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
249 self.accept_compression_encodings.enable(encoding);
250 self
251 }
252 #[must_use]
254 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
255 self.send_compression_encodings.enable(encoding);
256 self
257 }
258 #[must_use]
262 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
263 self.max_decoding_message_size = Some(limit);
264 self
265 }
266 #[must_use]
270 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
271 self.max_encoding_message_size = Some(limit);
272 self
273 }
274 }
275 impl<T, B> tonic::codegen::Service<http::Request<B>> for LogsServiceServer<T>
276 where
277 T: LogsService,
278 B: Body + std::marker::Send + 'static,
279 B::Error: Into<StdError> + std::marker::Send + 'static,
280 {
281 type Response = http::Response<tonic::body::BoxBody>;
282 type Error = std::convert::Infallible;
283 type Future = BoxFuture<Self::Response, Self::Error>;
284 fn poll_ready(
285 &mut self,
286 _cx: &mut Context<'_>,
287 ) -> Poll<std::result::Result<(), Self::Error>> {
288 Poll::Ready(Ok(()))
289 }
290 fn call(&mut self, req: http::Request<B>) -> Self::Future {
291 match req.uri().path() {
292 "/opentelemetry.proto.collector.logs.v1.LogsService/Export" => {
293 #[allow(non_camel_case_types)]
294 struct ExportSvc<T: LogsService>(pub Arc<T>);
295 impl<
296 T: LogsService,
297 > tonic::server::UnaryService<super::ExportLogsServiceRequest>
298 for ExportSvc<T> {
299 type Response = super::ExportLogsServiceResponse;
300 type Future = BoxFuture<
301 tonic::Response<Self::Response>,
302 tonic::Status,
303 >;
304 fn call(
305 &mut self,
306 request: tonic::Request<super::ExportLogsServiceRequest>,
307 ) -> Self::Future {
308 let inner = Arc::clone(&self.0);
309 let fut = async move {
310 <T as LogsService>::export(&inner, request).await
311 };
312 Box::pin(fut)
313 }
314 }
315 let accept_compression_encodings = self.accept_compression_encodings;
316 let send_compression_encodings = self.send_compression_encodings;
317 let max_decoding_message_size = self.max_decoding_message_size;
318 let max_encoding_message_size = self.max_encoding_message_size;
319 let inner = self.inner.clone();
320 let fut = async move {
321 let method = ExportSvc(inner);
322 let codec = tonic::codec::ProstCodec::default();
323 let mut grpc = tonic::server::Grpc::new(codec)
324 .apply_compression_config(
325 accept_compression_encodings,
326 send_compression_encodings,
327 )
328 .apply_max_message_size_config(
329 max_decoding_message_size,
330 max_encoding_message_size,
331 );
332 let res = grpc.unary(method, req).await;
333 Ok(res)
334 };
335 Box::pin(fut)
336 }
337 _ => {
338 Box::pin(async move {
339 let mut response = http::Response::new(empty_body());
340 let headers = response.headers_mut();
341 headers
342 .insert(
343 tonic::Status::GRPC_STATUS,
344 (tonic::Code::Unimplemented as i32).into(),
345 );
346 headers
347 .insert(
348 http::header::CONTENT_TYPE,
349 tonic::metadata::GRPC_CONTENT_TYPE,
350 );
351 Ok(response)
352 })
353 }
354 }
355 }
356 }
357 impl<T> Clone for LogsServiceServer<T> {
358 fn clone(&self) -> Self {
359 let inner = self.inner.clone();
360 Self {
361 inner,
362 accept_compression_encodings: self.accept_compression_encodings,
363 send_compression_encodings: self.send_compression_encodings,
364 max_decoding_message_size: self.max_decoding_message_size,
365 max_encoding_message_size: self.max_encoding_message_size,
366 }
367 }
368 }
369 pub const SERVICE_NAME: &str = "opentelemetry.proto.collector.logs.v1.LogsService";
371 impl<T> tonic::server::NamedService for LogsServiceServer<T> {
372 const NAME: &'static str = SERVICE_NAME;
373 }
374}