Skip to content

Commit

Permalink
merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb committed Apr 4, 2022
1 parent fd16c89 commit a0730e1
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MetricProducer
* @return a status of completion of method.
*/
virtual bool Collect(
nostd::function_ref<bool(ResourceMetrics metric_data)> callback) noexcept = 0;
nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept = 0;
};

} // namespace metrics
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/metric_exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MetricExporter
* concurrently for the same exporter instance.
* @param data metrics data
*/
virtual opentelemetry::sdk::common::ExportResult Export(const MetricData &data) noexcept = 0;
virtual opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &data) noexcept = 0;

/**
* Force flush the exporter.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/metric_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MetricReader
* Collect the metrics from SDK.
* @return return the status of the operation.
*/
bool Collect(nostd::function_ref<bool(ResourceMetrics &&metric_data)> callback) noexcept;
bool Collect(nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept;

AggregationTemporality GetAggregationTemporality() const noexcept;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MetricCollector : public MetricProducer, public CollectorHandle
*
* @return a status of completion of method.
*/
bool Collect(nostd::function_ref<bool(ResourceMetrics metric_data)> callback) noexcept override;
bool Collect(nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept override;

bool ForceFlush(std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept;

Expand Down
4 changes: 2 additions & 2 deletions sdk/src/metrics/export/periodic_exporting_metric_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ void PeriodicExportingMetricReader::DoBackgroundWork()
std::atomic<bool> cancel_export_for_timeout{false};
auto start = std::chrono::steady_clock::now();
auto future_receive = std::async(std::launch::async, [this, &cancel_export_for_timeout] {
Collect([this, &cancel_export_for_timeout](MetricData data) {
Collect([this, &cancel_export_for_timeout](ResourceMetrics &metric_data) {
if (cancel_export_for_timeout)
{
OTEL_INTERNAL_LOG_ERROR(
"[Periodic Exporting Metric Reader] Collect took longer configured time: "
<< export_timeout_millis_.count() << " ms, and timed out");
return false;
}
this->exporter_->Export(data);
this->exporter_->Export(metric_data);
return true;
});
});
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/metrics/metric_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AggregationTemporality MetricReader::GetAggregationTemporality() const noexcept
}

bool MetricReader::Collect(
nostd::function_ref<bool(ResourceMetrics &&metric_data)> callback) noexcept
nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept
{
if (!metric_producer_)
{
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/metrics/state/metric_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AggregationTemporality MetricCollector::GetAggregationTemporality() noexcept
}

bool MetricCollector::Collect(
nostd::function_ref<bool(ResourceMetrics metric_data)> callback) noexcept
nostd::function_ref<bool(ResourceMetrics &metric_data)> callback) noexcept
{
ResourceMetrics resource_metrics;
for (auto &meter : meter_context_->GetMeters())
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/metrics/meter_provider_sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MockMetricExporter : public MetricExporter

public:
MockMetricExporter() = default;
opentelemetry::sdk::common::ExportResult Export(const MetricData &records) noexcept override
opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &records) noexcept override
{
return opentelemetry::sdk::common::ExportResult::kSuccess;
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/metrics/metric_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ TEST(MetricReaderTest, BasicTests)
std::shared_ptr<MeterContext> meter_context2(new MeterContext(std::move(exporters)));
MetricProducer *metric_producer =
new MetricCollector(std::move(meter_context2), std::move(metric_reader2));
EXPECT_NO_THROW(metric_producer->Collect([](ResourceMetrics &&metric_data) { return true; }));
EXPECT_NO_THROW(metric_producer->Collect([](ResourceMetrics &metric_data) { return true; }));
}
#endif
8 changes: 4 additions & 4 deletions sdk/test/metrics/periodic_exporting_metric_reader_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace opentelemetry::sdk::metrics;
class MockPushMetricExporter : public MetricExporter
{
public:
opentelemetry::sdk::common::ExportResult Export(const MetricData &record) noexcept override
opentelemetry::sdk::common::ExportResult Export(const ResourceMetrics &record) noexcept override
{
records_.push_back(record);
return opentelemetry::sdk::common::ExportResult::kSuccess;
Expand All @@ -36,7 +36,7 @@ class MockPushMetricExporter : public MetricExporter
size_t GetDataCount() { return records_.size(); }

private:
std::vector<MetricData> records_;
std::vector<ResourceMetrics> records_;
};

class MockMetricProducer : public MetricProducer
Expand All @@ -46,11 +46,11 @@ class MockMetricProducer : public MetricProducer
: sleep_ms_{sleep_ms}, data_sent_size_(0)
{}

bool Collect(nostd::function_ref<bool(MetricData)> callback) noexcept override
bool Collect(nostd::function_ref<bool(ResourceMetrics &)> callback) noexcept override
{
std::this_thread::sleep_for(sleep_ms_);
data_sent_size_++;
MetricData data;
ResourceMetrics data;
callback(data);
return true;
}
Expand Down

0 comments on commit a0730e1

Please sign in to comment.