langfuse_client_base/models/trace.rs
1/*
2 * server
3 *
4 * ## Real-time data The only real-time path to get tracing data is to ingest via OpenTelemetry (`POST /api/public/otel/v1/traces`) and retrieve via Observations API v2 (`GET /api/public/v2/observations`) and Metrics API v2 (`GET /api/public/v2/metrics`). Other public API write and read endpoints can delay data by about 10 minutes. Direct OpenTelemetry exporters must send the `x-langfuse-ingestion-version: 4` header; current Python and JS SDKs already do. See the [Public API docs](https://langfuse.com/docs/api-and-data-platform/features/public-api) and [real-time ingestion](https://langfuse.com/integrations/native/opentelemetry.md#real-time-ingestion). ## 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 - Self-hosted deployments: interactive API reference at `/api/docs` and OpenAPI spec at `/api/openapi.yaml`
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: chrono::DateTime<chrono::FixedOffset>,
22 /// The name of the trace
23 #[serde(rename = "name", deserialize_with = "Option::deserialize")]
24 pub name: Option<String>,
25 /// The input data of the trace. Can be any JSON.
26 #[serde(
27 rename = "input",
28 default,
29 with = "::serde_with::rust::double_option",
30 skip_serializing_if = "Option::is_none"
31 )]
32 pub input: Option<Option<serde_json::Value>>,
33 /// The output data of the trace. Can be any JSON.
34 #[serde(
35 rename = "output",
36 default,
37 with = "::serde_with::rust::double_option",
38 skip_serializing_if = "Option::is_none"
39 )]
40 pub output: Option<Option<serde_json::Value>>,
41 /// The session identifier associated with the trace
42 #[serde(rename = "sessionId", deserialize_with = "Option::deserialize")]
43 pub session_id: Option<String>,
44 /// The release version of the application when the trace was created
45 #[serde(rename = "release", deserialize_with = "Option::deserialize")]
46 pub release: Option<String>,
47 /// The version of the trace
48 #[serde(rename = "version", deserialize_with = "Option::deserialize")]
49 pub version: Option<String>,
50 /// The user identifier associated with the trace
51 #[serde(rename = "userId", deserialize_with = "Option::deserialize")]
52 pub user_id: Option<String>,
53 /// The metadata associated with the trace. Values can be any JSON; non-object metadata sent at ingestion is returned under the `metadata` key.
54 #[serde(
55 rename = "metadata",
56 default,
57 with = "::serde_with::rust::double_option",
58 skip_serializing_if = "Option::is_none"
59 )]
60 pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
61 /// The tags associated with the trace.
62 #[serde(rename = "tags")]
63 pub tags: Vec<String>,
64 /// Public traces are accessible via url without login
65 #[serde(rename = "public")]
66 pub public: bool,
67 /// The environment from which this trace originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
68 #[serde(rename = "environment")]
69 pub environment: String,
70}
71
72impl Trace {
73 pub fn new(
74 id: String,
75 timestamp: chrono::DateTime<chrono::FixedOffset>,
76 name: Option<String>,
77 session_id: Option<String>,
78 release: Option<String>,
79 version: Option<String>,
80 user_id: Option<String>,
81 tags: Vec<String>,
82 public: bool,
83 environment: String,
84 ) -> Trace {
85 Trace {
86 id,
87 timestamp,
88 name,
89 input: None,
90 output: None,
91 session_id,
92 release,
93 version,
94 user_id,
95 metadata: None,
96 tags,
97 public,
98 environment,
99 }
100 }
101}