Skip to main content

libdd_telemetry/data/
metrics.rs

1// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
2// SPDX-License-Identifier: Apache-2.0
3
4use libdd_common::tag::Tag;
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Debug)]
8pub struct Serie {
9    pub namespace: MetricNamespace,
10    pub metric: String,
11    pub points: Vec<(u64, f64)>,
12    pub tags: Vec<Tag>,
13    pub common: bool,
14    #[serde(rename = "type")]
15    pub _type: MetricType,
16    pub interval: u64,
17}
18
19#[derive(Serialize, Debug)]
20pub struct Distribution {
21    pub namespace: MetricNamespace,
22    pub metric: String,
23    pub tags: Vec<Tag>,
24    #[serde(flatten)]
25    pub sketch: SerializedSketch,
26    pub common: bool,
27    pub interval: u64,
28    #[serde(rename = "type")]
29    pub _type: MetricType,
30}
31
32#[derive(Serialize, Debug)]
33#[serde(untagged)]
34pub enum SerializedSketch {
35    Bytes { sketch: Vec<u8> },
36    B64 { sketch_b64: String },
37}
38
39#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
40#[serde(rename_all = "snake_case")]
41#[repr(C)]
42pub enum MetricNamespace {
43    Tracers,
44    Profilers,
45    Rum,
46    Appsec,
47    IdePlugins,
48    LiveDebugger,
49    Iast,
50    General,
51    Telemetry,
52    Apm,
53    Sidecar,
54}
55
56#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash)]
57#[serde(rename_all = "snake_case")]
58#[repr(C)]
59pub enum MetricType {
60    Gauge,
61    Count,
62    Distribution,
63}