use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct TraceWithDetails {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "timestamp")]
pub timestamp: chrono::DateTime<chrono::FixedOffset>,
#[serde(rename = "name", deserialize_with = "Option::deserialize")]
pub name: Option<String>,
#[serde(
rename = "input",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub input: Option<Option<serde_json::Value>>,
#[serde(
rename = "output",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub output: Option<Option<serde_json::Value>>,
#[serde(rename = "sessionId", deserialize_with = "Option::deserialize")]
pub session_id: Option<String>,
#[serde(rename = "release", deserialize_with = "Option::deserialize")]
pub release: Option<String>,
#[serde(rename = "version", deserialize_with = "Option::deserialize")]
pub version: Option<String>,
#[serde(rename = "userId", deserialize_with = "Option::deserialize")]
pub user_id: Option<String>,
#[serde(
rename = "metadata",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub metadata: Option<Option<serde_json::Value>>,
#[serde(rename = "tags")]
pub tags: Vec<String>,
#[serde(rename = "public")]
pub public: bool,
#[serde(rename = "environment")]
pub environment: String,
#[serde(rename = "htmlPath")]
pub html_path: String,
#[serde(
rename = "latency",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub latency: Option<Option<f64>>,
#[serde(
rename = "totalCost",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub total_cost: Option<Option<f64>>,
#[serde(
rename = "observations",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub observations: Option<Option<Vec<String>>>,
#[serde(
rename = "scores",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub scores: Option<Option<Vec<String>>>,
}
impl TraceWithDetails {
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,
) -> TraceWithDetails {
TraceWithDetails {
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: None,
scores: None,
}
}
}