From 43588e8ee18894084b86d465d58328a98040a925 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Tue, 20 Apr 2021 18:13:10 -0700 Subject: [PATCH 1/7] Get rid of obsolete core namespace --- CHANGELOG.md | 2 + .../{core => common}/timestamp.h | 76 +++++++++++++++++-- api/include/opentelemetry/logs/logger.h | 8 +- api/include/opentelemetry/logs/noop.h | 4 +- api/include/opentelemetry/plugin/tracer.h | 4 +- .../opentelemetry/trace/default_span.h | 4 +- api/include/opentelemetry/trace/noop.h | 4 +- api/include/opentelemetry/trace/span.h | 16 ++-- api/test/core/timestamp_test.cc | 6 +- api/test/logs/logger_test.cc | 4 +- api/test/trace/noop_test.cc | 4 +- examples/plugin/plugin/tracer.cc | 5 +- examples/zpages/zpages_example.cc | 2 +- .../elasticsearch/es_log_recordable.h | 2 +- .../opentelemetry/exporters/etw/etw_tracer.h | 22 +++--- exporters/ostream/test/ostream_log_test.cc | 4 +- exporters/ostream/test/ostream_span_test.cc | 6 +- .../opentelemetry/exporters/otlp/recordable.h | 4 +- exporters/otlp/src/recordable.cc | 4 +- .../otlp/test/otlp_exporter_benchmark.cc | 4 +- exporters/otlp/test/recordable_test.cc | 6 +- .../exporters/zipkin/recordable.h | 4 +- exporters/zipkin/src/recordable.cc | 4 +- .../zipkin/test/zipkin_recordable_test.cc | 10 +-- .../ext/zpages/threadsafe_span_data.h | 10 +-- ext/test/zpages/threadsafe_span_data_test.cc | 2 +- .../zpages/tracez_data_aggregator_test.cc | 2 +- .../opentelemetry/sdk/logs/log_record.h | 6 +- sdk/include/opentelemetry/sdk/logs/logger.h | 2 +- .../opentelemetry/sdk/logs/recordable.h | 4 +- .../sdk/metrics/aggregator/aggregator.h | 4 +- .../sdk/metrics/aggregator/gauge_aggregator.h | 18 ++--- .../opentelemetry/sdk/trace/recordable.h | 10 +-- .../opentelemetry/sdk/trace/span_data.h | 16 ++-- sdk/src/logs/logger.cc | 2 +- sdk/src/trace/span.cc | 8 +- sdk/src/trace/span.h | 6 +- sdk/test/logs/log_record_test.cc | 2 +- sdk/test/trace/span_data_test.cc | 2 +- sdk/test/trace/tracer_test.cc | 4 +- 40 files changed, 186 insertions(+), 121 deletions(-) rename api/include/opentelemetry/{core => common}/timestamp.h (55%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8efe92df8b..1c72d480b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ Increment the: ## [Unreleased] +* [API] Move class from opentelemetry::core namespace to opentelemetry::common namespace ([#686](https://github.com/open-telemetry/opentelemetry-cpp/pull/686)) + ## [0.4.0] 2021-04-12 * [EXPORTER] ETW Exporter enhancements ([#519](https://github.com/open-telemetry/opentelemetry-cpp/pull/519)) diff --git a/api/include/opentelemetry/core/timestamp.h b/api/include/opentelemetry/common/timestamp.h similarity index 55% rename from api/include/opentelemetry/core/timestamp.h rename to api/include/opentelemetry/common/timestamp.h index c76edd76f4..b08d955407 100644 --- a/api/include/opentelemetry/core/timestamp.h +++ b/api/include/opentelemetry/common/timestamp.h @@ -7,26 +7,46 @@ #include "opentelemetry/version.h" OPENTELEMETRY_BEGIN_NAMESPACE -namespace core +namespace common { /** - * Represents a timepoint relative to the system clock epoch + * @brief A timepoint relative to the system clock epoch. + * + * This is used for marking the beginning and end of an operation. */ class SystemTimestamp { public: + /** + * @brief Initializes a system timestamp pointing to the start of the epoch. + */ SystemTimestamp() noexcept : nanos_since_epoch_{0} {} + /** + * @brief Initializes a system timestamp from a duration. + * + * @param time_since_epoch Time elapsed since the beginning of the epoch. + */ template explicit SystemTimestamp(const std::chrono::duration &time_since_epoch) noexcept : nanos_since_epoch_{static_cast( std::chrono::duration_cast(time_since_epoch).count())} {} + /** + * @brief Initializes a system timestamp based on a point in time. + * + * @param time_point A point in time. + */ /*implicit*/ SystemTimestamp(const std::chrono::system_clock::time_point &time_point) noexcept : SystemTimestamp{time_point.time_since_epoch()} {} + /** + * @brief Returns a time point for the time stamp. + * + * @return A time point corresponding to the time stamp. + */ operator std::chrono::system_clock::time_point() const noexcept { return std::chrono::system_clock::time_point{ @@ -35,18 +55,30 @@ class SystemTimestamp } /** - * @return the amount of time that has passed since the system clock epoch + * @brief Returns the nanoseconds since the beginning of the epoch. + * + * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. */ std::chrono::nanoseconds time_since_epoch() const noexcept { return std::chrono::nanoseconds{nanos_since_epoch_}; } + /** + * @brief Compare two steady time stamps. + * + * @return true if the two time stamps are equal. + */ bool operator==(const SystemTimestamp &other) const noexcept { return nanos_since_epoch_ == other.nanos_since_epoch_; } + /** + * @brief Compare two steady time stamps for inequality. + * + * @return true if the two time stamps are not equal. + */ bool operator!=(const SystemTimestamp &other) const noexcept { return nanos_since_epoch_ != other.nanos_since_epoch_; @@ -57,23 +89,43 @@ class SystemTimestamp }; /** - * Represents a timepoint relative to the monotonic clock epoch + * @brief A timepoint relative to the monotonic clock epoch + * + * This is used for calculating the duration of an operation. */ class SteadyTimestamp { public: + /** + * @brief Initializes a monotonic timestamp pointing to the start of the epoch. + */ SteadyTimestamp() noexcept : nanos_since_epoch_{0} {} + /** + * @brief Initializes a monotonic timestamp from a duration. + * + * @param time_since_epoch Time elapsed since the beginning of the epoch. + */ template explicit SteadyTimestamp(const std::chrono::duration &time_since_epoch) noexcept : nanos_since_epoch_{static_cast( std::chrono::duration_cast(time_since_epoch).count())} {} + /** + * @brief Initializes a monotonic timestamp based on a point in time. + * + * @param time_point A point in time. + */ /*implicit*/ SteadyTimestamp(const std::chrono::steady_clock::time_point &time_point) noexcept : SteadyTimestamp{time_point.time_since_epoch()} {} + /** + * @brief Returns a time point for the time stamp. + * + * @return A time point corresponding to the time stamp. + */ operator std::chrono::steady_clock::time_point() const noexcept { return std::chrono::steady_clock::time_point{ @@ -82,18 +134,30 @@ class SteadyTimestamp } /** - * @return the amount of time that has passed since the monotonic clock epoch + * @brief Returns the nanoseconds since the beginning of the epoch. + * + * @return Elapsed nanoseconds since the beginning of the epoch for this timestamp. */ std::chrono::nanoseconds time_since_epoch() const noexcept { return std::chrono::nanoseconds{nanos_since_epoch_}; } + /** + * @brief Compare two steady time stamps. + * + * @return true if the two time stamps are equal. + */ bool operator==(const SteadyTimestamp &other) const noexcept { return nanos_since_epoch_ == other.nanos_since_epoch_; } + /** + * @brief Compare two steady time stamps for inequality. + * + * @return true if the two time stamps are not equal. + */ bool operator!=(const SteadyTimestamp &other) const noexcept { return nanos_since_epoch_ != other.nanos_since_epoch_; @@ -102,5 +166,5 @@ class SteadyTimestamp private: int64_t nanos_since_epoch_; }; -} // namespace core +} // namespace common OPENTELEMETRY_END_NAMESPACE diff --git a/api/include/opentelemetry/logs/logger.h b/api/include/opentelemetry/logs/logger.h index 53aa6e872d..b436d96ec5 100644 --- a/api/include/opentelemetry/logs/logger.h +++ b/api/include/opentelemetry/logs/logger.h @@ -23,7 +23,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/logs/severity.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" @@ -80,7 +80,7 @@ class Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept = 0; + common::SystemTimestamp timestamp) noexcept = 0; /*** Overloaded methods for KeyValueIterables ***/ /** @@ -101,7 +101,7 @@ class Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept + common::SystemTimestamp timestamp) noexcept { Log(severity, name, body, common::KeyValueIterableView(resource), common::KeyValueIterableView(attributes), trace_id, span_id, trace_flags, timestamp); @@ -115,7 +115,7 @@ class Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept + common::SystemTimestamp timestamp) noexcept { return this->Log(severity, name, body, nostd::span>{ diff --git a/api/include/opentelemetry/logs/noop.h b/api/include/opentelemetry/logs/noop.h index 86738692c1..a49dbe8f88 100644 --- a/api/include/opentelemetry/logs/noop.h +++ b/api/include/opentelemetry/logs/noop.h @@ -25,7 +25,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" #include "opentelemetry/context/runtime_context.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/severity.h" @@ -60,7 +60,7 @@ class NoopLogger final : public Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept override + common::SystemTimestamp timestamp) noexcept override {} }; diff --git a/api/include/opentelemetry/plugin/tracer.h b/api/include/opentelemetry/plugin/tracer.h index d782d7d187..8e1dec632f 100644 --- a/api/include/opentelemetry/plugin/tracer.h +++ b/api/include/opentelemetry/plugin/tracer.h @@ -26,13 +26,13 @@ class Span final : public trace::Span void AddEvent(nostd::string_view name) noexcept override { span_->AddEvent(name); } - void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override + void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept override { span_->AddEvent(name, timestamp); } void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept override { span_->AddEvent(name, timestamp, attributes); diff --git a/api/include/opentelemetry/trace/default_span.h b/api/include/opentelemetry/trace/default_span.h index 9eabba6d04..6051a72e58 100644 --- a/api/include/opentelemetry/trace/default_span.h +++ b/api/include/opentelemetry/trace/default_span.h @@ -23,10 +23,10 @@ class DefaultSpan : public Span void AddEvent(nostd::string_view /* name */) noexcept {} - void AddEvent(nostd::string_view /* name */, core::SystemTimestamp /* timestamp */) noexcept {} + void AddEvent(nostd::string_view /* name */, common::SystemTimestamp /* timestamp */) noexcept {} void AddEvent(nostd::string_view /* name */, - core::SystemTimestamp /* timestamp */, + common::SystemTimestamp /* timestamp */, const common::KeyValueIterable & /* attributes */) noexcept {} diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 3255b40adc..8c62b404ed 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -35,11 +35,11 @@ class NoopSpan final : public Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, core::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/, - core::SystemTimestamp /*timestamp*/, + common::SystemTimestamp /*timestamp*/, const common::KeyValueIterable & /*attributes*/) noexcept override {} diff --git a/api/include/opentelemetry/trace/span.h b/api/include/opentelemetry/trace/span.h index 7b020b1c6d..b9f1326853 100644 --- a/api/include/opentelemetry/trace/span.h +++ b/api/include/opentelemetry/trace/span.h @@ -4,7 +4,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable_view.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/shared_ptr.h" #include "opentelemetry/nostd/span.h" #include "opentelemetry/nostd/string_view.h" @@ -54,8 +54,8 @@ struct StartSpanOptions // Span's duration, while timestamps from the system clock can be used to most // accurately place a Span's // time point relative to other Spans collected across a distributed system. - core::SystemTimestamp start_system_time; - core::SteadyTimestamp start_steady_time; + common::SystemTimestamp start_system_time; + common::SteadyTimestamp start_steady_time; // Explicitly set the parent of a Span. // @@ -75,7 +75,7 @@ struct StartSpanOptions struct EndSpanOptions { // Optionally sets the end time of a Span. - core::SteadyTimestamp end_steady_time; + common::SteadyTimestamp end_steady_time; }; class Tracer; @@ -109,11 +109,11 @@ class Span virtual void AddEvent(nostd::string_view name) noexcept = 0; // Adds an event to the Span, with a custom timestamp. - virtual void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept = 0; + virtual void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept = 0; // Adds an event to the Span, with a custom timestamp, and attributes. virtual void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept = 0; virtual void AddEvent(nostd::string_view name, @@ -125,7 +125,7 @@ class Span template ::value> * = nullptr> void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const T &attributes) noexcept { this->AddEvent(name, timestamp, common::KeyValueIterableView{attributes}); @@ -139,7 +139,7 @@ class Span } void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, std::initializer_list> attributes) noexcept { diff --git a/api/test/core/timestamp_test.cc b/api/test/core/timestamp_test.cc index 7ea4484321..bd73d4b7bd 100644 --- a/api/test/core/timestamp_test.cc +++ b/api/test/core/timestamp_test.cc @@ -1,9 +1,9 @@ -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include -using opentelemetry::core::SteadyTimestamp; -using opentelemetry::core::SystemTimestamp; +using opentelemetry::common::SteadyTimestamp; +using opentelemetry::common::SystemTimestamp; template static bool AreNearlyEqual(const Timestamp &t1, const Timestamp &t2) noexcept diff --git a/api/test/logs/logger_test.cc b/api/test/logs/logger_test.cc index de03c8d403..b6c1e9edb4 100644 --- a/api/test/logs/logger_test.cc +++ b/api/test/logs/logger_test.cc @@ -1,7 +1,7 @@ #include #include -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/provider.h" #include "opentelemetry/nostd/shared_ptr.h" @@ -77,7 +77,7 @@ class TestLogger : public Logger opentelemetry::trace::TraceId trace_id, opentelemetry::trace::SpanId span_id, opentelemetry::trace::TraceFlags trace_flags, - opentelemetry::core::SystemTimestamp timestamp) noexcept override + opentelemetry::common::SystemTimestamp timestamp) noexcept override {} }; diff --git a/api/test/trace/noop_test.cc b/api/test/trace/noop_test.cc index 5d84f408e0..2b2864af1a 100644 --- a/api/test/trace/noop_test.cc +++ b/api/test/trace/noop_test.cc @@ -1,5 +1,5 @@ #include "opentelemetry/trace/noop.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include #include @@ -7,7 +7,7 @@ #include -using opentelemetry::core::SystemTimestamp; +using opentelemetry::common::SystemTimestamp; using opentelemetry::trace::NoopTracer; using opentelemetry::trace::SpanContext; using opentelemetry::trace::Tracer; diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 49170fd4a4..ce6676bd93 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -6,7 +6,6 @@ namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; -namespace core = opentelemetry::core; namespace trace = opentelemetry::trace; namespace context = opentelemetry::context; @@ -34,11 +33,11 @@ class Span final : public trace::Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, core::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/, - core::SystemTimestamp /*timestamp*/, + common::SystemTimestamp /*timestamp*/, const common::KeyValueIterable & /*attributes*/) noexcept override {} diff --git a/examples/zpages/zpages_example.cc b/examples/zpages/zpages_example.cc index 958b28132c..43fb9cd806 100644 --- a/examples/zpages/zpages_example.cc +++ b/examples/zpages/zpages_example.cc @@ -8,7 +8,7 @@ #include "opentelemetry/ext/zpages/zpages.h" // Required file include for zpages -using opentelemetry::core::SteadyTimestamp; +using opentelemetry::common::SteadyTimestamp; int main(int argc, char *argv[]) { diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h index 09225b9dbd..aa4836335e 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_recordable.h @@ -158,7 +158,7 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable * Set the timestamp for this log. * @param timestamp the timestamp of the event */ - void SetTimestamp(core::SystemTimestamp timestamp) noexcept override + void SetTimestamp(common::SystemTimestamp timestamp) noexcept override { json_["timestamp"] = timestamp.time_since_epoch().count(); } diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index d0cdb2c4a5..8c55d3bf3e 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -160,7 +160,7 @@ std::string GetName(T &t) * @return Span Start timestamp */ template -core::SystemTimestamp GetStartTime(T &t) +common::SystemTimestamp GetStartTime(T &t) { return t.GetStartTime(); } @@ -172,7 +172,7 @@ core::SystemTimestamp GetStartTime(T &t) * @return Span Stop timestamp */ template -core::SystemTimestamp GetEndTime(T &t) +common::SystemTimestamp GetEndTime(T &t) { return t.GetEndTime(); } @@ -625,7 +625,7 @@ class Tracer : public trace::Tracer */ void AddEvent(trace::Span &span, nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept { #ifdef RTTI_ENABLED @@ -652,7 +652,7 @@ class Tracer : public trace::Tracer */ void AddEvent(trace::Span &span, nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, Properties &evt) noexcept { // TODO: respect originating timestamp. Do we need to reserve @@ -700,7 +700,7 @@ class Tracer : public trace::Tracer */ void AddEvent(trace::Span &span, nostd::string_view name, - core::SystemTimestamp timestamp) noexcept + common::SystemTimestamp timestamp) noexcept { AddEvent(span, name, timestamp, sdk::GetEmptyAttributes()); }; @@ -734,8 +734,8 @@ class Span : public trace::Span */ Properties attributes_; - core::SystemTimestamp start_time_; - core::SystemTimestamp end_time_; + common::SystemTimestamp start_time_; + common::SystemTimestamp end_time_; /** * @brief Owner Tracer of this Span @@ -796,13 +796,13 @@ class Span : public trace::Span * @brief Get start time of this Span. * @return */ - core::SystemTimestamp GetStartTime() { return start_time_; } + common::SystemTimestamp GetStartTime() { return start_time_; } /** * @brief Get end time of this Span. * @return */ - core::SystemTimestamp GetEndTime() { return end_time_; } + common::SystemTimestamp GetEndTime() { return end_time_; } /** * @brief Get Span Name. @@ -850,7 +850,7 @@ class Span : public trace::Span * @param timestamp * @return */ - void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override + void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept override { owner_.AddEvent(*this, name, timestamp); } @@ -863,7 +863,7 @@ class Span : public trace::Span * @return */ void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept override { owner_.AddEvent(*this, name, timestamp, attributes); diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index d6342f6128..59a06ef4f9 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -97,7 +97,7 @@ TEST(OStreamLogExporter, SimpleLogToCout) // Pass a default recordable created by the exporter to be exported // Create a log record and manually timestamp, severity, name, message - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); auto record = std::unique_ptr(new sdklogs::LogRecord()); record->SetTimestamp(now); @@ -252,7 +252,7 @@ TEST(OStreamLogExporter, IntegrationTest) std::cout.rdbuf(stdcoutOutput.rdbuf()); // Write a log to ostream exporter - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); logger->Log(opentelemetry::logs::Severity::kDebug, "", "Hello", {}, {}, {}, {}, {}, now); // Restore cout's original streambuf diff --git a/exporters/ostream/test/ostream_span_test.cc b/exporters/ostream/test/ostream_span_test.cc index c955544f5c..1a53f2c9e2 100644 --- a/exporters/ostream/test/ostream_span_test.cc +++ b/exporters/ostream/test/ostream_span_test.cc @@ -100,7 +100,7 @@ TEST(OStreamSpanExporter, PrintSpanWithBasicFields) recordable->SetIdentity(span_context, parent_span_id); recordable->SetName("Test Span"); - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); recordable->SetStartTime(now); recordable->SetDuration(std::chrono::nanoseconds(100)); recordable->SetStatus(opentelemetry::trace::StatusCode::kOk, "Test Description"); @@ -210,8 +210,8 @@ TEST(OStreamSpanExporter, PrintSpanWithEvents) new sdktrace::SimpleSpanProcessor(std::move(exporter))); auto recordable = processor->MakeRecordable(); - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); - opentelemetry::core::SystemTimestamp next(std::chrono::system_clock::now() + + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp next(std::chrono::system_clock::now() + std::chrono::seconds(1)); std::string now_str = std::to_string(now.time_since_epoch().count()); diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h b/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h index b4d7fae38d..1f2d0391a9 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/recordable.h @@ -26,7 +26,7 @@ class Recordable final : public sdk::trace::Recordable const opentelemetry::common::AttributeValue &value) noexcept override; void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept override; void AddLink(const opentelemetry::trace::SpanContext &span_context, @@ -38,7 +38,7 @@ class Recordable final : public sdk::trace::Recordable void SetSpanKind(opentelemetry::trace::SpanKind span_kind) noexcept override; - void SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept override; + void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept override; void SetDuration(std::chrono::nanoseconds duration) noexcept override; diff --git a/exporters/otlp/src/recordable.cc b/exporters/otlp/src/recordable.cc index b236ef125e..3e1c2443de 100644 --- a/exporters/otlp/src/recordable.cc +++ b/exporters/otlp/src/recordable.cc @@ -131,7 +131,7 @@ void Recordable::SetAttribute(nostd::string_view key, } void Recordable::AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept { auto *event = span_.add_events(); @@ -213,7 +213,7 @@ void Recordable::SetSpanKind(opentelemetry::trace::SpanKind span_kind) noexcept span_.set_kind(proto_span_kind); } -void Recordable::SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept +void Recordable::SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept { span_.set_start_time_unix_nano(start_time.time_since_epoch().count()); } diff --git a/exporters/otlp/test/otlp_exporter_benchmark.cc b/exporters/otlp/test/otlp_exporter_benchmark.cc index a72c1f5df5..76ae3871cc 100644 --- a/exporters/otlp/test/otlp_exporter_benchmark.cc +++ b/exporters/otlp/test/otlp_exporter_benchmark.cc @@ -87,7 +87,7 @@ void CreateSparseSpans(std::array, kBatc recordable->SetIdentity(kSpanContext, kParentSpanId); recordable->SetName("TestSpan"); - recordable->SetStartTime(core::SystemTimestamp(std::chrono::system_clock::now())); + recordable->SetStartTime(common::SystemTimestamp(std::chrono::system_clock::now())); recordable->SetDuration(std::chrono::nanoseconds(10)); recordables[i] = std::move(recordable); @@ -103,7 +103,7 @@ void CreateDenseSpans(std::array, kBatch recordable->SetIdentity(kSpanContext, kParentSpanId); recordable->SetName("TestSpan"); - recordable->SetStartTime(core::SystemTimestamp(std::chrono::system_clock::now())); + recordable->SetStartTime(common::SystemTimestamp(std::chrono::system_clock::now())); recordable->SetDuration(std::chrono::nanoseconds(10)); for (int i = 0; i < kNumAttributes; i++) diff --git a/exporters/otlp/test/recordable_test.cc b/exporters/otlp/test/recordable_test.cc index 007c7359e2..5ea4e03031 100644 --- a/exporters/otlp/test/recordable_test.cc +++ b/exporters/otlp/test/recordable_test.cc @@ -54,7 +54,7 @@ TEST(Recordable, SetStartTime) { Recordable rec; std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now(); - core::SystemTimestamp start_timestamp(start_time); + common::SystemTimestamp start_timestamp(start_time); uint64_t unix_start = std::chrono::duration_cast(start_time.time_since_epoch()).count(); @@ -67,7 +67,7 @@ TEST(Recordable, SetDuration) { Recordable rec; // Start time is 0 - core::SystemTimestamp start_timestamp; + common::SystemTimestamp start_timestamp; std::chrono::nanoseconds duration(10); uint64_t unix_end = duration.count(); @@ -95,7 +95,7 @@ TEST(Recordable, AddEventDefault) nostd::string_view name = "Test Event"; std::chrono::system_clock::time_point event_time = std::chrono::system_clock::now(); - core::SystemTimestamp event_timestamp(event_time); + common::SystemTimestamp event_timestamp(event_time); rec.sdk::trace::Recordable::AddEvent(name, event_timestamp); diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h index f72dc4414f..3e4fbfa715 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/recordable.h @@ -45,7 +45,7 @@ class Recordable final : public sdk::trace::Recordable const opentelemetry::common::AttributeValue &value) noexcept override; void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept override; void AddLink(const opentelemetry::trace::SpanContext &span_context, @@ -55,7 +55,7 @@ class Recordable final : public sdk::trace::Recordable void SetName(nostd::string_view name) noexcept override; - void SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept override; + void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept override; virtual void SetSpanKind(opentelemetry::trace::SpanKind span_kind) noexcept override; diff --git a/exporters/zipkin/src/recordable.cc b/exporters/zipkin/src/recordable.cc index 14d9c1fafc..ae2e450012 100644 --- a/exporters/zipkin/src/recordable.cc +++ b/exporters/zipkin/src/recordable.cc @@ -159,7 +159,7 @@ void Recordable::SetAttribute(nostd::string_view key, } void Recordable::AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const common::KeyValueIterable &attributes) noexcept { nlohmann::json attrs = nlohmann::json::object(); // empty object @@ -204,7 +204,7 @@ void Recordable::SetName(nostd::string_view name) noexcept span_["name"] = name.data(); } -void Recordable::SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept +void Recordable::SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept { span_["timestamp"] = std::chrono::duration_cast(start_time.time_since_epoch()).count(); diff --git a/exporters/zipkin/test/zipkin_recordable_test.cc b/exporters/zipkin/test/zipkin_recordable_test.cc index 0e8a132c1d..de124fd15f 100644 --- a/exporters/zipkin/test/zipkin_recordable_test.cc +++ b/exporters/zipkin/test/zipkin_recordable_test.cc @@ -22,7 +22,7 @@ #include "opentelemetry/sdk/trace/exporter.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/exporters/zipkin/recordable.h" #include @@ -71,7 +71,7 @@ TEST(ZipkinSpanRecordable, SetStartTime) { opentelemetry::exporter::zipkin::Recordable rec; std::chrono::system_clock::time_point start_time = std::chrono::system_clock::now(); - opentelemetry::core::SystemTimestamp start_timestamp(start_time); + opentelemetry::common::SystemTimestamp start_timestamp(start_time); uint64_t unix_start = std::chrono::duration_cast(start_time.time_since_epoch()).count(); @@ -85,7 +85,7 @@ TEST(ZipkinSpanRecordable, SetDuration) json j_span = {{"duration", 10}, {"timestamp", 0}}; opentelemetry::exporter::zipkin::Recordable rec; // Start time is 0 - opentelemetry::core::SystemTimestamp start_timestamp; + opentelemetry::common::SystemTimestamp start_timestamp; std::chrono::nanoseconds duration(10); uint64_t unix_end = duration.count(); @@ -120,7 +120,7 @@ TEST(ZipkinSpanRecordable, AddEventDefault) nostd::string_view name = "Test Event"; std::chrono::system_clock::time_point event_time = std::chrono::system_clock::now(); - opentelemetry::core::SystemTimestamp event_timestamp(event_time); + opentelemetry::common::SystemTimestamp event_timestamp(event_time); rec.opentelemetry::sdk::trace::Recordable::AddEvent(name, event_timestamp); @@ -139,7 +139,7 @@ TEST(ZipkinSpanRecordable, AddEventWithAttributes) nostd::string_view name = "Test Event"; std::chrono::system_clock::time_point event_time = std::chrono::system_clock::now(); - opentelemetry::core::SystemTimestamp event_timestamp(event_time); + opentelemetry::common::SystemTimestamp event_timestamp(event_time); uint64_t unix_event_time = std::chrono::duration_cast(event_time.time_since_epoch()).count(); diff --git a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h index 0d3b0488a1..c2b092bb1e 100644 --- a/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h +++ b/ext/include/opentelemetry/ext/zpages/threadsafe_span_data.h @@ -5,7 +5,7 @@ #include #include -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/trace/recordable.h" #include "opentelemetry/sdk/trace/span_data.h" @@ -100,7 +100,7 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable * Get the start time for this span * @return the start time for this span */ - opentelemetry::core::SystemTimestamp GetStartTime() const noexcept + opentelemetry::common::SystemTimestamp GetStartTime() const noexcept { std::lock_guard lock(mutex_); return start_time_; @@ -160,7 +160,7 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable span_kind_ = span_kind; } - void SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept override + void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept override { std::lock_guard lock(mutex_); start_time_ = start_time; @@ -184,7 +184,7 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable void AddEvent( nostd::string_view name, - core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()), + common::SystemTimestamp timestamp = common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = opentelemetry::common::KeyValueIterableView>( {})) noexcept override @@ -218,7 +218,7 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable mutable std::mutex mutex_; opentelemetry::trace::SpanContext span_context_{false, false}; opentelemetry::trace::SpanId parent_span_id_; - core::SystemTimestamp start_time_; + common::SystemTimestamp start_time_; std::chrono::nanoseconds duration_{0}; std::string name_; opentelemetry::trace::SpanKind span_kind_; diff --git a/ext/test/zpages/threadsafe_span_data_test.cc b/ext/test/zpages/threadsafe_span_data_test.cc index ed9509017b..73feaf137c 100644 --- a/ext/test/zpages/threadsafe_span_data_test.cc +++ b/ext/test/zpages/threadsafe_span_data_test.cc @@ -41,7 +41,7 @@ TEST(ThreadsafeSpanData, Set) trace_id, span_id, opentelemetry::trace::TraceFlags{opentelemetry::trace::TraceFlags::kIsSampled}, true, trace_state}; - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); ThreadsafeSpanData data; data.SetIdentity(span_context, parent_span_id); diff --git a/ext/test/zpages/tracez_data_aggregator_test.cc b/ext/test/zpages/tracez_data_aggregator_test.cc index 324cf0c612..f6f5ba6d9f 100644 --- a/ext/test/zpages/tracez_data_aggregator_test.cc +++ b/ext/test/zpages/tracez_data_aggregator_test.cc @@ -11,7 +11,7 @@ using namespace opentelemetry::sdk::trace; using namespace opentelemetry::ext::zpages; namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; -using opentelemetry::core::SteadyTimestamp; +using opentelemetry::common::SteadyTimestamp; using opentelemetry::v0::trace::Span; const std::string span_name1 = "span 1"; diff --git a/sdk/include/opentelemetry/sdk/logs/log_record.h b/sdk/include/opentelemetry/sdk/logs/log_record.h index 65030c8a57..2db0cda847 100644 --- a/sdk/include/opentelemetry/sdk/logs/log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/log_record.h @@ -47,7 +47,7 @@ class LogRecord final : public Recordable opentelemetry::trace::TraceId trace_id_; opentelemetry::trace::SpanId span_id_; opentelemetry::trace::TraceFlags trace_flags_; - core::SystemTimestamp timestamp_; // uint64 nanoseconds since Unix epoch + common::SystemTimestamp timestamp_; // uint64 nanoseconds since Unix epoch public: /********** Setters for each field (overrides methods from the Recordable interface) ************/ @@ -127,7 +127,7 @@ class LogRecord final : public Recordable * Set the timestamp for this log. * @param timestamp the timestamp of the event */ - void SetTimestamp(core::SystemTimestamp timestamp) noexcept override { timestamp_ = timestamp; } + void SetTimestamp(common::SystemTimestamp timestamp) noexcept override { timestamp_ = timestamp; } /************************** Getters for each field ****************************/ @@ -189,7 +189,7 @@ class LogRecord final : public Recordable * Get the timestamp for this log * @return the timestamp for this log */ - core::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } + common::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } }; } // namespace logs } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index 3b2c34fcb6..e4f3ef0398 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -67,7 +67,7 @@ class Logger final : public opentelemetry::logs::Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept override; + common::SystemTimestamp timestamp) noexcept override; private: // The name of this logger diff --git a/sdk/include/opentelemetry/sdk/logs/recordable.h b/sdk/include/opentelemetry/sdk/logs/recordable.h index 45ad3eaf59..5eb004e2d6 100644 --- a/sdk/include/opentelemetry/sdk/logs/recordable.h +++ b/sdk/include/opentelemetry/sdk/logs/recordable.h @@ -2,7 +2,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/logs/severity.h" #include "opentelemetry/trace/span.h" #include "opentelemetry/trace/span_context.h" @@ -32,7 +32,7 @@ class Recordable * Set the timestamp for this log. * @param timestamp the timestamp to set */ - virtual void SetTimestamp(core::SystemTimestamp timestamp) noexcept = 0; + virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0; /** * Set the severity for this log. diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h index f90f1d7b5a..ebf11e9599 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h @@ -2,7 +2,7 @@ #include #include -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/metrics/instrument.h" #include "opentelemetry/version.h" @@ -124,7 +124,7 @@ class Aggregator virtual size_t get_max_buckets() { return 0; } // virtual function to be overridden for Gauge Aggregator - virtual core::SystemTimestamp get_checkpoint_timestamp() { return core::SystemTimestamp(); } + virtual common::SystemTimestamp get_checkpoint_timestamp() { return common::SystemTimestamp(); } // Custom copy constructor to handle the mutex Aggregator(const Aggregator &cp) diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h index 5046928bac..831e25b2ec 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h @@ -1,6 +1,6 @@ #pragma once -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/metrics/instrument.h" #include "opentelemetry/sdk/metrics/aggregator/aggregator.h" #include "opentelemetry/version.h" @@ -36,7 +36,7 @@ class GaugeAggregator : public Aggregator this->values_ = std::vector(1, 0); this->checkpoint_ = this->values_; this->agg_kind_ = AggregatorKind::Gauge; - current_timestamp_ = core::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); } ~GaugeAggregator() = default; @@ -61,7 +61,7 @@ class GaugeAggregator : public Aggregator this->mu_.lock(); this->updated_ = true; this->values_[0] = val; - current_timestamp_ = core::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } @@ -82,7 +82,7 @@ class GaugeAggregator : public Aggregator // Reset the values to default this->values_[0] = 0; checkpoint_timestamp_ = current_timestamp_; - current_timestamp_ = core::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } @@ -101,7 +101,7 @@ class GaugeAggregator : public Aggregator this->values_[0] = other.values_[0]; // Now merge checkpoints this->checkpoint_[0] = other.checkpoint_[0]; - current_timestamp_ = core::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } else @@ -119,7 +119,7 @@ class GaugeAggregator : public Aggregator /** * @return the latest checkpointed timestamp */ - core::SystemTimestamp get_checkpoint_timestamp() override { return checkpoint_timestamp_; } + common::SystemTimestamp get_checkpoint_timestamp() override { return checkpoint_timestamp_; } /** * @return the values_ vector stored in this aggregator @@ -129,11 +129,11 @@ class GaugeAggregator : public Aggregator /** * @return the timestamp of when the last value recorded */ - core::SystemTimestamp get_timestamp() { return current_timestamp_; } + common::SystemTimestamp get_timestamp() { return current_timestamp_; } private: - core::SystemTimestamp current_timestamp_; - core::SystemTimestamp checkpoint_timestamp_; + common::SystemTimestamp current_timestamp_; + common::SystemTimestamp checkpoint_timestamp_; }; } // namespace metrics } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/trace/recordable.h b/sdk/include/opentelemetry/sdk/trace/recordable.h index ef5678d921..022a6a8c95 100644 --- a/sdk/include/opentelemetry/sdk/trace/recordable.h +++ b/sdk/include/opentelemetry/sdk/trace/recordable.h @@ -2,7 +2,7 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/empty_attributes.h" #include "opentelemetry/trace/canonical_code.h" @@ -54,7 +54,7 @@ class Recordable * @param attributes the attributes associated with the event */ virtual void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; /** @@ -63,7 +63,7 @@ class Recordable */ void AddEvent(nostd::string_view name) { - AddEvent(name, core::SystemTimestamp(std::chrono::system_clock::now()), + AddEvent(name, common::SystemTimestamp(std::chrono::system_clock::now()), opentelemetry::sdk::GetEmptyAttributes()); } @@ -72,7 +72,7 @@ class Recordable * @param name the name of the event * @param timestamp the timestamp of the event */ - void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) + void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) { AddEvent(name, timestamp, opentelemetry::sdk::GetEmptyAttributes()); } @@ -118,7 +118,7 @@ class Recordable * Set the start time of the span. * @param start_time the start time to set */ - virtual void SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept = 0; + virtual void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept = 0; /** * Set the duration of the span. diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 6eca905583..0c5dcc2f05 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -4,7 +4,7 @@ #include #include #include "opentelemetry/common/attribute_value.h" -#include "opentelemetry/core/timestamp.h" +#include "opentelemetry/common/timestamp.h" #include "opentelemetry/nostd/string_view.h" #include "opentelemetry/sdk/common/attribute_utils.h" #include "opentelemetry/sdk/trace/recordable.h" @@ -27,7 +27,7 @@ class SpanDataEvent { public: SpanDataEvent(std::string name, - core::SystemTimestamp timestamp, + opentelemetry::common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) : name_(name), timestamp_(timestamp), attribute_map_(attributes) {} @@ -42,7 +42,7 @@ class SpanDataEvent * Get the timestamp for this event * @return the timestamp for this event */ - core::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } + opentelemetry::common::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } /** * Get the attributes for this event @@ -55,7 +55,7 @@ class SpanDataEvent private: std::string name_; - core::SystemTimestamp timestamp_; + opentelemetry::common::SystemTimestamp timestamp_; common::AttributeMap attribute_map_; }; @@ -148,7 +148,7 @@ class SpanData final : public Recordable * Get the start time for this span * @return the start time for this span */ - opentelemetry::core::SystemTimestamp GetStartTime() const noexcept { return start_time_; } + opentelemetry::common::SystemTimestamp GetStartTime() const noexcept { return start_time_; } /** * Get the duration for this span @@ -192,7 +192,7 @@ class SpanData final : public Recordable void AddEvent( nostd::string_view name, - core::SystemTimestamp timestamp = core::SystemTimestamp(std::chrono::system_clock::now()), + common::SystemTimestamp timestamp = common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = opentelemetry::common::KeyValueIterableView>( {})) noexcept override @@ -225,7 +225,7 @@ class SpanData final : public Recordable span_kind_ = span_kind; } - void SetStartTime(opentelemetry::core::SystemTimestamp start_time) noexcept override + void SetStartTime(opentelemetry::common::SystemTimestamp start_time) noexcept override { start_time_ = start_time; } @@ -235,7 +235,7 @@ class SpanData final : public Recordable private: opentelemetry::trace::SpanContext span_context_{false, false}; opentelemetry::trace::SpanId parent_span_id_; - core::SystemTimestamp start_time_; + common::SystemTimestamp start_time_; std::chrono::nanoseconds duration_{0}; std::string name_; opentelemetry::trace::StatusCode status_code_{opentelemetry::trace::StatusCode::kUnset}; diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 0808f5a8e1..8758a5f50b 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -45,7 +45,7 @@ void Logger::Log(opentelemetry::logs::Severity severity, opentelemetry::trace::TraceId trace_id, opentelemetry::trace::SpanId span_id, opentelemetry::trace::TraceFlags trace_flags, - core::SystemTimestamp timestamp) noexcept + common::SystemTimestamp timestamp) noexcept { // If this logger does not have a processor, no need to create a log record auto processor = logger_provider_.lock()->GetProcessor(); diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index 388d0ab923..eb0bdface0 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -11,8 +11,8 @@ namespace sdk namespace trace { -using opentelemetry::core::SteadyTimestamp; -using opentelemetry::core::SystemTimestamp; +using opentelemetry::common::SteadyTimestamp; +using opentelemetry::common::SystemTimestamp; namespace { @@ -145,7 +145,7 @@ void Span::AddEvent(nostd::string_view name) noexcept recordable_->AddEvent(name); } -void Span::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept +void Span::AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept { std::lock_guard lock_guard{mu_}; if (recordable_ == nullptr) @@ -156,7 +156,7 @@ void Span::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) no } void Span::AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept { std::lock_guard lock_guard{mu_}; diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index efc16d6c59..54368ae89a 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -33,10 +33,10 @@ class Span final : public trace_api::Span void AddEvent(nostd::string_view name) noexcept override; - void AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) noexcept override; + void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept override; void AddEvent(nostd::string_view name, - core::SystemTimestamp timestamp, + common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept override; void SetStatus(trace_api::StatusCode code, nostd::string_view description) noexcept override; @@ -53,7 +53,7 @@ class Span final : public trace_api::Span std::shared_ptr tracer_; mutable std::mutex mu_; std::unique_ptr recordable_; - opentelemetry::core::SteadyTimestamp start_steady_time; + opentelemetry::common::SteadyTimestamp start_steady_time; std::unique_ptr span_context_; bool has_ended_; }; diff --git a/sdk/test/logs/log_record_test.cc b/sdk/test/logs/log_record_test.cc index 774e726c54..fc4307223c 100644 --- a/sdk/test/logs/log_record_test.cc +++ b/sdk/test/logs/log_record_test.cc @@ -32,7 +32,7 @@ TEST(LogRecord, SetAndGet) opentelemetry::trace::TraceId trace_id; opentelemetry::trace::SpanId span_id; opentelemetry::trace::TraceFlags trace_flags; - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); // Set all fields of the LogRecord LogRecord record; diff --git a/sdk/test/trace/span_data_test.cc b/sdk/test/trace/span_data_test.cc index 0a528987df..da4a31bd8e 100644 --- a/sdk/test/trace/span_data_test.cc +++ b/sdk/test/trace/span_data_test.cc @@ -40,7 +40,7 @@ TEST(SpanData, Set) trace_id, span_id, opentelemetry::trace::TraceFlags{opentelemetry::trace::TraceFlags::kIsSampled}, true, trace_state}; - opentelemetry::core::SystemTimestamp now(std::chrono::system_clock::now()); + opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); SpanData data; data.SetIdentity(span_context, parent_span_id); diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 176a949670..fc5948e7bc 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -11,8 +11,8 @@ using namespace opentelemetry::sdk::trace; using namespace opentelemetry::sdk::resource; -using opentelemetry::core::SteadyTimestamp; -using opentelemetry::core::SystemTimestamp; +using opentelemetry::common::SteadyTimestamp; +using opentelemetry::common::SystemTimestamp; namespace nostd = opentelemetry::nostd; namespace common = opentelemetry::common; using opentelemetry::common::KeyValueIterableView; From dd13da77456b83e4d81fbfc2fe30066d3552a370 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Tue, 20 Apr 2021 18:29:41 -0700 Subject: [PATCH 2/7] Fix format issues --- api/include/opentelemetry/logs/noop.h | 2 +- api/include/opentelemetry/trace/noop.h | 3 ++- examples/plugin/plugin/tracer.cc | 3 ++- exporters/ostream/test/ostream_span_test.cc | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/api/include/opentelemetry/logs/noop.h b/api/include/opentelemetry/logs/noop.h index a49dbe8f88..0f8650f277 100644 --- a/api/include/opentelemetry/logs/noop.h +++ b/api/include/opentelemetry/logs/noop.h @@ -24,8 +24,8 @@ #include "opentelemetry/common/attribute_value.h" #include "opentelemetry/common/key_value_iterable.h" -#include "opentelemetry/context/runtime_context.h" #include "opentelemetry/common/timestamp.h" +#include "opentelemetry/context/runtime_context.h" #include "opentelemetry/logs/logger.h" #include "opentelemetry/logs/logger_provider.h" #include "opentelemetry/logs/severity.h" diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index 8c62b404ed..f4dfeb371a 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -35,7 +35,8 @@ class NoopSpan final : public Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, common::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, + common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/, diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index ce6676bd93..86882c8d8f 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -33,7 +33,8 @@ class Span final : public trace::Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, common::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, + common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/, diff --git a/exporters/ostream/test/ostream_span_test.cc b/exporters/ostream/test/ostream_span_test.cc index 1a53f2c9e2..6c7a7a1e89 100644 --- a/exporters/ostream/test/ostream_span_test.cc +++ b/exporters/ostream/test/ostream_span_test.cc @@ -212,7 +212,7 @@ TEST(OStreamSpanExporter, PrintSpanWithEvents) auto recordable = processor->MakeRecordable(); opentelemetry::common::SystemTimestamp now(std::chrono::system_clock::now()); opentelemetry::common::SystemTimestamp next(std::chrono::system_clock::now() + - std::chrono::seconds(1)); + std::chrono::seconds(1)); std::string now_str = std::to_string(now.time_since_epoch().count()); std::string next_str = std::to_string(next.time_since_epoch().count()); From 430a1cf3c5d0de7160743ef3358939ae872b6491 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Tue, 20 Apr 2021 18:32:27 -0700 Subject: [PATCH 3/7] Fix compile error --- sdk/include/opentelemetry/sdk/trace/span_data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 0c5dcc2f05..770317c89f 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -192,7 +192,7 @@ class SpanData final : public Recordable void AddEvent( nostd::string_view name, - common::SystemTimestamp timestamp = common::SystemTimestamp(std::chrono::system_clock::now()), + opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), const opentelemetry::common::KeyValueIterable &attributes = opentelemetry::common::KeyValueIterableView>( {})) noexcept override @@ -235,7 +235,7 @@ class SpanData final : public Recordable private: opentelemetry::trace::SpanContext span_context_{false, false}; opentelemetry::trace::SpanId parent_span_id_; - common::SystemTimestamp start_time_; + opentelemetry::common::SystemTimestamp start_time_; std::chrono::nanoseconds duration_{0}; std::string name_; opentelemetry::trace::StatusCode status_code_{opentelemetry::trace::StatusCode::kUnset}; From ad85667a510bd71a5fdcb19675e16dc5b616bbcf Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Tue, 20 Apr 2021 18:42:06 -0700 Subject: [PATCH 4/7] Fix compilation errors --- sdk/include/opentelemetry/sdk/logs/log_record.h | 6 +++--- sdk/include/opentelemetry/sdk/logs/logger.h | 2 +- sdk/include/opentelemetry/sdk/logs/recordable.h | 2 +- .../sdk/metrics/aggregator/aggregator.h | 2 +- .../sdk/metrics/aggregator/gauge_aggregator.h | 16 ++++++++-------- sdk/include/opentelemetry/sdk/trace/recordable.h | 6 +++--- sdk/src/logs/logger.cc | 2 +- sdk/src/trace/span.cc | 4 ++-- sdk/src/trace/span.h | 4 ++-- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sdk/include/opentelemetry/sdk/logs/log_record.h b/sdk/include/opentelemetry/sdk/logs/log_record.h index 2db0cda847..f5e837b14a 100644 --- a/sdk/include/opentelemetry/sdk/logs/log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/log_record.h @@ -47,7 +47,7 @@ class LogRecord final : public Recordable opentelemetry::trace::TraceId trace_id_; opentelemetry::trace::SpanId span_id_; opentelemetry::trace::TraceFlags trace_flags_; - common::SystemTimestamp timestamp_; // uint64 nanoseconds since Unix epoch + opentelemetry::common::SystemTimestamp timestamp_; // uint64 nanoseconds since Unix epoch public: /********** Setters for each field (overrides methods from the Recordable interface) ************/ @@ -127,7 +127,7 @@ class LogRecord final : public Recordable * Set the timestamp for this log. * @param timestamp the timestamp of the event */ - void SetTimestamp(common::SystemTimestamp timestamp) noexcept override { timestamp_ = timestamp; } + void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept override { timestamp_ = timestamp; } /************************** Getters for each field ****************************/ @@ -189,7 +189,7 @@ class LogRecord final : public Recordable * Get the timestamp for this log * @return the timestamp for this log */ - common::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } + opentelemetry::common::SystemTimestamp GetTimestamp() const noexcept { return timestamp_; } }; } // namespace logs } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/logs/logger.h b/sdk/include/opentelemetry/sdk/logs/logger.h index e4f3ef0398..5666d954d2 100644 --- a/sdk/include/opentelemetry/sdk/logs/logger.h +++ b/sdk/include/opentelemetry/sdk/logs/logger.h @@ -67,7 +67,7 @@ class Logger final : public opentelemetry::logs::Logger trace::TraceId trace_id, trace::SpanId span_id, trace::TraceFlags trace_flags, - common::SystemTimestamp timestamp) noexcept override; + opentelemetry::common::SystemTimestamp timestamp) noexcept override; private: // The name of this logger diff --git a/sdk/include/opentelemetry/sdk/logs/recordable.h b/sdk/include/opentelemetry/sdk/logs/recordable.h index 5eb004e2d6..bf305ed3fa 100644 --- a/sdk/include/opentelemetry/sdk/logs/recordable.h +++ b/sdk/include/opentelemetry/sdk/logs/recordable.h @@ -32,7 +32,7 @@ class Recordable * Set the timestamp for this log. * @param timestamp the timestamp to set */ - virtual void SetTimestamp(common::SystemTimestamp timestamp) noexcept = 0; + virtual void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept = 0; /** * Set the severity for this log. diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h index ebf11e9599..14e8ef39ef 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h @@ -124,7 +124,7 @@ class Aggregator virtual size_t get_max_buckets() { return 0; } // virtual function to be overridden for Gauge Aggregator - virtual common::SystemTimestamp get_checkpoint_timestamp() { return common::SystemTimestamp(); } + virtual opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() { return opentelemetry::common::SystemTimestamp(); } // Custom copy constructor to handle the mutex Aggregator(const Aggregator &cp) diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h index 831e25b2ec..472c255f1e 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h @@ -36,7 +36,7 @@ class GaugeAggregator : public Aggregator this->values_ = std::vector(1, 0); this->checkpoint_ = this->values_; this->agg_kind_ = AggregatorKind::Gauge; - current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); } ~GaugeAggregator() = default; @@ -61,7 +61,7 @@ class GaugeAggregator : public Aggregator this->mu_.lock(); this->updated_ = true; this->values_[0] = val; - current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } @@ -82,7 +82,7 @@ class GaugeAggregator : public Aggregator // Reset the values to default this->values_[0] = 0; checkpoint_timestamp_ = current_timestamp_; - current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } @@ -101,7 +101,7 @@ class GaugeAggregator : public Aggregator this->values_[0] = other.values_[0]; // Now merge checkpoints this->checkpoint_[0] = other.checkpoint_[0]; - current_timestamp_ = common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } else @@ -119,7 +119,7 @@ class GaugeAggregator : public Aggregator /** * @return the latest checkpointed timestamp */ - common::SystemTimestamp get_checkpoint_timestamp() override { return checkpoint_timestamp_; } + opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() override { return checkpoint_timestamp_; } /** * @return the values_ vector stored in this aggregator @@ -129,11 +129,11 @@ class GaugeAggregator : public Aggregator /** * @return the timestamp of when the last value recorded */ - common::SystemTimestamp get_timestamp() { return current_timestamp_; } + opentelemetry::common::SystemTimestamp get_timestamp() { return current_timestamp_; } private: - common::SystemTimestamp current_timestamp_; - common::SystemTimestamp checkpoint_timestamp_; + opentelemetry::common::SystemTimestamp current_timestamp_; + opentelemetry::common::SystemTimestamp checkpoint_timestamp_; }; } // namespace metrics } // namespace sdk diff --git a/sdk/include/opentelemetry/sdk/trace/recordable.h b/sdk/include/opentelemetry/sdk/trace/recordable.h index 022a6a8c95..24bca38e3f 100644 --- a/sdk/include/opentelemetry/sdk/trace/recordable.h +++ b/sdk/include/opentelemetry/sdk/trace/recordable.h @@ -54,7 +54,7 @@ class Recordable * @param attributes the attributes associated with the event */ virtual void AddEvent(nostd::string_view name, - common::SystemTimestamp timestamp, + opentelemetry::common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept = 0; /** @@ -63,7 +63,7 @@ class Recordable */ void AddEvent(nostd::string_view name) { - AddEvent(name, common::SystemTimestamp(std::chrono::system_clock::now()), + AddEvent(name, opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), opentelemetry::sdk::GetEmptyAttributes()); } @@ -72,7 +72,7 @@ class Recordable * @param name the name of the event * @param timestamp the timestamp of the event */ - void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) + void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp) { AddEvent(name, timestamp, opentelemetry::sdk::GetEmptyAttributes()); } diff --git a/sdk/src/logs/logger.cc b/sdk/src/logs/logger.cc index 8758a5f50b..b4dfefb983 100644 --- a/sdk/src/logs/logger.cc +++ b/sdk/src/logs/logger.cc @@ -45,7 +45,7 @@ void Logger::Log(opentelemetry::logs::Severity severity, opentelemetry::trace::TraceId trace_id, opentelemetry::trace::SpanId span_id, opentelemetry::trace::TraceFlags trace_flags, - common::SystemTimestamp timestamp) noexcept + opentelemetry::common::SystemTimestamp timestamp) noexcept { // If this logger does not have a processor, no need to create a log record auto processor = logger_provider_.lock()->GetProcessor(); diff --git a/sdk/src/trace/span.cc b/sdk/src/trace/span.cc index eb0bdface0..6d0fcbebca 100644 --- a/sdk/src/trace/span.cc +++ b/sdk/src/trace/span.cc @@ -145,7 +145,7 @@ void Span::AddEvent(nostd::string_view name) noexcept recordable_->AddEvent(name); } -void Span::AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept +void Span::AddEvent(nostd::string_view name, SystemTimestamp timestamp) noexcept { std::lock_guard lock_guard{mu_}; if (recordable_ == nullptr) @@ -156,7 +156,7 @@ void Span::AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) } void Span::AddEvent(nostd::string_view name, - common::SystemTimestamp timestamp, + SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept { std::lock_guard lock_guard{mu_}; diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 54368ae89a..02540b5a5c 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -33,10 +33,10 @@ class Span final : public trace_api::Span void AddEvent(nostd::string_view name) noexcept override; - void AddEvent(nostd::string_view name, common::SystemTimestamp timestamp) noexcept override; + void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp) noexcept override; void AddEvent(nostd::string_view name, - common::SystemTimestamp timestamp, + opentelemetry::common::SystemTimestamp timestamp, const opentelemetry::common::KeyValueIterable &attributes) noexcept override; void SetStatus(trace_api::StatusCode code, nostd::string_view description) noexcept override; From 0b47a701c47749811c2d9580970e05f7075a5126 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Wed, 21 Apr 2021 09:57:46 -0700 Subject: [PATCH 5/7] Remove obsolete namespaces --- exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h | 1 - .../include/opentelemetry/exporters/etw/etw_tracer_exporter.h | 1 - 2 files changed, 2 deletions(-) diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 8c55d3bf3e..3eecec02d3 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -49,7 +49,6 @@ #include "opentelemetry/exporters/etw/etw_provider.h" #include "opentelemetry/exporters/etw/utils.h" -namespace core = opentelemetry::core; namespace trace = opentelemetry::trace; OPENTELEMETRY_BEGIN_NAMESPACE diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h index 107254e026..45c54a68d7 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h @@ -37,5 +37,4 @@ #include "opentelemetry/exporters/etw/utils.h" -namespace core = opentelemetry::core; namespace trace = opentelemetry::trace; From 85049a7232eaf3a3e69622268c7bec1355985c41 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Wed, 21 Apr 2021 11:40:15 -0700 Subject: [PATCH 6/7] Format --- api/include/opentelemetry/trace/noop.h | 4 ++-- sdk/include/opentelemetry/sdk/logs/log_record.h | 5 ++++- .../sdk/metrics/aggregator/aggregator.h | 5 ++++- .../sdk/metrics/aggregator/gauge_aggregator.h | 9 ++++++--- sdk/include/opentelemetry/sdk/trace/span_data.h | 12 ++++++------ sdk/src/trace/span.h | 3 ++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/api/include/opentelemetry/trace/noop.h b/api/include/opentelemetry/trace/noop.h index f4dfeb371a..762b2dd035 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -35,8 +35,8 @@ class NoopSpan final : public Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, - common::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, + common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/, diff --git a/sdk/include/opentelemetry/sdk/logs/log_record.h b/sdk/include/opentelemetry/sdk/logs/log_record.h index f5e837b14a..a41e47523b 100644 --- a/sdk/include/opentelemetry/sdk/logs/log_record.h +++ b/sdk/include/opentelemetry/sdk/logs/log_record.h @@ -127,7 +127,10 @@ class LogRecord final : public Recordable * Set the timestamp for this log. * @param timestamp the timestamp of the event */ - void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept override { timestamp_ = timestamp; } + void SetTimestamp(opentelemetry::common::SystemTimestamp timestamp) noexcept override + { + timestamp_ = timestamp; + } /************************** Getters for each field ****************************/ diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h index 14e8ef39ef..d3e878d785 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/aggregator.h @@ -124,7 +124,10 @@ class Aggregator virtual size_t get_max_buckets() { return 0; } // virtual function to be overridden for Gauge Aggregator - virtual opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() { return opentelemetry::common::SystemTimestamp(); } + virtual opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() + { + return opentelemetry::common::SystemTimestamp(); + } // Custom copy constructor to handle the mutex Aggregator(const Aggregator &cp) diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h index 472c255f1e..fa36f07981 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/gauge_aggregator.h @@ -82,7 +82,7 @@ class GaugeAggregator : public Aggregator // Reset the values to default this->values_[0] = 0; checkpoint_timestamp_ = current_timestamp_; - current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } @@ -101,7 +101,7 @@ class GaugeAggregator : public Aggregator this->values_[0] = other.values_[0]; // Now merge checkpoints this->checkpoint_[0] = other.checkpoint_[0]; - current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); + current_timestamp_ = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()); this->mu_.unlock(); } else @@ -119,7 +119,10 @@ class GaugeAggregator : public Aggregator /** * @return the latest checkpointed timestamp */ - opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() override { return checkpoint_timestamp_; } + opentelemetry::common::SystemTimestamp get_checkpoint_timestamp() override + { + return checkpoint_timestamp_; + } /** * @return the values_ vector stored in this aggregator diff --git a/sdk/include/opentelemetry/sdk/trace/span_data.h b/sdk/include/opentelemetry/sdk/trace/span_data.h index 770317c89f..4bc7ab8dda 100644 --- a/sdk/include/opentelemetry/sdk/trace/span_data.h +++ b/sdk/include/opentelemetry/sdk/trace/span_data.h @@ -190,12 +190,12 @@ class SpanData final : public Recordable attribute_map_.SetAttribute(key, value); } - void AddEvent( - nostd::string_view name, - opentelemetry::common::SystemTimestamp timestamp = opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), - const opentelemetry::common::KeyValueIterable &attributes = - opentelemetry::common::KeyValueIterableView>( - {})) noexcept override + void AddEvent(nostd::string_view name, + opentelemetry::common::SystemTimestamp timestamp = + opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()), + const opentelemetry::common::KeyValueIterable &attributes = + opentelemetry::common::KeyValueIterableView>( + {})) noexcept override { SpanDataEvent event(std::string(name), timestamp, attributes); events_.push_back(event); diff --git a/sdk/src/trace/span.h b/sdk/src/trace/span.h index 02540b5a5c..decb2d89c9 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -33,7 +33,8 @@ class Span final : public trace_api::Span void AddEvent(nostd::string_view name) noexcept override; - void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp) noexcept override; + void AddEvent(nostd::string_view name, + opentelemetry::common::SystemTimestamp timestamp) noexcept override; void AddEvent(nostd::string_view name, opentelemetry::common::SystemTimestamp timestamp, From 098e77380b2c17de2a1d77e1f274e1181ec36611 Mon Sep 17 00:00:00 2001 From: Johannes Tax Date: Wed, 21 Apr 2021 11:42:46 -0700 Subject: [PATCH 7/7] Format --- examples/plugin/plugin/tracer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/plugin/plugin/tracer.cc b/examples/plugin/plugin/tracer.cc index 86882c8d8f..17cb76e704 100644 --- a/examples/plugin/plugin/tracer.cc +++ b/examples/plugin/plugin/tracer.cc @@ -33,8 +33,8 @@ class Span final : public trace::Span void AddEvent(nostd::string_view /*name*/) noexcept override {} - void AddEvent(nostd::string_view /*name*/, - common::SystemTimestamp /*timestamp*/) noexcept override + void AddEvent(nostd::string_view /*name*/, + common::SystemTimestamp /*timestamp*/) noexcept override {} void AddEvent(nostd::string_view /*name*/,