opentelemetry_proto/proto/tonic/
opentelemetry.proto.collector.metrics.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#[allow(clippy::derive_partial_eq_without_eq)]
6#[derive(Clone, PartialEq, ::prost::Message)]
7pub struct ExportMetricsServiceRequest {
8 #[prost(message, repeated, tag = "1")]
14 pub resource_metrics: ::prost::alloc::vec::Vec<
15 super::super::super::metrics::v1::ResourceMetrics,
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 ExportMetricsServiceResponse {
24 #[prost(message, optional, tag = "1")]
40 pub partial_success: ::core::option::Option<ExportMetricsPartialSuccess>,
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 ExportMetricsPartialSuccess {
48 #[prost(int64, tag = "1")]
53 pub rejected_data_points: i64,
54 #[prost(string, tag = "2")]
62 pub error_message: ::prost::alloc::string::String,
63}
64#[cfg(feature = "gen-tonic")]
66pub mod metrics_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 #[derive(Debug, Clone)]
74 pub struct MetricsServiceClient<T> {
75 inner: tonic::client::Grpc<T>,
76 }
77 impl MetricsServiceClient<tonic::transport::Channel> {
78 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> MetricsServiceClient<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 ) -> MetricsServiceClient<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 MetricsServiceClient::new(InterceptedService::new(inner, interceptor))
121 }
122 #[must_use]
127 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
128 self.inner = self.inner.send_compressed(encoding);
129 self
130 }
131 #[must_use]
133 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
134 self.inner = self.inner.accept_compressed(encoding);
135 self
136 }
137 #[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 #[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 pub async fn export(
156 &mut self,
157 request: impl tonic::IntoRequest<super::ExportMetricsServiceRequest>,
158 ) -> std::result::Result<
159 tonic::Response<super::ExportMetricsServiceResponse>,
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.metrics.v1.MetricsService/Export",
174 );
175 let mut req = request.into_request();
176 req.extensions_mut()
177 .insert(
178 GrpcMethod::new(
179 "opentelemetry.proto.collector.metrics.v1.MetricsService",
180 "Export",
181 ),
182 );
183 self.inner.unary(req, path, codec).await
184 }
185 }
186}
187#[cfg(feature = "gen-tonic")]
189pub mod metrics_service_server {
190 #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
191 use tonic::codegen::*;
192 #[async_trait]
194 pub trait MetricsService: Send + Sync + 'static {
195 async fn export(
198 &self,
199 request: tonic::Request<super::ExportMetricsServiceRequest>,
200 ) -> std::result::Result<
201 tonic::Response<super::ExportMetricsServiceResponse>,
202 tonic::Status,
203 >;
204 }
205 #[derive(Debug)]
209 pub struct MetricsServiceServer<T: MetricsService> {
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: MetricsService> MetricsServiceServer<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 #[must_use]
240 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
241 self.accept_compression_encodings.enable(encoding);
242 self
243 }
244 #[must_use]
246 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
247 self.send_compression_encodings.enable(encoding);
248 self
249 }
250 #[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 #[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 MetricsServiceServer<T>
268 where
269 T: MetricsService,
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.metrics.v1.MetricsService/Export" => {
285 #[allow(non_camel_case_types)]
286 struct ExportSvc<T: MetricsService>(pub Arc<T>);
287 impl<
288 T: MetricsService,
289 > tonic::server::UnaryService<super::ExportMetricsServiceRequest>
290 for ExportSvc<T> {
291 type Response = super::ExportMetricsServiceResponse;
292 type Future = BoxFuture<
293 tonic::Response<Self::Response>,
294 tonic::Status,
295 >;
296 fn call(
297 &mut self,
298 request: tonic::Request<super::ExportMetricsServiceRequest>,
299 ) -> Self::Future {
300 let inner = Arc::clone(&self.0);
301 let fut = async move {
302 <T as MetricsService>::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: MetricsService> Clone for MetricsServiceServer<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: MetricsService> tonic::server::NamedService for MetricsServiceServer<T> {
360 const NAME: &'static str = "opentelemetry.proto.collector.metrics.v1.MetricsService";
361 }
362}