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..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/common/timestamp.h" #include "opentelemetry/context/runtime_context.h" -#include "opentelemetry/core/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..762b2dd035 100644 --- a/api/include/opentelemetry/trace/noop.h +++ b/api/include/opentelemetry/trace/noop.h @@ -35,11 +35,12 @@ 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..17cb76e704 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,12 @@ 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..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 @@ -160,7 +159,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 +171,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 +624,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 +651,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 +699,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 +733,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 +795,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 +849,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 +862,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/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; 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..6c7a7a1e89 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,9 +210,9 @@ 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() + - std::chrono::seconds(1)); + 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()); std::string next_str = std::to_string(next.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..a41e47523b 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 + opentelemetry::common::SystemTimestamp timestamp_; // uint64 nanoseconds since Unix epoch public: /********** Setters for each field (overrides methods from the Recordable interface) ************/ @@ -127,7 +127,10 @@ 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(opentelemetry::common::SystemTimestamp timestamp) noexcept override + { + timestamp_ = timestamp; + } /************************** Getters for each field ****************************/ @@ -189,7 +192,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_; } + 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 3b2c34fcb6..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, - core::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 45ad3eaf59..bf305ed3fa 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(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 f90f1d7b5a..d3e878d785 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,10 @@ 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 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 5046928bac..fa36f07981 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_ = 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_ = core::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_ = core::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_ = core::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 */ - core::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 +132,11 @@ class GaugeAggregator : public Aggregator /** * @return the timestamp of when the last value recorded */ - core::SystemTimestamp get_timestamp() { return current_timestamp_; } + opentelemetry::common::SystemTimestamp get_timestamp() { return current_timestamp_; } private: - core::SystemTimestamp current_timestamp_; - core::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 ef5678d921..24bca38e3f 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, + 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, core::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, core::SystemTimestamp timestamp) + void AddEvent(nostd::string_view name, opentelemetry::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..4bc7ab8dda 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 @@ -190,12 +190,12 @@ class SpanData final : public Recordable attribute_map_.SetAttribute(key, value); } - void AddEvent( - nostd::string_view name, - core::SystemTimestamp timestamp = core::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); @@ -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_; + opentelemetry::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..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, - core::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 caffc733bd..f890f9b9cd 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 { @@ -129,7 +129,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, SystemTimestamp timestamp) noexcept { std::lock_guard lock_guard{mu_}; if (recordable_ == nullptr) @@ -140,7 +140,7 @@ void Span::AddEvent(nostd::string_view name, core::SystemTimestamp timestamp) no } void Span::AddEvent(nostd::string_view name, - core::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 efc16d6c59..decb2d89c9 100644 --- a/sdk/src/trace/span.h +++ b/sdk/src/trace/span.h @@ -33,10 +33,11 @@ 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, + opentelemetry::common::SystemTimestamp timestamp) noexcept override; void AddEvent(nostd::string_view name, - core::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; @@ -53,7 +54,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 dbfa3146f3..2fa064d4bf 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;