forked from open-telemetry/weaver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattribute_group.rs
More file actions
44 lines (36 loc) · 1.36 KB
/
attribute_group.rs
File metadata and controls
44 lines (36 loc) · 1.36 KB
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
// SPDX-License-Identifier: Apache-2.0
//! The new way we want to define attribute groups going forward.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use weaver_semconv::v2::{signal_id::SignalId, CommonFields};
use crate::v2::{attribute::AttributeRef, lineage::SignalLineage, Signal};
/// Public attribute group.
///
/// An attribute group is a grouping of attributes that can be leveraged
/// in codegen. For example, rather than passing attributes on at a time,
/// a temporary structure could be made to contain all of them and report
/// the bundle as a group to different signals.
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema, PartialEq)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "snake_case")]
pub struct AttributeGroup {
/// The name of the attribute group, must be unique.
pub id: SignalId,
/// List of attributes and group references that belong to this group
pub attributes: Vec<AttributeRef>,
/// Common fields (like brief, note, annotations).
#[serde(flatten)]
pub common: CommonFields,
/// Lineage for this attribute group.
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
pub lineage: Option<SignalLineage>,
}
impl Signal for AttributeGroup {
fn id(&self) -> &str {
&self.id
}
fn common(&self) -> &CommonFields {
&self.common
}
}