Skip to main content

langfuse_client_base/models/
trace.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 - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
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#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
15pub struct Trace {
16    /// The unique identifier of a trace
17    #[serde(rename = "id")]
18    pub id: String,
19    /// The timestamp when the trace was created
20    #[serde(rename = "timestamp")]
21    pub timestamp: String,
22    /// The name of the trace
23    #[serde(
24        rename = "name",
25        default,
26        with = "::serde_with::rust::double_option",
27        skip_serializing_if = "Option::is_none"
28    )]
29    pub name: Option<Option<String>>,
30    /// The input data of the trace. Can be any JSON.
31    #[serde(
32        rename = "input",
33        default,
34        with = "::serde_with::rust::double_option",
35        skip_serializing_if = "Option::is_none"
36    )]
37    pub input: Option<Option<serde_json::Value>>,
38    /// The output data of the trace. Can be any JSON.
39    #[serde(
40        rename = "output",
41        default,
42        with = "::serde_with::rust::double_option",
43        skip_serializing_if = "Option::is_none"
44    )]
45    pub output: Option<Option<serde_json::Value>>,
46    /// The session identifier associated with the trace
47    #[serde(
48        rename = "sessionId",
49        default,
50        with = "::serde_with::rust::double_option",
51        skip_serializing_if = "Option::is_none"
52    )]
53    pub session_id: Option<Option<String>>,
54    /// The release version of the application when the trace was created
55    #[serde(
56        rename = "release",
57        default,
58        with = "::serde_with::rust::double_option",
59        skip_serializing_if = "Option::is_none"
60    )]
61    pub release: Option<Option<String>>,
62    /// The version of the trace
63    #[serde(
64        rename = "version",
65        default,
66        with = "::serde_with::rust::double_option",
67        skip_serializing_if = "Option::is_none"
68    )]
69    pub version: Option<Option<String>>,
70    /// The user identifier associated with the trace
71    #[serde(
72        rename = "userId",
73        default,
74        with = "::serde_with::rust::double_option",
75        skip_serializing_if = "Option::is_none"
76    )]
77    pub user_id: Option<Option<String>>,
78    /// The metadata associated with the trace. Can be any JSON.
79    #[serde(
80        rename = "metadata",
81        default,
82        with = "::serde_with::rust::double_option",
83        skip_serializing_if = "Option::is_none"
84    )]
85    pub metadata: Option<Option<serde_json::Value>>,
86    /// The tags associated with the trace.
87    #[serde(rename = "tags")]
88    pub tags: Vec<String>,
89    /// Public traces are accessible via url without login
90    #[serde(rename = "public")]
91    pub public: bool,
92    /// The environment from which this trace originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
93    #[serde(rename = "environment")]
94    pub environment: String,
95}
96
97impl Trace {
98    pub fn new(
99        id: String,
100        timestamp: String,
101        tags: Vec<String>,
102        public: bool,
103        environment: String,
104    ) -> Trace {
105        Trace {
106            id,
107            timestamp,
108            name: None,
109            input: None,
110            output: None,
111            session_id: None,
112            release: None,
113            version: None,
114            user_id: None,
115            metadata: None,
116            tags,
117            public,
118            environment,
119        }
120    }
121}