Skip to content

Commit 5774487

Browse files
authored
Revert "[Partial Fix] - remove/comment end timestamp from OTLP export metrics (#667)"
This reverts commit fb99bb3.
1 parent fb99bb3 commit 5774487

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Metrics.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ void Counter::to_prometheus(std::stringstream &out, Metric::LabelMap add_labels)
1919
out << name_snake({}, add_labels) << ' ' << _value << std::endl;
2020
}
2121

22-
void Counter::to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, [[maybe_unused]] timespec &end, Metric::LabelMap add_labels) const
22+
void Counter::to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, timespec &end, Metric::LabelMap add_labels) const
2323
{
2424
auto metric = scope.add_metrics();
2525
metric->set_name(base_name_snake());
2626
metric->set_description(_desc);
2727
auto gauge_data_point = metric->mutable_gauge()->add_data_points();
2828
gauge_data_point->set_as_int(_value);
2929
gauge_data_point->set_start_time_unix_nano(timespec_to_uint64(start));
30-
//gauge_data_point->set_time_unix_nano(timespec_to_uint64(end));
30+
gauge_data_point->set_time_unix_nano(timespec_to_uint64(end));
3131
for (const auto &label: add_labels) {
3232
auto attribute = gauge_data_point->add_attributes();
3333
attribute->set_key(label.first);
@@ -79,15 +79,15 @@ void Cardinality::to_prometheus(std::stringstream &out, Metric::LabelMap add_lab
7979
out << name_snake({}, add_labels) << ' ' << lround(_set.get_estimate()) << std::endl;
8080
}
8181

82-
void Cardinality::to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, [[maybe_unused]] timespec &end, Metric::LabelMap add_labels) const
82+
void Cardinality::to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, timespec &end, Metric::LabelMap add_labels) const
8383
{
8484
auto metric = scope.add_metrics();
8585
metric->set_name(base_name_snake());
8686
metric->set_description(_desc);
8787
auto gauge_data_point = metric->mutable_gauge()->add_data_points();
8888
gauge_data_point->set_as_int(lround(_set.get_estimate()));
8989
gauge_data_point->set_start_time_unix_nano(timespec_to_uint64(start));
90-
//gauge_data_point->set_time_unix_nano(timespec_to_uint64(end));
90+
gauge_data_point->set_time_unix_nano(timespec_to_uint64(end));
9191
for (const auto &label: add_labels) {
9292
auto attribute = gauge_data_point->add_attributes();
9393
attribute->set_key(label.first);

src/Metrics.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ struct comparator {
5050
}
5151
};
5252

53-
static inline uint64_t timespec_to_uint64(const timespec &stamp)
53+
static inline uint64_t timespec_to_uint64(timespec &stamp)
5454
{
55-
return (stamp.tv_sec * 1000000000ULL) + stamp.tv_nsec;
55+
return stamp.tv_sec * 1000000000ULL + stamp.tv_nsec;
5656
}
5757

5858
class Metric
@@ -293,7 +293,7 @@ class Histogram final : public Metric
293293
out << name_snake({"count"}, add_labels) << ' ' << _sketch.get_n() << std::endl;
294294
}
295295

296-
void to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, [[maybe_unused]] timespec &end, LabelMap add_labels = {}) const
296+
void to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, timespec &end, LabelMap add_labels = {}) const
297297
{
298298
if (_sketch.is_empty()) {
299299
return;
@@ -316,7 +316,7 @@ class Histogram final : public Metric
316316
m_hist->set_aggregation_temporality(metrics::v1::AggregationTemporality::AGGREGATION_TEMPORALITY_CUMULATIVE);
317317
auto hist_data_point = m_hist->add_data_points();
318318
hist_data_point->set_start_time_unix_nano(timespec_to_uint64(start));
319-
// hist_data_point->set_time_unix_nano(timespec_to_uint64(end));
319+
hist_data_point->set_time_unix_nano(timespec_to_uint64(end));
320320

321321
for (std::size_t i = 0; i < bins.size(); ++i) {
322322
hist_data_point->add_explicit_bounds(bins[i] - pace);
@@ -448,7 +448,7 @@ class Quantile final : public Metric
448448
}
449449
}
450450

451-
void to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, [[maybe_unused]] timespec &end, LabelMap add_labels = {}) const override
451+
void to_opentelemetry(metrics::v1::ScopeMetrics &scope, timespec &start, timespec &end, LabelMap add_labels = {}) const override
452452
{
453453
if (_quantile.is_empty()) {
454454
return;
@@ -467,7 +467,7 @@ class Quantile final : public Metric
467467
metric->set_description(_desc);
468468
auto summary_data_point = metric->mutable_summary()->add_data_points();
469469
summary_data_point->set_start_time_unix_nano(timespec_to_uint64(start));
470-
// summary_data_point->set_time_unix_nano(timespec_to_uint64(end));
470+
summary_data_point->set_time_unix_nano(timespec_to_uint64(end));
471471
for (auto it = quantiles.begin(); it != quantiles.end(); ++it) {
472472
auto quantile = summary_data_point->add_quantile_values();
473473
quantile->set_quantile(fractions[it - quantiles.begin()]);
@@ -521,11 +521,11 @@ class TopN final : public Metric
521521
return quantile.get_quantile(_percentile_threshold);
522522
}
523523

524-
void _set_opentelemetry_data(opentelemetry::proto::metrics::v1::NumberDataPoint *data_point, uint64_t start, [[maybe_unused]] uint64_t end, const Metric::LabelMap &l, uint64_t value) const
524+
void _set_opentelemetry_data(opentelemetry::proto::metrics::v1::NumberDataPoint *data_point, uint64_t start, uint64_t end, const Metric::LabelMap &l, uint64_t value) const
525525
{
526526
data_point->set_as_int(value);
527527
data_point->set_start_time_unix_nano(start);
528-
//data_point->set_time_unix_nano(end);
528+
data_point->set_time_unix_nano(end);
529529
for (const auto &label : l) {
530530
auto attribute = data_point->add_attributes();
531531
attribute->set_key(label.first);

0 commit comments

Comments
 (0)