forked from open-telemetry/otel-arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
157 lines (134 loc) · 4.42 KB
/
lib.rs
File metadata and controls
157 lines (134 loc) · 4.42 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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//! OTAP data plane configuration.
//!
//! Data Model:
//! - data plane
//! - pipeline groups
//! - pipelines
//! - nodes
//!
//! A data plane is a collection of pipeline groups, where each group can have multiple pipelines.
//! A pipeline is a collection of nodes interconnected in a directed acyclic graph (DAG).
use serde::{Deserialize, Serialize, ser::Serializer};
use std::borrow::Cow;
use std::hash::Hash;
pub mod byte_units;
/// Config URI providers for resolving configuration from file:, env:, or bare paths.
pub mod config_provider;
pub mod engine;
/// Environment variable substitution for raw config text.
pub mod env_substitution;
pub mod error;
pub mod health;
pub mod node;
/// Node type URN value object.
pub mod node_urn;
pub mod observed_state;
pub mod pipeline;
pub mod pipeline_group;
pub mod policy;
/// Engine telemetry settings.
pub mod settings;
/// TLS configuration.
pub mod tls;
pub mod topic;
/// Transport header core types and capture/propagation engines.
pub mod transport_headers;
/// Transport header capture and propagation policy declarations.
pub mod transport_headers_policy;
pub use topic::{
SubscriptionGroupName, TopicAckPropagationMode, TopicAckPropagationPolicies, TopicBackendKind,
TopicBroadcastOnLagPolicy, TopicImplSelectionPolicy, TopicName,
};
/// Validation helpers for node configuration.
pub mod validation;
/// Signal types
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SignalType {
/// Signal representing a stream of spans.
Traces,
/// Signal representing a stream of metrics.
Metrics,
/// Signal representing a stream of logs.
Logs,
}
/// Signal formats
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SignalFormat {
/// OTel-Arrow records
OtapRecords,
/// OTLP protobuf bytes
OtlpBytes,
// TODO: maybe add types not included in OtapPdata including
// OtlpProtoMessage, OtapArrowBytes, and possible opaque.
}
/// The id of a pipeline group.
pub type PipelineGroupId = Cow<'static, str>;
/// The id of a pipeline.
pub type PipelineId = Cow<'static, str>;
/// The id of a node in the pipeline.
pub type NodeId = Cow<'static, str>;
/// The id of a capability binding (e.g., "bearer_token_provider").
pub type CapabilityId = Cow<'static, str>;
/// The URN of a node type.
pub use node_urn::NodeUrn;
/// MetricLevel is widely used.
pub use policy::MetricLevel;
/// The name of a node output port in the pipeline.
pub type PortName = Cow<'static, str>;
/// The description of a pipeline or a node.
pub type Description = Cow<'static, str>;
/// Type alias for CPU core identifier.
/// Note: Not using core_affinity::CoreId directly to avoid dependency leakage in this public API
pub type CoreId = usize;
/// Unique key for identifying a pipeline within a pipeline group.
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct PipelineKey {
pipeline_group_id: PipelineGroupId,
pipeline_id: PipelineId,
}
impl PipelineKey {
/// Construct a new PipelineKey from group and pipeline ids.
#[must_use]
pub const fn new(pipeline_group_id: PipelineGroupId, pipeline_id: PipelineId) -> Self {
Self {
pipeline_group_id,
pipeline_id,
}
}
/// Returns the pipeline group identifier.
#[must_use]
pub const fn pipeline_group_id(&self) -> &PipelineGroupId {
&self.pipeline_group_id
}
/// Returns the pipeline identifier.
#[must_use]
pub const fn pipeline_id(&self) -> &PipelineId {
&self.pipeline_id
}
/// Returns a `group_id:pipeline_id` string representation.
#[must_use]
pub fn as_string(&self) -> String {
format!("{}:{}", self.pipeline_group_id, self.pipeline_id)
}
}
impl Serialize for PipelineKey {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let s = self.as_string();
serializer.serialize_str(&s)
}
}
/// Unique key for identifying a pipeline running on a specific core.
#[derive(Debug, Clone, Serialize)]
pub struct DeployedPipelineKey {
/// The unique ID of the pipeline group the pipeline belongs to.
pub pipeline_group_id: PipelineGroupId,
/// The unique ID of the pipeline within its group.
pub pipeline_id: PipelineId,
/// The CPU core ID the pipeline is pinned to.
pub core_id: CoreId,
}