2
0

common.cc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. #include "common.h"
  4. #include <utility>
  5. #include "opentelemetry/sdk/instrumentationscope/instrumentation_scope.h"
  6. using namespace opentelemetry::sdk::instrumentationscope;
  7. using namespace opentelemetry::sdk::metrics;
  8. using namespace opentelemetry::sdk::common;
  9. // MockMetricExporter
  10. ExportResult MockMetricExporter::Export(const ResourceMetrics & /*resource_metrics*/) noexcept
  11. {
  12. return ExportResult::kSuccess;
  13. }
  14. AggregationTemporality MockMetricExporter::GetAggregationTemporality(
  15. InstrumentType /*instrument_type*/) const noexcept
  16. {
  17. return AggregationTemporality::kCumulative;
  18. }
  19. bool MockMetricExporter::ForceFlush(std::chrono::microseconds /* timeout */) noexcept
  20. {
  21. return true;
  22. }
  23. bool MockMetricExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept
  24. {
  25. return true;
  26. }
  27. // MockMetricReader
  28. MockMetricReader::MockMetricReader(std::unique_ptr<PushMetricExporter> exporter)
  29. : exporter_(std::move(exporter))
  30. {}
  31. MockMetricReader::MockMetricReader() : exporter_{new MockMetricExporter()} {}
  32. AggregationTemporality MockMetricReader::GetAggregationTemporality(
  33. InstrumentType instrument_type) const noexcept
  34. {
  35. return exporter_->GetAggregationTemporality(instrument_type);
  36. }
  37. bool MockMetricReader::OnForceFlush(std::chrono::microseconds /* timeout */) noexcept
  38. {
  39. return true;
  40. }
  41. bool MockMetricReader::OnShutDown(std::chrono::microseconds /* timeout */) noexcept
  42. {
  43. return true;
  44. }
  45. void MockMetricReader::OnInitialized() noexcept {}
  46. // MockCollectorHandle
  47. MockCollectorHandle::MockCollectorHandle(AggregationTemporality temp) : temporality_(temp) {}
  48. AggregationTemporality MockCollectorHandle::GetAggregationTemporality(
  49. InstrumentType /* instrument_type */) noexcept
  50. {
  51. return temporality_;
  52. }