Skip to content

Commit 570a7f4

Browse files
fix: cargo hack, incorporate review comments
1 parent 5c22ab1 commit 570a7f4

15 files changed

+125
-150
lines changed

Cargo.lock

Lines changed: 0 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,6 @@ zip = { version = "2.2.0", default-features = false, features = ["deflate"] }
117117
url = "2.4.0"
118118
prost-build = "0.13.3"
119119

120-
[dev-dependencies]
121-
maplit = "1.0"
122-
rstest = "0.23.0"
123-
arrow = "53.0.0"
124-
125120
[package.metadata.parseable_ui]
126121
assets-url = "https://github.com/parseablehq/console/releases/download/v0.9.12/build.zip"
127122
assets-sha1 = "9d5a45f204d709a2dd96f6a5e0b21b3834ee0e36"

src/handlers/http/ingest.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
use super::logstream::error::{CreateStreamError, StreamError};
2020
use super::modal::utils::ingest_utils::{flatten_and_push_logs, push_logs};
21+
use super::otel::logs::flatten_otel_logs;
22+
use super::otel::metrics::flatten_otel_metrics;
23+
use super::otel::traces::flatten_otel_traces;
2124
use super::users::dashboards::DashboardError;
2225
use super::users::filters::FiltersError;
23-
use super::{otel_logs, otel_metrics, otel_traces};
2426
use crate::event::{
2527
self,
2628
error::EventError,
@@ -119,7 +121,7 @@ pub async fn handle_otel_logs_ingestion(
119121
create_stream_if_not_exists(&stream_name, &StreamType::UserDefined.to_string()).await?;
120122

121123
//custom flattening required for otel logs
122-
let mut json = otel_logs::flatten_otel_logs(&body);
124+
let mut json = flatten_otel_logs(&body);
123125
for record in json.iter_mut() {
124126
let body: Bytes = serde_json::to_vec(record).unwrap().into();
125127
push_logs(&stream_name, &req, &body).await?;
@@ -146,7 +148,7 @@ pub async fn handle_otel_metrics_ingestion(
146148
create_stream_if_not_exists(&stream_name, &StreamType::UserDefined.to_string()).await?;
147149

148150
//custom flattening required for otel metrics
149-
let mut json = otel_metrics::flatten_otel_metrics(&body);
151+
let mut json = flatten_otel_metrics(&body);
150152
for record in json.iter_mut() {
151153
let body: Bytes = serde_json::to_vec(record).unwrap().into();
152154
push_logs(&stream_name, &req, &body).await?;
@@ -173,7 +175,7 @@ pub async fn handle_otel_traces_ingestion(
173175
create_stream_if_not_exists(&stream_name, &StreamType::UserDefined.to_string()).await?;
174176

175177
//custom flattening required for otel traces
176-
let mut json = otel_traces::flatten_otel_traces(&body);
178+
let mut json = flatten_otel_traces(&body);
177179
for record in json.iter_mut() {
178180
let body: Bytes = serde_json::to_vec(record).unwrap().into();
179181
push_logs(&stream_name, &req, &body).await?;

src/handlers/http/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ pub mod middleware;
3838
pub mod modal;
3939
pub mod oidc;
4040
pub mod otel;
41-
pub mod otel_logs;
42-
pub mod otel_metrics;
43-
pub mod otel_traces;
4441
pub mod query;
4542
pub mod rbac;
4643
pub mod role;

src/handlers/http/modal/utils/ingest_utils.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ use crate::{
3333
format::{self, EventFormat},
3434
},
3535
handlers::{
36-
http::{ingest::PostError, kinesis, otel_logs, otel_metrics, otel_traces},
36+
http::{
37+
ingest::PostError,
38+
kinesis,
39+
otel::{
40+
logs::flatten_otel_logs, metrics::flatten_otel_metrics, traces::flatten_otel_traces,
41+
},
42+
},
3743
LOG_SOURCE_KEY, LOG_SOURCE_KINESIS, LOG_SOURCE_OTEL_LOGS, LOG_SOURCE_OTEL_METRICS,
3844
LOG_SOURCE_OTEL_TRACES, PREFIX_META, PREFIX_TAGS, SEPARATOR,
3945
},
@@ -56,17 +62,17 @@ pub async fn flatten_and_push_logs(
5662

5763
//custom flattening required for otel logs
5864
LOG_SOURCE_OTEL_LOGS => {
59-
json = otel_logs::flatten_otel_logs(&body);
65+
json = flatten_otel_logs(&body);
6066
}
6167

6268
//custom flattening required for otel metrics
6369
LOG_SOURCE_OTEL_METRICS => {
64-
json = otel_metrics::flatten_otel_metrics(&body);
70+
json = flatten_otel_metrics(&body);
6571
}
6672

6773
//custom flattening required for otel traces
6874
LOG_SOURCE_OTEL_TRACES => {
69-
json = otel_traces::flatten_otel_traces(&body);
75+
json = flatten_otel_traces(&body);
7076
}
7177
_ => {
7278
tracing::warn!("Unknown log source: {}", log_source);

src/handlers/http/otel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*
1717
*/
18+
pub mod logs;
19+
pub mod metrics;
20+
#[allow(clippy::all)]
1821
pub mod proto;
22+
pub mod traces;
1923
use proto::common::v1::KeyValue;
2024
use serde_json::Value;
2125
use std::collections::BTreeMap;

src/handlers/http/otel/opentelemetry.proto.metrics.v1.rs renamed to src/handlers/http/otel/compiled_protos/opentelemetry.proto.metrics.v1.rs

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ pub struct Metric {
191191
/// name of the metric.
192192
pub name: Option<String>,
193193
/// description of the metric, which can be used in documentation.
194-
195194
pub description: Option<String>,
196195
/// unit in which the metric value is reported. Follows the format
197196
/// described by <http://unitsofmeasure.org/ucum.html.>
@@ -235,10 +234,8 @@ pub struct Sum {
235234
pub data_points: Option<Vec<NumberDataPoint>>,
236235
/// aggregation_temporality describes if the aggregator reports delta changes
237236
/// since last report time, or cumulative changes since a fixed start time.
238-
239237
pub aggregation_temporality: Option<i32>,
240238
/// If "true" means that the sum is monotonic.
241-
242239
pub is_monotonic: Option<bool>,
243240
}
244241
/// Histogram represents the type of a metric that is calculated by aggregating
@@ -250,7 +247,6 @@ pub struct Histogram {
250247
pub data_points: Option<Vec<HistogramDataPoint>>,
251248
/// aggregation_temporality describes if the aggregator reports delta changes
252249
/// since last report time, or cumulative changes since a fixed start time.
253-
254250
pub aggregation_temporality: Option<i32>,
255251
}
256252
/// ExponentialHistogram represents the type of a metric that is calculated by aggregating
@@ -261,7 +257,6 @@ pub struct ExponentialHistogram {
261257
pub data_points: Option<Vec<ExponentialHistogramDataPoint>>,
262258
/// aggregation_temporality describes if the aggregator reports delta changes
263259
/// since last report time, or cumulative changes since a fixed start time.
264-
265260
pub aggregation_temporality: Option<i32>,
266261
}
267262
/// Summary metric data are used to convey quantile summaries,
@@ -560,7 +555,7 @@ pub mod summary_data_point {
560555
fn deserialize_f64_or_nan<'de, D>(deserializer: D) -> Result<Option<f64>, D::Error> where D: Deserializer<'de>,
561556
{
562557
struct StringOrFloatVisitor;
563-
impl<'de> serde::de::Visitor<'de> for StringOrFloatVisitor
558+
impl serde::de::Visitor<'_> for StringOrFloatVisitor
564559
{
565560
type Value = Option<f64>;
566561
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
@@ -617,68 +612,8 @@ pub struct Exemplar {
617612
/// which they are aggregated.
618613
#[repr(i32)]
619614
pub enum AggregationTemporality {
620-
/// UNSPECIFIED is the default AggregationTemporality, it MUST not be used.
621615
Unspecified = 0,
622-
/// DELTA is an AggregationTemporality for a metric aggregator which reports
623-
/// changes since last report time. Successive metrics contain aggregation of
624-
/// values from continuous and non-overlapping intervals.
625-
///
626-
/// The values for a DELTA metric are based only on the time interval
627-
/// associated with one measurement cycle. There is no dependency on
628-
/// previous measurements like is the case for CUMULATIVE metrics.
629-
///
630-
/// For example, consider a system measuring the number of requests that
631-
/// it receives and reports the sum of these requests every second as a
632-
/// DELTA metric:
633-
///
634-
/// 1. The system starts receiving at time=t_0.
635-
/// 2. A request is received, the system measures 1 request.
636-
/// 3. A request is received, the system measures 1 request.
637-
/// 4. A request is received, the system measures 1 request.
638-
/// 5. The 1 second collection cycle ends. A metric is exported for the
639-
/// number of requests received over the interval of time t_0 to
640-
/// t_0+1 with a value of 3.
641-
/// 6. A request is received, the system measures 1 request.
642-
/// 7. A request is received, the system measures 1 request.
643-
/// 8. The 1 second collection cycle ends. A metric is exported for the
644-
/// number of requests received over the interval of time t_0+1 to
645-
/// t_0+2 with a value of 2.
646616
Delta = 1,
647-
/// CUMULATIVE is an AggregationTemporality for a metric aggregator which
648-
/// reports changes since a fixed start time. This means that current values
649-
/// of a CUMULATIVE metric depend on all previous measurements since the
650-
/// start time. Because of this, the sender is required to retain this state
651-
/// in some form. If this state is lost or invalidated, the CUMULATIVE metric
652-
/// values MUST be reset and a new fixed start time following the last
653-
/// reported measurement time sent MUST be used.
654-
///
655-
/// For example, consider a system measuring the number of requests that
656-
/// it receives and reports the sum of these requests every second as a
657-
/// CUMULATIVE metric:
658-
///
659-
/// 1. The system starts receiving at time=t_0.
660-
/// 2. A request is received, the system measures 1 request.
661-
/// 3. A request is received, the system measures 1 request.
662-
/// 4. A request is received, the system measures 1 request.
663-
/// 5. The 1 second collection cycle ends. A metric is exported for the
664-
/// number of requests received over the interval of time t_0 to
665-
/// t_0+1 with a value of 3.
666-
/// 6. A request is received, the system measures 1 request.
667-
/// 7. A request is received, the system measures 1 request.
668-
/// 8. The 1 second collection cycle ends. A metric is exported for the
669-
/// number of requests received over the interval of time t_0 to
670-
/// t_0+2 with a value of 5.
671-
/// 9. The system experiences a fault and loses state.
672-
/// 10. The system recovers and resumes receiving at time=t_1.
673-
/// 11. A request is received, the system measures 1 request.
674-
/// 12. The 1 second collection cycle ends. A metric is exported for the
675-
/// number of requests received over the interval of time t_1 to
676-
/// t_0+1 with a value of 1.
677-
///
678-
/// Note: Even though, when reporting changes since last report time, using
679-
/// CUMULATIVE is valid, it is not recommended. This may cause problems for
680-
/// systems that do not use start_time to determine when the aggregation
681-
/// value was reset (e.g. Prometheus).
682617
Cumulative = 2,
683618
}
684619
impl AggregationTemporality {

0 commit comments

Comments
 (0)