1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
use std::{collections::HashMap, time::SystemTime};
use super::v7::{DebugMeta, TraceId};
use crate::utils::ts_rfc3339;
use serde::{Deserialize, Serialize, Serializer};
use uuid::Uuid;
fn serialize_id<S: Serializer>(uuid: &Uuid, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_some(&uuid.as_simple())
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct TransactionMetadata {
#[serde(serialize_with = "serialize_id")]
pub id: Uuid,
pub name: String,
pub trace_id: TraceId,
pub relative_start_ns: u64,
pub relative_end_ns: u64,
#[serde(default)]
pub active_thread_id: u64,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)]
pub struct RustFrame {
pub instruction_addr: String,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Sample {
pub stack_id: u32,
pub thread_id: u64,
pub elapsed_since_start_ns: u64,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct ThreadMetadata {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct Profile {
pub samples: Vec<Sample>,
pub stacks: Vec<Vec<u32>>,
pub frames: Vec<RustFrame>,
pub thread_metadata: HashMap<String, ThreadMetadata>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct OSMetadata {
pub name: String,
pub version: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub build_number: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct RuntimeMetadata {
pub name: String,
pub version: String,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub struct DeviceMetadata {
pub architecture: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
pub enum Version {
#[serde(rename = "1")]
V1,
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct SampleProfile {
pub version: Version,
#[serde(skip_serializing_if = "Option::is_none")]
pub debug_meta: Option<DebugMeta>,
pub device: DeviceMetadata,
pub os: OSMetadata,
#[serde(skip_serializing_if = "Option::is_none")]
pub runtime: Option<RuntimeMetadata>,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub environment: String,
#[serde(serialize_with = "serialize_id")]
pub event_id: Uuid,
pub platform: String,
pub profile: Profile,
pub release: String,
#[serde(with = "ts_rfc3339")]
pub timestamp: SystemTime,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub transactions: Vec<TransactionMetadata>,
}