diff --git a/VERSION b/VERSION index 3dda072..46f8a98 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -Package Version: 1.1.1 -Library Version: 1:0:1 +Package Version: 1.1.2 +Library Version: 1:1:1 diff --git a/include/util.h b/include/util.h index 81bdcb3..50a4109 100644 --- a/include/util.h +++ b/include/util.h @@ -30,6 +30,7 @@ extern otc_ext_malloc_t otc_ext_malloc; extern otc_ext_free_t otc_ext_free; +std::chrono::microseconds timespec_to_duration_us(const struct timespec *ts); std::chrono::nanoseconds timespec_to_duration(const struct timespec *ts); const char *otc_strerror(int errnum); diff --git a/src/span.cpp b/src/span.cpp index 2d98476..3e9323d 100644 --- a/src/span.cpp +++ b/src/span.cpp @@ -64,7 +64,11 @@ static void ot_span_finish_with_options(struct otc_span *span, const struct otc_ struct opentracing::LogRecord record; if (options->log_records[i].timestamp.value.tv_sec > 0) { +#ifdef __clang__ + auto dt = timespec_to_duration_us(&(options->log_records[i].timestamp.value)); +#else auto dt = timespec_to_duration(&(options->log_records[i].timestamp.value)); +#endif record.timestamp = std::chrono::time_point(dt); } diff --git a/src/tracer.cpp b/src/tracer.cpp index 33c30ab..80f56b0 100644 --- a/src/tracer.cpp +++ b/src/tracer.cpp @@ -159,7 +159,11 @@ static struct otc_span *ot_tracer_start_span_with_options(struct otc_tracer *tra } if (options->start_time_system.value.tv_sec > 0) { +#ifdef __clang__ + auto dt = timespec_to_duration_us(&(options->start_time_system.value)); +#else auto dt = timespec_to_duration(&(options->start_time_system.value)); +#endif span_options.start_system_timestamp = std::chrono::time_point(dt); } diff --git a/src/util.cpp b/src/util.cpp index c9c6405..3236e9d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -20,6 +20,27 @@ otc_ext_malloc_t otc_ext_malloc = OT_IFDEF_DBG(otc_dbg_malloc, malloc); otc_ext_free_t otc_ext_free = OT_IFDEF_DBG(otc_dbg_free, free); +/*** + * NAME + * timespec_to_duration_us - + * + * ARGUMENTS + * ts - + * + * DESCRIPTION + * - + * + * RETURN VALUE + * - + */ +std::chrono::microseconds timespec_to_duration_us(const struct timespec *ts) +{ + auto duration = std::chrono::seconds{ts->tv_sec} + std::chrono::microseconds{ts->tv_nsec / 1000}; + + return std::chrono::duration_cast(duration); +} + + /*** * NAME * timespec_to_duration -