Skip to content

Commit 7bf01c2

Browse files
committed
feat: generate protos for profiles collector
1 parent 0e3511e commit 7bf01c2

File tree

3 files changed

+384
-1
lines changed

3 files changed

+384
-1
lines changed

opentelemetry-proto/src/proto.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ pub mod tonic {
242242
#[path = "opentelemetry.proto.collector.trace.v1.rs"]
243243
pub mod v1;
244244
}
245+
246+
#[cfg(feature = "profiles")]
247+
#[path = ""]
248+
pub mod profiles {
249+
#[path = "opentelemetry.proto.collector.profiles.v1development.rs"]
250+
pub mod v1development;
251+
}
245252
}
246253

247254
/// Common types used across all signals
@@ -295,7 +302,7 @@ pub mod tonic {
295302
#[path = ""]
296303
pub mod profiles {
297304
#[path = "opentelemetry.proto.profiles.v1development.rs"]
298-
pub mod v1;
305+
pub mod v1development;
299306
}
300307

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

0 commit comments

Comments
 (0)