|
15 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | * |
17 | 17 | */ |
18 | | - |
19 | | -use std::collections::HashSet; |
20 | | - |
21 | 18 | use opentelemetry_proto::tonic::metrics::v1::number_data_point::Value as NumberDataPointValue; |
22 | 19 | use opentelemetry_proto::tonic::metrics::v1::{ |
23 | 20 | exemplar::Value as ExemplarValue, exponential_histogram_data_point::Buckets, metric, Exemplar, |
24 | 21 | ExponentialHistogram, Gauge, Histogram, Metric, MetricsData, NumberDataPoint, Sum, Summary, |
25 | 22 | }; |
26 | 23 | use serde_json::{Map, Value}; |
27 | 24 |
|
28 | | -use crate::otel::otel_utils::OtelError; |
29 | | -use crate::parseable::PARSEABLE; |
30 | | - |
31 | 25 | use super::otel_utils::{ |
32 | 26 | convert_epoch_nano_to_timestamp, insert_attributes, insert_number_if_some, |
33 | 27 | }; |
@@ -507,10 +501,8 @@ pub fn flatten_metrics_record(metrics_record: &Metric) -> Vec<Map<String, Value> |
507 | 501 |
|
508 | 502 | /// this function performs the custom flattening of the otel metrics |
509 | 503 | /// and returns a `Vec` of `Value::Object` of the flattened json |
510 | | -pub fn flatten_otel_metrics(message: MetricsData) -> Result<Vec<Value>, OtelError> { |
| 504 | +pub fn flatten_otel_metrics(message: MetricsData) -> Vec<Value> { |
511 | 505 | let mut vec_otel_json = Vec::new(); |
512 | | - let known_fields: HashSet<&str> = OTEL_METRICS_KNOWN_FIELD_LIST.iter().cloned().collect(); |
513 | | - |
514 | 506 | for record in &message.resource_metrics { |
515 | 507 | let mut resource_metrics_json = Map::new(); |
516 | 508 | if let Some(resource) = &record.resource { |
@@ -564,29 +556,11 @@ pub fn flatten_otel_metrics(message: MetricsData) -> Result<Vec<Value>, OtelErro |
564 | 556 | resource_metric_json.insert(key.clone(), value.clone()); |
565 | 557 | } |
566 | 558 |
|
567 | | - let attribute_count = resource_metric_json |
568 | | - .iter() |
569 | | - .filter(|(key, _)| !known_fields.contains(key.as_str())) |
570 | | - .count(); |
571 | | - |
572 | | - // Check if the number of attributes exceeds the allowed limit |
573 | | - if attribute_count > PARSEABLE.options.otel_attributes_allowed_limit { |
574 | | - tracing::error!( |
575 | | - "OTEL metrics ingestion failed because the number of attributes ({}) exceeded the threshold of {}", |
576 | | - attribute_count, |
577 | | - PARSEABLE.options.otel_attributes_allowed_limit |
578 | | - ); |
579 | | - return Err(OtelError::AttributeCountExceeded( |
580 | | - attribute_count, |
581 | | - PARSEABLE.options.otel_attributes_allowed_limit, |
582 | | - )); |
583 | | - } |
584 | | - |
585 | 559 | vec_otel_json.push(Value::Object(resource_metric_json.clone())); |
586 | 560 | } |
587 | 561 | } |
588 | 562 |
|
589 | | - Ok(vec_otel_json) |
| 563 | + vec_otel_json |
590 | 564 | } |
591 | 565 |
|
592 | 566 | /// otel metrics event has json object for aggregation temporality |
|
0 commit comments