/*
* server
*
* ## 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`
*
* The version of the OpenAPI document:
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TraceWithFullDetails {
/// The unique identifier of a trace
#[serde(rename = "id")]
pub id: String,
/// The timestamp when the trace was created
#[serde(rename = "timestamp")]
pub timestamp: chrono::DateTime<chrono::FixedOffset>,
/// The name of the trace
#[serde(rename = "name", deserialize_with = "Option::deserialize")]
pub name: Option<String>,
/// The input data of the trace. Can be any JSON.
#[serde(
rename = "input",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub input: Option<Option<serde_json::Value>>,
/// The output data of the trace. Can be any JSON.
#[serde(
rename = "output",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub output: Option<Option<serde_json::Value>>,
/// The session identifier associated with the trace
#[serde(rename = "sessionId", deserialize_with = "Option::deserialize")]
pub session_id: Option<String>,
/// The release version of the application when the trace was created
#[serde(rename = "release", deserialize_with = "Option::deserialize")]
pub release: Option<String>,
/// The version of the trace
#[serde(rename = "version", deserialize_with = "Option::deserialize")]
pub version: Option<String>,
/// The user identifier associated with the trace
#[serde(rename = "userId", deserialize_with = "Option::deserialize")]
pub user_id: Option<String>,
/// The metadata associated with the trace. Values can be any JSON; non-object metadata sent at ingestion is returned under the `metadata` key.
#[serde(
rename = "metadata",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub metadata: Option<Option<std::collections::HashMap<String, serde_json::Value>>>,
/// The tags associated with the trace.
#[serde(rename = "tags")]
pub tags: Vec<String>,
/// Public traces are accessible via url without login
#[serde(rename = "public")]
pub public: bool,
/// The environment from which this trace originated. Can be any lowercase alphanumeric string with hyphens and underscores that does not start with 'langfuse'.
#[serde(rename = "environment")]
pub environment: String,
/// Path of trace in Langfuse UI
#[serde(rename = "htmlPath")]
pub html_path: String,
/// Latency of trace in seconds
#[serde(
rename = "latency",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub latency: Option<Option<f64>>,
/// Cost of trace in USD
#[serde(
rename = "totalCost",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub total_cost: Option<Option<f64>>,
/// List of observations
#[serde(rename = "observations")]
pub observations: Vec<models::ObservationsView>,
/// List of scores
#[serde(rename = "scores")]
pub scores: Vec<models::ScoreV1>,
#[serde(rename = "_deprecation", skip_serializing_if = "Option::is_none")]
pub _deprecation: Option<Box<models::Deprecation>>,
}
impl TraceWithFullDetails {
pub fn new(
id: String,
timestamp: chrono::DateTime<chrono::FixedOffset>,
name: Option<String>,
session_id: Option<String>,
release: Option<String>,
version: Option<String>,
user_id: Option<String>,
tags: Vec<String>,
public: bool,
environment: String,
html_path: String,
observations: Vec<models::ObservationsView>,
scores: Vec<models::ScoreV1>,
) -> TraceWithFullDetails {
TraceWithFullDetails {
id,
timestamp,
name,
input: None,
output: None,
session_id,
release,
version,
user_id,
metadata: None,
tags,
public,
environment,
html_path,
latency: None,
total_cost: None,
observations,
scores,
_deprecation: None,
}
}
}