libdd-trace-protobuf 2.0.0

Protobuf utils for Datadog's traces serialization
Documentation
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use serde::{Deserialize, Serialize};
// This file is @generated by prost-build.
/// AnyValue is a union of possible value types.
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnyValue {
    #[prost(oneof = "any_value::Value", tags = "1, 2, 3, 4, 5, 6, 7")]
    pub value: ::core::option::Option<any_value::Value>,
}
/// Nested message and enum types in `AnyValue`.
pub mod any_value {
    #[derive(serde::Deserialize, serde::Serialize)]
    #[derive(Clone, PartialEq, ::prost::Oneof)]
    pub enum Value {
        /// stringValueRef specifies the string table ref of a string value.
        #[prost(uint32, tag = "1")]
        StringValueRef(u32),
        /// boolValue specifies a bool value.
        #[prost(bool, tag = "2")]
        BoolValue(bool),
        /// doubleValue specifies a double value.
        #[prost(double, tag = "3")]
        DoubleValue(f64),
        /// intValue specifies an int value.
        #[prost(int64, tag = "4")]
        IntValue(i64),
        /// bytesValue specifies a bytes value.
        #[prost(bytes, tag = "5")]
        BytesValue(::prost::alloc::vec::Vec<u8>),
        /// arrayValue specifies an array value.
        #[prost(message, tag = "6")]
        ArrayValue(super::ArrayValue),
        /// keyValueList specifies a list of key-value pairs.
        #[prost(message, tag = "7")]
        KeyValueList(super::KeyValueList),
    }
}
/// KeyValue is a key-value pair where key is a string table ref and value is an AnyValue.
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValue {
    /// key specifies the string table ref of a key.
    #[prost(uint32, tag = "1")]
    pub key: u32,
    /// value specifies a value.
    #[prost(message, optional, tag = "2")]
    pub value: ::core::option::Option<AnyValue>,
}
/// ArrayValue is a repeated list of AnyValue that is needed since `oneof` in AnyValue
/// cannot be `repeated`
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrayValue {
    /// values specifies a repeated list of AnyValue.
    #[prost(message, repeated, tag = "1")]
    pub values: ::prost::alloc::vec::Vec<AnyValue>,
}
/// KeyValueList is a repeated list of KeyValue messages that is needed since `oneof`
/// in AnyValue cannot be `repeated` or `map`
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValueList {
    /// keyValues specifies a repeated list of KeyValue.
    #[prost(message, repeated, tag = "1")]
    pub key_values: ::prost::alloc::vec::Vec<KeyValue>,
}
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SpanLink {
    /// traceID specifies the ID of the trace to which this span link belongs.
    #[prost(bytes = "vec", tag = "1")]
    pub trace_id: ::prost::alloc::vec::Vec<u8>,
    /// spanID specifies the ID of this span.
    #[prost(fixed64, tag = "2")]
    pub span_id: u64,
    /// attributes specifies a map of attribute key string ref to any value.
    #[prost(map = "uint32, message", tag = "3")]
    pub attributes: ::std::collections::HashMap<u32, AnyValue>,
    /// tracestateRef specifies the string table ref of the W3C tracestate.
    #[prost(uint32, tag = "4")]
    pub tracestate_ref: u32,
    /// flags specifies the W3C trace flags. Optional. If set, the high bit (bit 31) must be set.
    #[prost(uint32, tag = "5")]
    pub flags: u32,
}
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SpanEvent {
    /// time is the number of nanoseconds between the Unix epoch and this event.
    #[prost(fixed64, tag = "1")]
    pub time: u64,
    /// nameRef specifies the string table ref of this event's name.
    #[prost(uint32, tag = "2")]
    pub name_ref: u32,
    /// attributes is a mapping from attribute key string ref to any value.
    #[prost(map = "uint32, message", tag = "3")]
    pub attributes: ::std::collections::HashMap<u32, AnyValue>,
}
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Span {
    /// serviceRef specifies the string table ref of this span's service name.
    #[prost(uint32, tag = "1")]
    pub service_ref: u32,
    /// nameRef specifies the string table ref of this span's operation name.
    #[prost(uint32, tag = "2")]
    pub name_ref: u32,
    /// resourceRef specifies the string table ref of this span's resource name.
    #[prost(uint32, tag = "3")]
    pub resource_ref: u32,
    /// spanID is the ID of this span.
    #[prost(fixed64, tag = "4")]
    pub span_id: u64,
    /// parentID is the ID of this span's parent, or zero if this span has no parent.
    #[prost(uint64, tag = "5")]
    pub parent_id: u64,
    /// start is the number of nanoseconds between the Unix epoch and the beginning of this span.
    #[prost(fixed64, tag = "6")]
    pub start: u64,
    /// duration is the time length of this span in nanoseconds.
    #[prost(uint64, tag = "7")]
    pub duration: u64,
    /// error specifies if there is an error associated with this span.
    #[prost(bool, tag = "8")]
    pub error: bool,
    /// attributes is a mapping from attribute key string ref to any value.
    #[prost(map = "uint32, message", tag = "9")]
    pub attributes: ::std::collections::HashMap<u32, AnyValue>,
    /// typeRef is the string table ref of the type of the service with which this span is associated.  Example values: web, db, lambda.
    #[prost(uint32, tag = "10")]
    pub type_ref: u32,
    /// span_links represents a collection of links, where each link defines a causal relationship between two spans.
    #[prost(message, repeated, tag = "11")]
    pub links: ::prost::alloc::vec::Vec<SpanLink>,
    /// spanEvents represent an event at an instant in time related to this span, but not necessarily during the span.
    #[prost(message, repeated, tag = "12")]
    pub events: ::prost::alloc::vec::Vec<SpanEvent>,
    /// envRef is the string table ref of the optional string environment of this span.
    #[prost(uint32, tag = "13")]
    pub env_ref: u32,
    /// versionRef is the string table ref of the optional string version of this span.
    #[prost(uint32, tag = "14")]
    pub version_ref: u32,
    /// componentRef is the string table ref of the string component name of this span.
    #[prost(uint32, tag = "15")]
    pub component_ref: u32,
    /// kind is the SpanKind of this span as defined in the OTEL Specification.
    #[prost(enumeration = "SpanKind", tag = "16")]
    pub kind: i32,
}
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
/// in addition to a parent/child relationship.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SpanKind {
    /// Unspecified. Do NOT use as default.
    /// Implementations MAY assume SpanKind to be INTERNAL when receiving UNSPECIFIED.
    Unspecified = 0,
    /// Indicates that the span represents an internal operation within an application,
    /// as opposed to an operations happening at the boundaries. Default value.
    Internal = 1,
    /// Indicates that the span covers server-side handling of an RPC or other
    /// remote network request.
    Server = 2,
    /// Indicates that the span describes a request to some remote service.
    Client = 3,
    /// Indicates that the span describes a producer sending a message to a broker.
    /// Unlike CLIENT and SERVER, there is often no direct critical path latency relationship
    /// between producer and consumer spans. A PRODUCER span ends when the message was accepted
    /// by the broker while the logical processing of the message might span a much longer time.
    Producer = 4,
    /// Indicates that the span describes consumer receiving a message from a broker.
    /// Like the PRODUCER kind, there is often no direct critical path latency relationship
    /// between producer and consumer spans.
    Consumer = 5,
}
impl SpanKind {
    /// String value of the enum field names used in the ProtoBuf definition.
    ///
    /// The values are not transformed in any way and thus are considered stable
    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
    pub fn as_str_name(&self) -> &'static str {
        match self {
            Self::Unspecified => "SPAN_KIND_UNSPECIFIED",
            Self::Internal => "SPAN_KIND_INTERNAL",
            Self::Server => "SPAN_KIND_SERVER",
            Self::Client => "SPAN_KIND_CLIENT",
            Self::Producer => "SPAN_KIND_PRODUCER",
            Self::Consumer => "SPAN_KIND_CONSUMER",
        }
    }
    /// Creates an enum from field names used in the ProtoBuf definition.
    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
        match value {
            "SPAN_KIND_UNSPECIFIED" => Some(Self::Unspecified),
            "SPAN_KIND_INTERNAL" => Some(Self::Internal),
            "SPAN_KIND_SERVER" => Some(Self::Server),
            "SPAN_KIND_CLIENT" => Some(Self::Client),
            "SPAN_KIND_PRODUCER" => Some(Self::Producer),
            "SPAN_KIND_CONSUMER" => Some(Self::Consumer),
            _ => None,
        }
    }
}
/// TraceChunk represents a list of spans with the same trace ID. In other words, a chunk of a trace.
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TraceChunk {
    /// priority specifies the string table ref of the sampling priority of the trace.
    #[prost(int32, tag = "1")]
    pub priority: i32,
    /// originRef specifies the string table ref of the origin product ("lambda", "rum", etc.) of the trace.
    #[prost(uint32, tag = "2")]
    pub origin_ref: u32,
    /// attributes specifies the map of string table ref to AnyValue of the tags common in all `spans`.
    #[prost(map = "uint32, message", tag = "3")]
    pub attributes: ::std::collections::HashMap<u32, AnyValue>,
    /// spans specifies list of containing spans.
    #[prost(message, repeated, tag = "4")]
    pub spans: ::prost::alloc::vec::Vec<Span>,
    /// droppedTrace specifies whether the trace was dropped by samplers or not.
    #[prost(bool, tag = "5")]
    pub dropped_trace: bool,
    /// traceID specifies the ID of the trace to which all spans in this chunk belong.
    #[prost(bytes = "vec", tag = "6")]
    pub trace_id: ::prost::alloc::vec::Vec<u8>,
    /// samplingMechanism specifies the optional sampling mechanism (previously part of span tag _dd.p.dm)
    #[prost(uint32, tag = "7")]
    pub sampling_mechanism: u32,
}
/// TracerPayload represents a payload the trace agent receives from tracers.
#[derive(Deserialize, Serialize)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TracerPayload {
    /// strings specifies the array of strings referenced in this tracer payload, its chunks and spans.
    #[prost(string, repeated, tag = "1")]
    pub strings: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
    /// containerIDRef specifies the string table ref of the ID of the container where the tracer is running on.
    #[prost(uint32, tag = "2")]
    pub container_id_ref: u32,
    /// languageNameRef specifies the string table ref of the language of the tracer.
    #[prost(uint32, tag = "3")]
    pub language_name_ref: u32,
    /// languageVersionRef specifies the string table ref of the language version of the tracer.
    #[prost(uint32, tag = "4")]
    pub language_version_ref: u32,
    /// tracerVersionRef specifies the string table ref of the version of the tracer.
    #[prost(uint32, tag = "5")]
    pub tracer_version_ref: u32,
    /// runtimeIDRef specifies the string table ref of the V4 UUID representation of a tracer session.
    #[prost(uint32, tag = "6")]
    pub runtime_id_ref: u32,
    /// envRef specifies the string table ref of the `env` tag that set with the tracer.
    #[prost(uint32, tag = "7")]
    pub env_ref: u32,
    /// hostnameRef specifies the string table ref of the hostname of where the tracer is running.
    #[prost(uint32, tag = "8")]
    pub hostname_ref: u32,
    /// appVersionRef specifies the string table ref of the `version` tag set in the tracer.
    #[prost(uint32, tag = "9")]
    pub app_version_ref: u32,
    /// a collection of key to value pairs common in all `chunks`
    #[prost(map = "uint32, message", tag = "10")]
    pub attributes: ::std::collections::HashMap<u32, AnyValue>,
    /// chunks specifies list of containing trace chunks.
    #[prost(message, repeated, tag = "11")]
    pub chunks: ::prost::alloc::vec::Vec<TraceChunk>,
}