Skip to main content

langfuse_client_base/models/
otel_span.rs

1/*
2 * langfuse
3 *
4 * ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings:  - username: Langfuse Public Key - password: Langfuse Secret Key  ## Exports  - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml
5 *
6 * The version of the OpenAPI document:
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// OtelSpan : Individual span representing a unit of work or operation
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
16pub struct OtelSpan {
17    /// Trace ID (16 bytes, hex-encoded string in JSON or Buffer in binary)
18    #[serde(
19        rename = "traceId",
20        default,
21        with = "::serde_with::rust::double_option",
22        skip_serializing_if = "Option::is_none"
23    )]
24    pub trace_id: Option<Option<serde_json::Value>>,
25    /// Span ID (8 bytes, hex-encoded string in JSON or Buffer in binary)
26    #[serde(
27        rename = "spanId",
28        default,
29        with = "::serde_with::rust::double_option",
30        skip_serializing_if = "Option::is_none"
31    )]
32    pub span_id: Option<Option<serde_json::Value>>,
33    /// Parent span ID if this is a child span
34    #[serde(
35        rename = "parentSpanId",
36        default,
37        with = "::serde_with::rust::double_option",
38        skip_serializing_if = "Option::is_none"
39    )]
40    pub parent_span_id: Option<Option<serde_json::Value>>,
41    /// Span name describing the operation
42    #[serde(
43        rename = "name",
44        default,
45        with = "::serde_with::rust::double_option",
46        skip_serializing_if = "Option::is_none"
47    )]
48    pub name: Option<Option<String>>,
49    /// Span kind (1=INTERNAL, 2=SERVER, 3=CLIENT, 4=PRODUCER, 5=CONSUMER)
50    #[serde(
51        rename = "kind",
52        default,
53        with = "::serde_with::rust::double_option",
54        skip_serializing_if = "Option::is_none"
55    )]
56    pub kind: Option<Option<i32>>,
57    /// Start time in nanoseconds since Unix epoch
58    #[serde(
59        rename = "startTimeUnixNano",
60        default,
61        with = "::serde_with::rust::double_option",
62        skip_serializing_if = "Option::is_none"
63    )]
64    pub start_time_unix_nano: Option<Option<serde_json::Value>>,
65    /// End time in nanoseconds since Unix epoch
66    #[serde(
67        rename = "endTimeUnixNano",
68        default,
69        with = "::serde_with::rust::double_option",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub end_time_unix_nano: Option<Option<serde_json::Value>>,
73    /// Span attributes including Langfuse-specific attributes (langfuse.observation.*)
74    #[serde(
75        rename = "attributes",
76        default,
77        with = "::serde_with::rust::double_option",
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub attributes: Option<Option<Vec<models::OtelAttribute>>>,
81    /// Span status object
82    #[serde(
83        rename = "status",
84        default,
85        with = "::serde_with::rust::double_option",
86        skip_serializing_if = "Option::is_none"
87    )]
88    pub status: Option<Option<serde_json::Value>>,
89}
90
91impl OtelSpan {
92    /// Individual span representing a unit of work or operation
93    pub fn new() -> OtelSpan {
94        OtelSpan {
95            trace_id: None,
96            span_id: None,
97            parent_span_id: None,
98            name: None,
99            kind: None,
100            start_time_unix_nano: None,
101            end_time_unix_nano: None,
102            attributes: None,
103            status: None,
104        }
105    }
106}