Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions opentelemetry-prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ rustdoc-args = ["--cfg", "docsrs"]
once_cell = "1.17"
opentelemetry = { version = "0.21", path = "../opentelemetry", default-features = false, features = ["metrics"] }
opentelemetry_sdk = { version = "0.20", path = "../opentelemetry-sdk", default-features = false, features = ["metrics"] }
prometheus = "0.13"
protobuf = "2.14"
prometheus = "0.14"

[dev-dependencies]
opentelemetry-semantic-conventions = { path = "../opentelemetry-semantic-conventions" }
Expand Down
30 changes: 15 additions & 15 deletions opentelemetry-prometheus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,9 @@ fn validate_metrics(
global::handle_error(MetricsError::Other(format!("Instrument type conflict, using existing type definition. Instrument {name}, Existing: {:?}, dropped: {:?}", existing.get_field_type(), metric_type)));
return (true, None);
}
if existing.get_help() != description {
global::handle_error(MetricsError::Other(format!("Instrument description conflict, using existing. Instrument {name}, Existing: {:?}, dropped: {:?}", existing.get_help(), description)));
return (false, Some(existing.get_help().to_string()));
if existing.help() != description {
global::handle_error(MetricsError::Other(format!("Instrument description conflict, using existing. Instrument {name}, Existing: {:?}, dropped: {:?}", existing.help(), description)));
return (false, Some(existing.help().to_string()));
}
(false, None)
} else {
Expand Down Expand Up @@ -458,16 +458,16 @@ fn add_histogram_metric<T: Numeric>(
let mut h = prometheus::proto::Histogram::default();
h.set_sample_sum(dp.sum.as_f64());
h.set_sample_count(dp.count);
h.set_bucket(protobuf::RepeatedField::from_vec(bucket));
h.set_bucket(bucket);
let mut pm = prometheus::proto::Metric::default();
pm.set_label(protobuf::RepeatedField::from_vec(kvs));
pm.set_label(kvs);
pm.set_histogram(h);

let mut mf = prometheus::proto::MetricFamily::default();
mf.set_name(name.to_string());
mf.set_help(description.clone());
mf.set_field_type(prometheus::proto::MetricType::HISTOGRAM);
mf.set_metric(protobuf::RepeatedField::from_vec(vec![pm]));
mf.set_metric(vec![pm]);
res.push(mf);
}
}
Expand All @@ -489,7 +489,7 @@ fn add_sum_metric<T: Numeric>(
let kvs = get_attrs(&mut dp.attributes.iter(), extra);

let mut pm = prometheus::proto::Metric::default();
pm.set_label(protobuf::RepeatedField::from_vec(kvs));
pm.set_label(kvs);

if sum.is_monotonic {
let mut c = prometheus::proto::Counter::default();
Expand All @@ -505,7 +505,7 @@ fn add_sum_metric<T: Numeric>(
mf.set_name(name.to_string());
mf.set_help(description.clone());
mf.set_field_type(metric_type);
mf.set_metric(protobuf::RepeatedField::from_vec(vec![pm]));
mf.set_metric(vec![pm]);
res.push(mf);
}
}
Expand All @@ -523,14 +523,14 @@ fn add_gauge_metric<T: Numeric>(
let mut g = prometheus::proto::Gauge::default();
g.set_value(dp.value.as_f64());
let mut pm = prometheus::proto::Metric::default();
pm.set_label(protobuf::RepeatedField::from_vec(kvs));
pm.set_label(kvs);
pm.set_gauge(g);

let mut mf = prometheus::proto::MetricFamily::default();
mf.set_name(name.to_string());
mf.set_help(description.to_string());
mf.set_field_type(MetricType::GAUGE);
mf.set_metric(protobuf::RepeatedField::from_vec(vec![pm]));
mf.set_metric(vec![pm]);
res.push(mf);
}
}
Expand All @@ -544,17 +544,17 @@ fn create_info_metric(
g.set_value(1.0);

let mut m = prometheus::proto::Metric::default();
m.set_label(protobuf::RepeatedField::from_vec(get_attrs(
m.set_label(get_attrs(
&mut resource.iter(),
&[],
)));
));
m.set_gauge(g);

let mut mf = MetricFamily::default();
mf.set_name(target_info_name.into());
mf.set_help(target_info_description.into());
mf.set_field_type(MetricType::GAUGE);
mf.set_metric(protobuf::RepeatedField::from_vec(vec![m]));
mf.set_metric(vec![m]);
mf
}

Expand All @@ -575,14 +575,14 @@ fn create_scope_info_metric(scope: &Scope) -> MetricFamily {
}

let mut m = prometheus::proto::Metric::default();
m.set_label(protobuf::RepeatedField::from_vec(labels));
m.set_label(labels);
m.set_gauge(g);

let mut mf = MetricFamily::default();
mf.set_name(SCOPE_INFO_METRIC_NAME.into());
mf.set_help(SCOPE_INFO_DESCRIPTION.into());
mf.set_field_type(MetricType::GAUGE);
mf.set_metric(protobuf::RepeatedField::from_vec(vec![m]));
mf.set_metric(vec![m]);
mf
}

Expand Down
Loading