Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package opentracing-cpp for openSUSE:Factory checked in at 2021-02-18 20:40:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/opentracing-cpp (Old) and /work/SRC/openSUSE:Factory/.opentracing-cpp.new.28504 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "opentracing-cpp" Thu Feb 18 20:40:42 2021 rev:5 rq:873202 version:1.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/opentracing-cpp/opentracing-cpp.changes 2019-03-20 13:21:27.937312046 +0100 +++ /work/SRC/openSUSE:Factory/.opentracing-cpp.new.28504/opentracing-cpp.changes 2021-02-18 20:52:43.815457380 +0100 @@ -1,0 +2,15 @@ +Mon Dec 28 22:54:14 UTC 2020 - John Vandenberg <jay...@gmail.com> + +- Update to v1.6.0 + * Implements CPack for easy RPM building + * Support copying span contexts + * Fix error code comparisons + * Directly support opentracing::string_view as a Value + * Support specifying timestamp with Log + * Support accessing IDs + * Support querying to see if a tracer is registered + * Specialize conversion between time points of the same clock +- from v1.5.1 + * Fix error handling for dynamic loading + +------------------------------------------------------------------- Old: ---- opentracing-cpp-1.5.0.tar.gz New: ---- opentracing-cpp-1.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ opentracing-cpp.spec ++++++ --- /var/tmp/diff_new_pack.Wuy7Ke/_old 2021-02-18 20:52:44.335457867 +0100 +++ /var/tmp/diff_new_pack.Wuy7Ke/_new 2021-02-18 20:52:44.339457871 +0100 @@ -1,7 +1,7 @@ # # spec file for package opentracing-cpp # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -20,7 +20,7 @@ %define src_install_dir /usr/src/%{name} Name: opentracing-cpp -Version: 1.5.0 +Version: 1.6.0 Release: 0 Summary: OpenTracing C++ API License: MIT ++++++ opentracing-cpp-1.5.0.tar.gz -> opentracing-cpp-1.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/CMakeLists.txt new/opentracing-cpp-1.6.0/CMakeLists.txt --- old/opentracing-cpp-1.5.0/CMakeLists.txt 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/CMakeLists.txt 2019-09-18 23:59:25.000000000 +0200 @@ -1,3 +1,4 @@ +set(CPACK_RPM_COMPONENT_INSTALL ON) cmake_minimum_required(VERSION 3.1) project(opentracing-cpp) @@ -9,12 +10,12 @@ # # Also, whenever the ABI is between versions and in development # suffix the ABI version number with "_unstable". -set(OPENTRACING_ABI_VERSION "2") +set(OPENTRACING_ABI_VERSION "3") # Version number follows semver # See https://semver.org/ set(OPENTRACING_VERSION_MAJOR "1") -set(OPENTRACING_VERSION_MINOR "5") +set(OPENTRACING_VERSION_MINOR "6") set(OPENTRACING_VERSION_PATCH "0") set(OPENTRACING_VERSION_STRING "${OPENTRACING_VERSION_MAJOR}.${OPENTRACING_VERSION_MINOR}.${OPENTRACING_VERSION_PATCH}") @@ -26,10 +27,18 @@ SET(CPACK_PACKAGE_VENDOR "opentracing.io") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +SET(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") SET(CPACK_PACKAGE_VERSION_MAJOR ${OPENTRACING_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${OPENTRACING_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${OPENTRACING_VERSION_PATCH}) +set(CPACK_RPM_DIST_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/runldconfig) +set(CPACK_RPM_DIST_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/runldconfig) +set(CPACK_COMPONENTS_ALL DIST DEVEL) +set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) +set(CPACK_GENERATOR "RPM") +set(CPACK_COMPONENTS_IGNORE_GROUPS 1) + include(CPack) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output) @@ -52,7 +61,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} -D_SCL_SECURE_NO_WARNINGS") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SCL_SECURE_NO_WARNINGS") endif() # ============================================================================== @@ -115,7 +124,8 @@ configure_file(config.h.in include/opentracing/config.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/opentracing - DESTINATION include) + DESTINATION include + COMPONENT DEVEL) # ============================================================================== # OpenTracing library targets @@ -154,9 +164,11 @@ SOVERSION ${OPENTRACING_VERSION_MAJOR}) target_compile_definitions(opentracing PRIVATE OPENTRACING_EXPORTS) install(TARGETS opentracing EXPORT OpenTracingTargets + COMPONENT DIST RUNTIME DESTINATION ${LIB_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + ) if (CLANG_TIDY_EXE) set_target_properties(opentracing PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}") @@ -170,20 +182,26 @@ if (NOT WIN32) set_target_properties(opentracing-static PROPERTIES OUTPUT_NAME opentracing) endif() - target_compile_definitions(opentracing-static PRIVATE OPENTRACING_STATIC) + target_compile_definitions(opentracing-static PUBLIC OPENTRACING_STATIC) target_include_directories(opentracing-static INTERFACE "$<INSTALL_INTERFACE:include/>") install(TARGETS opentracing-static EXPORT OpenTracingTargets - ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) + ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) endif() -install(DIRECTORY 3rd_party/include/opentracing/expected DESTINATION include/opentracing +install(DIRECTORY 3rd_party/include/opentracing/expected + COMPONENT DEVEL + DESTINATION include/opentracing FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") -install(DIRECTORY 3rd_party/include/opentracing/variant DESTINATION include/opentracing +install(DIRECTORY 3rd_party/include/opentracing/variant + COMPONENT DEVEL + DESTINATION include/opentracing FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h") -install(DIRECTORY include/opentracing DESTINATION include +install(DIRECTORY include/opentracing + COMPONENT DEVEL + DESTINATION include FILES_MATCHING PATTERN "*.h") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/ci/setup_linux_environment.sh new/opentracing-cpp-1.6.0/ci/setup_linux_environment.sh --- old/opentracing-cpp-1.5.0/ci/setup_linux_environment.sh 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/ci/setup_linux_environment.sh 2019-09-18 23:59:25.000000000 +0200 @@ -8,3 +8,8 @@ -o Dir::Etc::sourceparts="-" \ -o APT::Get::List-Cleanup="0" sudo apt-get install openjdk-8-jdk bazel +sudo apt-get install software-properties-common + +sudo add-apt-repository ppa:george-edison55/cmake-3.x -y +sudo apt-get update +sudo apt-get install cmake diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/cmake/runldconfig new/opentracing-cpp-1.6.0/cmake/runldconfig --- old/opentracing-cpp-1.5.0/cmake/runldconfig 1970-01-01 01:00:00.000000000 +0100 +++ new/opentracing-cpp-1.6.0/cmake/runldconfig 2019-09-18 23:59:25.000000000 +0200 @@ -0,0 +1,4 @@ +#!/bin/bash +/sbin/ldconfig + +#This sets up the links between shared libraries after installation and uninstallation of RPMs. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/example/tutorial/text_map_carrier.h new/opentracing-cpp-1.6.0/example/tutorial/text_map_carrier.h --- old/opentracing-cpp-1.5.0/example/tutorial/text_map_carrier.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/example/tutorial/text_map_carrier.h 2019-09-18 23:59:25.000000000 +0200 @@ -5,10 +5,10 @@ #include <string> #include <unordered_map> -using opentracing::TextMapReader; -using opentracing::TextMapWriter; using opentracing::expected; using opentracing::string_view; +using opentracing::TextMapReader; +using opentracing::TextMapWriter; class TextMapCarrier : public TextMapReader, public TextMapWriter { public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/include/opentracing/ext/tags.h new/opentracing-cpp-1.6.0/include/opentracing/ext/tags.h --- old/opentracing-cpp-1.5.0/include/opentracing/ext/tags.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/include/opentracing/ext/tags.h 2019-09-18 23:59:25.000000000 +0200 @@ -31,42 +31,42 @@ // --------------------------------------------------------------------------- // error indicates whether a Span ended in an error state. // --------------------------------------------------------------------------- -extern const opentracing::string_view error; +OPENTRACING_API extern const opentracing::string_view error; // --------------------------------------------------------------------------- // component (string) ia s low-cardinality identifier of the module, library, // or package that is generating a span. // --------------------------------------------------------------------------- -extern const opentracing::string_view component; +OPENTRACING_API extern const opentracing::string_view component; // --------------------------------------------------------------------------- // sampling_priority (uint16) determines the priority of sampling this Span. // --------------------------------------------------------------------------- -extern const opentracing::string_view sampling_priority; +OPENTRACING_API extern const opentracing::string_view sampling_priority; // --------------------------------------------------------------------------- // peer_* tags can be emitted by either client-side of server-side to describe // the other side/service in a peer-to-peer communications, like an RPC call. // --------------------------------------------------------------------------- // peer_service (string) records the service name of the peer -extern const opentracing::string_view peer_service; +OPENTRACING_API extern const opentracing::string_view peer_service; // peer_hostname (string) records the host name of the peer -extern const opentracing::string_view peer_hostname; +OPENTRACING_API extern const opentracing::string_view peer_hostname; // peer_address (string) suitable for use in a networking client library. // This may be a "ip:port", a bare "hostname", a FQDN, or even a // JDBC substring like "mysql://prod-db:3306" -extern const opentracing::string_view peer_address; +OPENTRACING_API extern const opentracing::string_view peer_address; // peer_host_ipv4 (uint32) records IP v4 host address of the peer -extern const opentracing::string_view peer_host_ipv4; +OPENTRACING_API extern const opentracing::string_view peer_host_ipv4; // peer_host_ipv6 (string) records IP v6 host address of the peer -extern const opentracing::string_view peer_host_ipv6; +OPENTRACING_API extern const opentracing::string_view peer_host_ipv6; // peer_port (uint16) records port number of the peer -extern const opentracing::string_view peer_port; +OPENTRACING_API extern const opentracing::string_view peer_port; // --------------------------------------------------------------------------- // HTTP tags @@ -74,15 +74,15 @@ // http_url (string) should be the URL of the request being handled in this // segment of the trace, in standard URI format. The protocol is optional. -extern const opentracing::string_view http_url; +OPENTRACING_API extern const opentracing::string_view http_url; // http_method (string) is the HTTP method of the request. // Both upper/lower case values are allowed. -extern const opentracing::string_view http_method; +OPENTRACING_API extern const opentracing::string_view http_method; // http_status_code (int) is the numeric HTTP status code (200, 404, etc) // of the HTTP response. -extern const opentracing::string_view http_status_code; +OPENTRACING_API extern const opentracing::string_view http_status_code; // --------------------------------------------------------------------------- // DATABASE tags @@ -91,20 +91,20 @@ // database_instance (string) The database instance name. E.g., In java, if // the jdbc.url="jdbc:mysql://127.0.0.1:3306/customers", the instance // name is "customers" -extern const opentracing::string_view database_instance; +OPENTRACING_API extern const opentracing::string_view database_instance; // database_statement (string) A database statement for the given database // type. E.g., for db.type="SQL", "SELECT * FROM user_table"; // for db.type="redis", "SET mykey 'WuValue'". -extern const opentracing::string_view database_statement; +OPENTRACING_API extern const opentracing::string_view database_statement; // database_type (string) For any SQL database, "sql". For others, // the lower-case database category, e.g. "cassandra", "hbase", or "redis". -extern const opentracing::string_view database_type; +OPENTRACING_API extern const opentracing::string_view database_type; // database_user (string) Username for accessing database. E.g., // "readonly_user" or "reporting_user" -extern const opentracing::string_view database_user; +OPENTRACING_API extern const opentracing::string_view database_user; // --------------------------------------------------------------------------- // message_bus tags @@ -114,7 +114,7 @@ // exchanged. E.g. A Kafka record has an associated "topic name" that can // be extracted by the instrumented producer or consumer and stored // using this tag. -extern const opentracing::string_view message_bus_destination; +OPENTRACING_API extern const opentracing::string_view message_bus_destination; } // namespace ext END_OPENTRACING_ABI_NAMESPACE } // namespace opentracing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/include/opentracing/span.h new/opentracing-cpp-1.6.0/include/opentracing/span.h --- old/opentracing-cpp-1.5.0/include/opentracing/span.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/include/opentracing/span.h 2019-09-18 23:59:25.000000000 +0200 @@ -7,6 +7,7 @@ #include <opentracing/version.h> #include <chrono> #include <functional> +#include <memory> #include <string> #include <vector> @@ -26,6 +27,30 @@ virtual void ForeachBaggageItem( std::function<bool(const std::string& key, const std::string& value)> f) const = 0; + + // Clone creates a copy of SpanContext. + // + // Returns nullptr on failure. + virtual std::unique_ptr<SpanContext> Clone() const noexcept = 0; + + // Return the ID of the trace. + // + // Should be globally unique. Every span in a trace shares this ID. + // + // An empty string will be returned if the tracer does not support this + // functionality or an error occurs (this is the case for no-op traces, for + // example). + virtual std::string ToTraceID() const noexcept { return {}; } + + // Return the ID of the associated Span. + // + // Should be unique within a trace. Each span within a trace contains a + // different ID. + // + // An empty string will be returned if the tracer does not support this + // functionality or an error occurs (this is the case for no-op traces, for + // example). + virtual std::string ToSpanID() const noexcept { return {}; } }; struct LogRecord { @@ -149,6 +174,14 @@ virtual void Log( std::initializer_list<std::pair<string_view, Value>> fields) noexcept = 0; + virtual void Log( + SystemTime timestamp, + std::initializer_list<std::pair<string_view, Value>> fields) noexcept = 0; + + virtual void Log( + SystemTime timestamp, + const std::vector<std::pair<string_view, Value>>& fields) noexcept = 0; + // context() yields the SpanContext for this Span. Note that the return // value of context() is still valid after a call to Span.Finish(), as is // a call to Span.context() after a call to Span.Finish(). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/include/opentracing/tracer.h new/opentracing-cpp-1.6.0/include/opentracing/tracer.h --- old/opentracing-cpp-1.5.0/include/opentracing/tracer.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/include/opentracing/tracer.h 2019-09-18 23:59:25.000000000 +0200 @@ -161,6 +161,8 @@ // former global tracer value. static std::shared_ptr<Tracer> InitGlobal( std::shared_ptr<Tracer> tracer) noexcept; + + static bool IsGlobalTracerRegistered() noexcept; }; // StartTimestamp is a StartSpanOption that sets an explicit start timestamp for diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/include/opentracing/util.h new/opentracing-cpp-1.6.0/include/opentracing/util.h --- old/opentracing-cpp-1.5.0/include/opentracing/util.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/include/opentracing/util.h 2019-09-18 23:59:25.000000000 +0200 @@ -1,6 +1,7 @@ #ifndef OPENTRACING_UTIL_H #define OPENTRACING_UTIL_H +#include <opentracing/string_view.h> #include <opentracing/version.h> #include <chrono> #include <system_error> @@ -41,7 +42,9 @@ // an approximation suggested by Howard Hinnant. // // See https://stackoverflow.com/a/35282833/4447365 -template <class ToClock, class FromClock, class Duration> +template <class ToClock, class FromClock, class Duration, + typename std::enable_if< + !std::is_same<FromClock, ToClock>::value>::type * = nullptr> typename ToClock::time_point convert_time_point( std::chrono::time_point<FromClock, Duration> from_time_point) { auto from_now = FromClock::now(); @@ -49,6 +52,32 @@ return to_now + std::chrono::duration_cast<typename ToClock::duration>( from_time_point - from_now); } + +template <class ToClock, class FromClock, class Duration, + typename std::enable_if<std::is_same<FromClock, ToClock>::value>::type + * = nullptr> +typename ToClock::time_point convert_time_point( + std::chrono::time_point<FromClock, Duration> from_time_point) { + return std::chrono::time_point_cast<typename ToClock::time_point::duration>( + from_time_point); +} + +// std::error_code's have default comparison operators; however, they make use +// of singleton addresses which can cause comparisons to fail when multiple +// versions of the opentracing library are linked in. Since this is a common +// deployment scenario when making OpenTracing plugins, we add this utility +// function to make comparing std::error_code across libraries easier. +// +// Note: There's a proposed change to the C++ standard that addresses this +// issue. See +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1196r0.html +inline bool are_errors_equal(std::error_code lhs, + std::error_code rhs) noexcept { + return opentracing::string_view{lhs.category().name()} == + opentracing::string_view{rhs.category().name()} && + lhs.value() == rhs.value(); +} + END_OPENTRACING_ABI_NAMESPACE } // namespace opentracing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/include/opentracing/value.h new/opentracing-cpp-1.6.0/include/opentracing/value.h --- old/opentracing-cpp-1.5.0/include/opentracing/value.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/include/opentracing/value.h 2019-09-18 23:59:25.000000000 +0200 @@ -16,9 +16,10 @@ typedef std::unordered_map<std::string, Value> Dictionary; typedef std::vector<Value> Values; -typedef util::variant< - bool, double, int64_t, uint64_t, std::string, std::nullptr_t, const char*, - util::recursive_wrapper<Values>, util::recursive_wrapper<Dictionary>> +typedef util::variant<bool, double, int64_t, uint64_t, std::string, + opentracing::string_view, std::nullptr_t, const char*, + util::recursive_wrapper<Values>, + util::recursive_wrapper<Dictionary>> variant_type; class Value : public variant_type { @@ -53,7 +54,7 @@ Value(const std::string& s) : variant_type(s) {} Value(std::string&& s) : variant_type(std::move(s)) {} - Value(opentracing::string_view s) : variant_type(std::string{s}) {} + Value(opentracing::string_view s) noexcept : variant_type(s) {} Value(const Values& values) : variant_type(values) {} Value(Values&& values) : variant_type(std::move(values)) {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/CMakeLists.txt new/opentracing-cpp-1.6.0/mocktracer/CMakeLists.txt --- old/opentracing-cpp-1.5.0/mocktracer/CMakeLists.txt 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/CMakeLists.txt 2019-09-18 23:59:25.000000000 +0200 @@ -18,7 +18,9 @@ SOVERSION ${OPENTRACING_VERSION_MAJOR}) target_link_libraries(opentracing_mocktracer PUBLIC opentracing) target_compile_definitions(opentracing_mocktracer PRIVATE OPENTRACING_MOCK_TRACER_EXPORTS) - install(TARGETS opentracing_mocktracer EXPORT OpenTracingTargets + install(TARGETS opentracing_mocktracer + COMPONENT DIST + EXPORT OpenTracingTargets LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) @@ -31,7 +33,7 @@ if (NOT WIN32) set_target_properties(opentracing_mocktracer-static PROPERTIES OUTPUT_NAME opentracing_mocktracer) endif() - target_compile_definitions(opentracing_mocktracer-static PRIVATE OPENTRACING_MOCK_TRACER_STATIC) + target_compile_definitions(opentracing_mocktracer-static PUBLIC OPENTRACING_MOCK_TRACER_STATIC) target_include_directories(opentracing_mocktracer-static INTERFACE "$<INSTALL_INTERFACE:include/>") target_link_libraries(opentracing_mocktracer-static opentracing-static) install(TARGETS opentracing_mocktracer-static EXPORT OpenTracingTargets diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/include/opentracing/mocktracer/tracer.h new/opentracing-cpp-1.6.0/mocktracer/include/opentracing/mocktracer/tracer.h --- old/opentracing-cpp-1.5.0/mocktracer/include/opentracing/mocktracer/tracer.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/include/opentracing/mocktracer/tracer.h 2019-09-18 23:59:25.000000000 +0200 @@ -51,8 +51,8 @@ const std::vector<SpanData>& spans() const noexcept { return spans_; } - using Tracer::Inject; using Tracer::Extract; + using Tracer::Inject; expected<void> Inject(const SpanContext& sc, std::ostream& writer) const override; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/src/mock_span.cpp new/opentracing-cpp-1.6.0/mocktracer/src/mock_span.cpp --- old/opentracing-cpp-1.5.0/mocktracer/src/mock_span.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/src/mock_span.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -117,7 +117,7 @@ data_.duration = finish_timestamp - start_steady_; - span_context_.SetData(data_.span_context); + span_context_.CopyData(data_.span_context); if (recorder_ != nullptr) { recorder_->RecordSpan(std::move(data_)); @@ -142,13 +142,36 @@ } void MockSpan::Log( + std::initializer_list<std::pair<string_view, Value>> fields) noexcept { + Log(SystemClock::now(), fields); +} + +void MockSpan::Log( + SystemTime timestamp, std::initializer_list<std::pair<string_view, Value>> fields) noexcept try { + LogRecord log_record; + log_record.timestamp = timestamp; + log_record.fields.reserve(fields.size()); + for (auto& field : fields) { + log_record.fields.emplace_back(field.first, field.second); + } std::lock_guard<std::mutex> lock_guard{mutex_}; + data_.logs.emplace_back(std::move(log_record)); +} catch (const std::exception& e) { + // Drop log record upon error. + fprintf(stderr, "Failed to log: %s\n", e.what()); +} + +void MockSpan::Log( + SystemTime timestamp, + const std::vector<std::pair<string_view, Value>>& fields) noexcept try { LogRecord log_record; - log_record.timestamp = SystemClock::now(); + log_record.timestamp = timestamp; + log_record.fields.reserve(fields.size()); for (auto& field : fields) { log_record.fields.emplace_back(field.first, field.second); } + std::lock_guard<std::mutex> lock_guard{mutex_}; data_.logs.emplace_back(std::move(log_record)); } catch (const std::exception& e) { // Drop log record upon error. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/src/mock_span.h new/opentracing-cpp-1.6.0/mocktracer/src/mock_span.h --- old/opentracing-cpp-1.5.0/mocktracer/src/mock_span.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/src/mock_span.h 2019-09-18 23:59:25.000000000 +0200 @@ -27,6 +27,14 @@ void Log(std::initializer_list<std::pair<string_view, Value>> fields) noexcept override; + void Log(SystemTime timestamp, + std::initializer_list<std::pair<string_view, Value>> + fields) noexcept override; + + void Log(SystemTime timestamp, + const std::vector<std::pair<string_view, Value>>& + fields) noexcept override; + void SetBaggageItem(string_view restricted_key, string_view value) noexcept override; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/src/mock_span_context.cpp new/opentracing-cpp-1.6.0/mocktracer/src/mock_span_context.cpp --- old/opentracing-cpp-1.5.0/mocktracer/src/mock_span_context.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/src/mock_span_context.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -21,12 +21,20 @@ } } -void MockSpanContext::SetData(SpanContextData& data) { +void MockSpanContext::CopyData(SpanContextData& data) const { data.trace_id = data_.trace_id; data.span_id = data_.span_id; std::lock_guard<std::mutex> lock_guard{baggage_mutex_}; data.baggage = data_.baggage; } + +std::unique_ptr<SpanContext> MockSpanContext::Clone() const noexcept try { + auto result = std::unique_ptr<MockSpanContext>{new MockSpanContext{}}; + CopyData(result->data_); + return std::unique_ptr<SpanContext>{result.release()}; +} catch (const std::exception& /*e*/) { + return nullptr; +} } // namespace mocktracer END_OPENTRACING_ABI_NAMESPACE } // namespace opentracing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/src/mock_span_context.h new/opentracing-cpp-1.6.0/mocktracer/src/mock_span_context.h --- old/opentracing-cpp-1.5.0/mocktracer/src/mock_span_context.h 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/src/mock_span_context.h 2019-09-18 23:59:25.000000000 +0200 @@ -2,7 +2,9 @@ #define OPENTRACING_MOCKTRACER_SPAN_CONTEXT_H #include <opentracing/mocktracer/tracer.h> +#include <exception> #include <mutex> +#include <string> #include "propagation.h" namespace opentracing { @@ -29,11 +31,23 @@ std::function<bool(const std::string& key, const std::string& value)> f) const override; + std::string ToTraceID() const noexcept override try { + return std::to_string(data_.trace_id); + } catch (const std::exception& /*e*/) { + return {}; + } + + std::string ToSpanID() const noexcept override try { + return std::to_string(data_.span_id); + } catch (const std::exception& /*e*/) { + return {}; + } + uint64_t trace_id() const noexcept { return data_.trace_id; } uint64_t span_id() const noexcept { return data_.span_id; } - void SetData(SpanContextData& data); + void CopyData(SpanContextData& data) const; template <class Carrier> expected<void> Inject(const PropagationOptions& propagation_options, @@ -49,6 +63,8 @@ return ExtractSpanContext(propagation_options, reader, data_); } + std::unique_ptr<SpanContext> Clone() const noexcept override; + private: friend MockSpan; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/mocktracer/src/propagation.cpp new/opentracing-cpp-1.6.0/mocktracer/src/propagation.cpp --- old/opentracing-cpp-1.5.0/mocktracer/src/propagation.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/mocktracer/src/propagation.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -124,7 +124,9 @@ // First try carrier.LookupKey since that can potentially be the fastest // approach. auto result = carrier.LookupKey(key); - if (result || result.error() != opentracing::lookup_key_not_supported_error) { + if (result || + !are_errors_equal(result.error(), + opentracing::lookup_key_not_supported_error)) { return result; } @@ -155,7 +157,8 @@ auto value_maybe = LookupKey(carrier, propagation_options.propagation_key, key_compare); if (!value_maybe) { - if (value_maybe.error() == opentracing::key_not_found_error) { + if (are_errors_equal(value_maybe.error(), + opentracing::key_not_found_error)) { return false; } else { return opentracing::make_unexpected(value_maybe.error()); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/src/dynamic_load_unix.cpp new/opentracing-cpp-1.6.0/src/dynamic_load_unix.cpp --- old/opentracing-cpp-1.5.0/src/dynamic_load_unix.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/src/dynamic_load_unix.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -74,7 +74,7 @@ if (error_message.empty()) { error_message = error_code.message(); } - return make_unexpected(error_code); + return make_unexpected(dynamic_load_failure_error); } if (tracer_factory == nullptr) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/src/noop.cpp new/opentracing-cpp-1.6.0/src/noop.cpp --- old/opentracing-cpp-1.5.0/src/noop.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/src/noop.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -8,6 +8,10 @@ void ForeachBaggageItem( std::function<bool(const std::string& key, const std::string& value)> /*f*/) const override {} + + std::unique_ptr<SpanContext> Clone() const noexcept override { + return std::unique_ptr<SpanContext>{new (std::nothrow) NoopSpanContext{}}; + } }; class NoopSpan : public Span { @@ -33,6 +37,14 @@ void Log(std::initializer_list<std::pair<string_view, Value>> /*fields*/) noexcept override {} + void Log(SystemTime /*timestamp*/, + std::initializer_list< + std::pair<string_view, Value>> /*fields*/) noexcept override {} + + void Log(SystemTime /*timestamp*/, + const std::vector< + std::pair<string_view, Value>>& /*fields*/) noexcept override {} + const SpanContext& context() const noexcept override { return span_context_; } const Tracer& tracer() const noexcept override { return *tracer_; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/src/tracer.cpp new/opentracing-cpp-1.6.0/src/tracer.cpp --- old/opentracing-cpp-1.5.0/src/tracer.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/src/tracer.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -1,21 +1,60 @@ #include <opentracing/noop.h> #include <opentracing/tracer.h> +#include <mutex> + namespace opentracing { BEGIN_OPENTRACING_ABI_NAMESPACE -static std::shared_ptr<Tracer>& get_global_tracer() { - static std::shared_ptr<Tracer> global_tracer = MakeNoopTracer(); - return global_tracer; -} +namespace { +class TracerRegistry { + public: + static TracerRegistry& instance() noexcept { + static TracerRegistry result; + return result; + } + + static std::shared_ptr<Tracer> RegisterTracer( + std::shared_ptr<Tracer>& tracer) noexcept { + std::lock_guard<std::mutex> lock_guard{mutex_}; + is_registered_ = true; + tracer_.swap(tracer); + return tracer; + } + + static std::shared_ptr<Tracer> tracer() noexcept { + std::lock_guard<std::mutex> lock_guard{mutex_}; + return tracer_; + } + + static bool is_registered() noexcept { + std::lock_guard<std::mutex> lock_guard{mutex_}; + return is_registered_; + } + + private: + static std::mutex mutex_; + static bool is_registered_; + static std::shared_ptr<Tracer> tracer_; +}; + +std::mutex TracerRegistry::mutex_; + +bool TracerRegistry::is_registered_{false}; + +std::shared_ptr<Tracer> TracerRegistry::tracer_{MakeNoopTracer()}; +} // namespace std::shared_ptr<Tracer> Tracer::Global() noexcept { - return get_global_tracer(); + return TracerRegistry::instance().tracer(); } std::shared_ptr<Tracer> Tracer::InitGlobal( std::shared_ptr<Tracer> tracer) noexcept { - get_global_tracer().swap(tracer); - return tracer; + return TracerRegistry::instance().RegisterTracer(tracer); +} + +bool Tracer::IsGlobalTracerRegistered() noexcept { + return TracerRegistry::instance().is_registered(); } END_OPENTRACING_ABI_NAMESPACE } // namespace opentracing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/test/tracer_test.cpp new/opentracing-cpp-1.6.0/test/tracer_test.cpp --- old/opentracing-cpp-1.5.0/test/tracer_test.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/test/tracer_test.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -34,3 +34,10 @@ CHECK(options.references.size() == 0); } } + +TEST_CASE("A tracer can be globally registered") { + CHECK(!Tracer::IsGlobalTracerRegistered()); + auto tracer = MakeNoopTracer(); + CHECK(Tracer::InitGlobal(tracer) != nullptr); + CHECK(Tracer::IsGlobalTracerRegistered()); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/opentracing-cpp-1.5.0/test/util_test.cpp new/opentracing-cpp-1.6.0/test/util_test.cpp --- old/opentracing-cpp-1.5.0/test/util_test.cpp 2018-06-20 17:05:58.000000000 +0200 +++ new/opentracing-cpp-1.6.0/test/util_test.cpp 2019-09-18 23:59:25.000000000 +0200 @@ -7,13 +7,20 @@ #include <opentracing/catch2/catch.hpp> TEST_CASE("convert_time_point") { - // Check that converting from a system_clock time_point to a steady_clock - // time point and then back again produces approximately the same system_clock - // time_point. - auto t1 = SystemClock::now(); - auto t2 = convert_time_point<SteadyClock>(t1); - auto t3 = convert_time_point<SystemClock>(t2); - auto difference = std::abs( - std::chrono::duration_cast<std::chrono::microseconds>(t3 - t1).count()); - CHECK(difference < 100); + SECTION("We can convert between time points of different clocks") { + // Check that converting from a system_clock time_point to a steady_clock + // time point and then back again produces approximately the same + // system_clock time_point. + auto t1 = SystemClock::now(); + auto t2 = convert_time_point<SteadyClock>(t1); + auto t3 = convert_time_point<SystemClock>(t2); + auto difference = std::abs( + std::chrono::duration_cast<std::chrono::microseconds>(t3 - t1).count()); + CHECK(difference < 100); + } + + SECTION("Converting times from the same clock gives the identity") { + auto t = SystemClock::now(); + CHECK(t == convert_time_point<SystemClock>(t)); + } }