opentelemetry_proto/proto/tonic/
opentelemetry.proto.logs.v1.rs

1// This file is @generated by prost-build.
2/// LogsData represents the logs data that can be stored in a persistent storage,
3/// OR can be embedded by other protocols that transfer OTLP logs data but do not
4/// implement the OTLP protocol.
5///
6/// The main difference between this message and collector protocol is that
7/// in this message there will not be any "control" or "metadata" specific to
8/// OTLP protocol.
9///
10/// When new fields are added into this message, the OTLP request MUST be updated
11/// as well.
12#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
13#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
14#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
15#[allow(clippy::derive_partial_eq_without_eq)]
16#[derive(Clone, PartialEq, ::prost::Message)]
17pub struct LogsData {
18    /// An array of ResourceLogs.
19    /// For data coming from a single resource this array will typically contain
20    /// one element. Intermediary nodes that receive data from multiple origins
21    /// typically batch the data before forwarding further and in that case this
22    /// array will contain multiple elements.
23    #[prost(message, repeated, tag = "1")]
24    pub resource_logs: ::prost::alloc::vec::Vec<ResourceLogs>,
25}
26/// A collection of ScopeLogs from a Resource.
27#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
28#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
29#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
30#[cfg_attr(feature = "with-serde", serde(default))]
31#[allow(clippy::derive_partial_eq_without_eq)]
32#[derive(Clone, PartialEq, ::prost::Message)]
33pub struct ResourceLogs {
34    /// The resource for the logs in this message.
35    /// If this field is not set then resource info is unknown.
36    #[prost(message, optional, tag = "1")]
37    pub resource: ::core::option::Option<super::super::resource::v1::Resource>,
38    /// A list of ScopeLogs that originate from a resource.
39    #[prost(message, repeated, tag = "2")]
40    pub scope_logs: ::prost::alloc::vec::Vec<ScopeLogs>,
41    /// The Schema URL, if known. This is the identifier of the Schema that the resource data
42    /// is recorded in. To learn more about Schema URL see
43    /// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
44    /// This schema_url applies to the data in the "resource" field. It does not apply
45    /// to the data in the "scope_logs" field which have their own schema_url field.
46    #[prost(string, tag = "3")]
47    pub schema_url: ::prost::alloc::string::String,
48}
49/// A collection of Logs produced by a Scope.
50#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
51#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
52#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
53#[cfg_attr(feature = "with-serde", serde(default))]
54#[allow(clippy::derive_partial_eq_without_eq)]
55#[derive(Clone, PartialEq, ::prost::Message)]
56pub struct ScopeLogs {
57    /// The instrumentation scope information for the logs in this message.
58    /// Semantically when InstrumentationScope isn't set, it is equivalent with
59    /// an empty instrumentation scope name (unknown).
60    #[prost(message, optional, tag = "1")]
61    pub scope: ::core::option::Option<super::super::common::v1::InstrumentationScope>,
62    /// A list of log records.
63    #[prost(message, repeated, tag = "2")]
64    pub log_records: ::prost::alloc::vec::Vec<LogRecord>,
65    /// The Schema URL, if known. This is the identifier of the Schema that the log data
66    /// is recorded in. To learn more about Schema URL see
67    /// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
68    /// This schema_url applies to all logs in the "logs" field.
69    #[prost(string, tag = "3")]
70    pub schema_url: ::prost::alloc::string::String,
71}
72/// A log record according to OpenTelemetry Log Data Model:
73/// <https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md>
74#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
75#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
76#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
77#[cfg_attr(feature = "with-serde", serde(default))]
78#[allow(clippy::derive_partial_eq_without_eq)]
79#[derive(Clone, PartialEq, ::prost::Message)]
80pub struct LogRecord {
81    /// time_unix_nano is the time when the event occurred.
82    /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
83    /// Value of 0 indicates unknown or missing timestamp.
84    #[prost(fixed64, tag = "1")]
85    #[cfg_attr(
86        feature = "with-serde",
87        serde(
88            serialize_with = "crate::proto::serializers::serialize_u64_to_string",
89            deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
90        )
91    )]
92    pub time_unix_nano: u64,
93    /// Time when the event was observed by the collection system.
94    /// For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK)
95    /// this timestamp is typically set at the generation time and is equal to Timestamp.
96    /// For events originating externally and collected by OpenTelemetry (e.g. using
97    /// Collector) this is the time when OpenTelemetry's code observed the event measured
98    /// by the clock of the OpenTelemetry code. This field MUST be set once the event is
99    /// observed by OpenTelemetry.
100    ///
101    /// For converting OpenTelemetry log data to formats that support only one timestamp or
102    /// when receiving OpenTelemetry log data by recipients that support only one timestamp
103    /// internally the following logic is recommended:
104    ///    - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano.
105    ///
106    /// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
107    /// Value of 0 indicates unknown or missing timestamp.
108    #[prost(fixed64, tag = "11")]
109    #[cfg_attr(
110        feature = "with-serde",
111        serde(
112            serialize_with = "crate::proto::serializers::serialize_u64_to_string",
113            deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
114        )
115    )]
116    pub observed_time_unix_nano: u64,
117    /// Numerical value of the severity, normalized to values described in Log Data Model.
118    /// \[Optional\].
119    #[prost(enumeration = "SeverityNumber", tag = "2")]
120    pub severity_number: i32,
121    /// The severity text (also known as log level). The original string representation as
122    /// it is known at the source. \[Optional\].
123    #[prost(string, tag = "3")]
124    pub severity_text: ::prost::alloc::string::String,
125    /// A value containing the body of the log record. Can be for example a human-readable
126    /// string message (including multi-line) describing the event in a free form or it can
127    /// be a structured data composed of arrays and maps of other values. \[Optional\].
128    #[prost(message, optional, tag = "5")]
129    #[cfg_attr(
130        feature = "with-serde",
131        serde(
132            serialize_with = "crate::proto::serializers::serialize_to_value",
133            deserialize_with = "crate::proto::serializers::deserialize_from_value"
134        )
135    )]
136    pub body: ::core::option::Option<super::super::common::v1::AnyValue>,
137    /// Additional attributes that describe the specific event occurrence. \[Optional\].
138    /// Attribute keys MUST be unique (it is not allowed to have more than one
139    /// attribute with the same key).
140    #[prost(message, repeated, tag = "6")]
141    pub attributes: ::prost::alloc::vec::Vec<super::super::common::v1::KeyValue>,
142    #[prost(uint32, tag = "7")]
143    pub dropped_attributes_count: u32,
144    /// Flags, a bit field. 8 least significant bits are the trace flags as
145    /// defined in W3C Trace Context specification. 24 most significant bits are reserved
146    /// and must be set to 0. Readers must not assume that 24 most significant bits
147    /// will be zero and must correctly mask the bits when reading 8-bit trace flag (use
148    /// flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). \[Optional\].
149    #[prost(fixed32, tag = "8")]
150    pub flags: u32,
151    /// A unique identifier for a trace. All logs from the same trace share
152    /// the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
153    /// of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
154    /// is zero-length and thus is also invalid).
155    ///
156    /// This field is optional.
157    ///
158    /// The receivers SHOULD assume that the log record is not associated with a
159    /// trace if any of the following is true:
160    ///    - the field is not present,
161    ///    - the field contains an invalid value.
162    #[prost(bytes = "vec", tag = "9")]
163    #[cfg_attr(
164        feature = "with-serde",
165        serde(
166            serialize_with = "crate::proto::serializers::serialize_to_hex_string",
167            deserialize_with = "crate::proto::serializers::deserialize_from_hex_string"
168        )
169    )]
170    pub trace_id: ::prost::alloc::vec::Vec<u8>,
171    /// A unique identifier for a span within a trace, assigned when the span
172    /// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
173    /// other than 8 bytes is considered invalid (empty string in OTLP/JSON
174    /// is zero-length and thus is also invalid).
175    ///
176    /// This field is optional. If the sender specifies a valid span_id then it SHOULD also
177    /// specify a valid trace_id.
178    ///
179    /// The receivers SHOULD assume that the log record is not associated with a
180    /// span if any of the following is true:
181    ///    - the field is not present,
182    ///    - the field contains an invalid value.
183    #[prost(bytes = "vec", tag = "10")]
184    #[cfg_attr(
185        feature = "with-serde",
186        serde(
187            serialize_with = "crate::proto::serializers::serialize_to_hex_string",
188            deserialize_with = "crate::proto::serializers::deserialize_from_hex_string"
189        )
190    )]
191    pub span_id: ::prost::alloc::vec::Vec<u8>,
192}
193/// Possible values for LogRecord.SeverityNumber.
194#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
195#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
196#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
197#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
198#[repr(i32)]
199pub enum SeverityNumber {
200    /// UNSPECIFIED is the default SeverityNumber, it MUST NOT be used.
201    Unspecified = 0,
202    Trace = 1,
203    Trace2 = 2,
204    Trace3 = 3,
205    Trace4 = 4,
206    Debug = 5,
207    Debug2 = 6,
208    Debug3 = 7,
209    Debug4 = 8,
210    Info = 9,
211    Info2 = 10,
212    Info3 = 11,
213    Info4 = 12,
214    Warn = 13,
215    Warn2 = 14,
216    Warn3 = 15,
217    Warn4 = 16,
218    Error = 17,
219    Error2 = 18,
220    Error3 = 19,
221    Error4 = 20,
222    Fatal = 21,
223    Fatal2 = 22,
224    Fatal3 = 23,
225    Fatal4 = 24,
226}
227impl SeverityNumber {
228    /// String value of the enum field names used in the ProtoBuf definition.
229    ///
230    /// The values are not transformed in any way and thus are considered stable
231    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
232    pub fn as_str_name(&self) -> &'static str {
233        match self {
234            SeverityNumber::Unspecified => "SEVERITY_NUMBER_UNSPECIFIED",
235            SeverityNumber::Trace => "SEVERITY_NUMBER_TRACE",
236            SeverityNumber::Trace2 => "SEVERITY_NUMBER_TRACE2",
237            SeverityNumber::Trace3 => "SEVERITY_NUMBER_TRACE3",
238            SeverityNumber::Trace4 => "SEVERITY_NUMBER_TRACE4",
239            SeverityNumber::Debug => "SEVERITY_NUMBER_DEBUG",
240            SeverityNumber::Debug2 => "SEVERITY_NUMBER_DEBUG2",
241            SeverityNumber::Debug3 => "SEVERITY_NUMBER_DEBUG3",
242            SeverityNumber::Debug4 => "SEVERITY_NUMBER_DEBUG4",
243            SeverityNumber::Info => "SEVERITY_NUMBER_INFO",
244            SeverityNumber::Info2 => "SEVERITY_NUMBER_INFO2",
245            SeverityNumber::Info3 => "SEVERITY_NUMBER_INFO3",
246            SeverityNumber::Info4 => "SEVERITY_NUMBER_INFO4",
247            SeverityNumber::Warn => "SEVERITY_NUMBER_WARN",
248            SeverityNumber::Warn2 => "SEVERITY_NUMBER_WARN2",
249            SeverityNumber::Warn3 => "SEVERITY_NUMBER_WARN3",
250            SeverityNumber::Warn4 => "SEVERITY_NUMBER_WARN4",
251            SeverityNumber::Error => "SEVERITY_NUMBER_ERROR",
252            SeverityNumber::Error2 => "SEVERITY_NUMBER_ERROR2",
253            SeverityNumber::Error3 => "SEVERITY_NUMBER_ERROR3",
254            SeverityNumber::Error4 => "SEVERITY_NUMBER_ERROR4",
255            SeverityNumber::Fatal => "SEVERITY_NUMBER_FATAL",
256            SeverityNumber::Fatal2 => "SEVERITY_NUMBER_FATAL2",
257            SeverityNumber::Fatal3 => "SEVERITY_NUMBER_FATAL3",
258            SeverityNumber::Fatal4 => "SEVERITY_NUMBER_FATAL4",
259        }
260    }
261    /// Creates an enum from field names used in the ProtoBuf definition.
262    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
263        match value {
264            "SEVERITY_NUMBER_UNSPECIFIED" => Some(Self::Unspecified),
265            "SEVERITY_NUMBER_TRACE" => Some(Self::Trace),
266            "SEVERITY_NUMBER_TRACE2" => Some(Self::Trace2),
267            "SEVERITY_NUMBER_TRACE3" => Some(Self::Trace3),
268            "SEVERITY_NUMBER_TRACE4" => Some(Self::Trace4),
269            "SEVERITY_NUMBER_DEBUG" => Some(Self::Debug),
270            "SEVERITY_NUMBER_DEBUG2" => Some(Self::Debug2),
271            "SEVERITY_NUMBER_DEBUG3" => Some(Self::Debug3),
272            "SEVERITY_NUMBER_DEBUG4" => Some(Self::Debug4),
273            "SEVERITY_NUMBER_INFO" => Some(Self::Info),
274            "SEVERITY_NUMBER_INFO2" => Some(Self::Info2),
275            "SEVERITY_NUMBER_INFO3" => Some(Self::Info3),
276            "SEVERITY_NUMBER_INFO4" => Some(Self::Info4),
277            "SEVERITY_NUMBER_WARN" => Some(Self::Warn),
278            "SEVERITY_NUMBER_WARN2" => Some(Self::Warn2),
279            "SEVERITY_NUMBER_WARN3" => Some(Self::Warn3),
280            "SEVERITY_NUMBER_WARN4" => Some(Self::Warn4),
281            "SEVERITY_NUMBER_ERROR" => Some(Self::Error),
282            "SEVERITY_NUMBER_ERROR2" => Some(Self::Error2),
283            "SEVERITY_NUMBER_ERROR3" => Some(Self::Error3),
284            "SEVERITY_NUMBER_ERROR4" => Some(Self::Error4),
285            "SEVERITY_NUMBER_FATAL" => Some(Self::Fatal),
286            "SEVERITY_NUMBER_FATAL2" => Some(Self::Fatal2),
287            "SEVERITY_NUMBER_FATAL3" => Some(Self::Fatal3),
288            "SEVERITY_NUMBER_FATAL4" => Some(Self::Fatal4),
289            _ => None,
290        }
291    }
292}
293/// LogRecordFlags represents constants used to interpret the
294/// LogRecord.flags field, which is protobuf 'fixed32' type and is to
295/// be used as bit-fields. Each non-zero value defined in this enum is
296/// a bit-mask.  To extract the bit-field, for example, use an
297/// expression like:
298///
299///    (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
300///
301#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
302#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
303#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
304#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
305#[repr(i32)]
306pub enum LogRecordFlags {
307    /// The zero value for the enum. Should not be used for comparisons.
308    /// Instead use bitwise "and" with the appropriate mask as shown above.
309    DoNotUse = 0,
310    /// Bits 0-7 are used for trace flags.
311    TraceFlagsMask = 255,
312}
313impl LogRecordFlags {
314    /// String value of the enum field names used in the ProtoBuf definition.
315    ///
316    /// The values are not transformed in any way and thus are considered stable
317    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
318    pub fn as_str_name(&self) -> &'static str {
319        match self {
320            LogRecordFlags::DoNotUse => "LOG_RECORD_FLAGS_DO_NOT_USE",
321            LogRecordFlags::TraceFlagsMask => "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK",
322        }
323    }
324    /// Creates an enum from field names used in the ProtoBuf definition.
325    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
326        match value {
327            "LOG_RECORD_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
328            "LOG_RECORD_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
329            _ => None,
330        }
331    }
332}