-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl(otel): set Recordable identity and timestamps #11286
impl(otel): set Recordable identity and timestamps #11286
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #11286 +/- ##
=======================================
Coverage 93.77% 93.77%
=======================================
Files 1767 1767
Lines 159222 159222
=======================================
+ Hits 149316 149317 +1
+ Misses 9906 9905 -1 see 3 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
opentelemetry::trace::SpanContext const& /*span_context*/, | ||
opentelemetry::trace::SpanId /*parent_span_id*/) noexcept {} | ||
opentelemetry::trace::SpanContext const& span_context, | ||
opentelemetry::trace::SpanId parent_span_id) noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how you can assert noexcept
when you do things like construct strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't. These are virtual functions and we need to respect the specification.
I tried (and failed) to convince these folks to drop the noexcept
.
It seems that we will need to capture all exceptions. Maybe something like this (
// in some header...
bool NoExceptAction(absl::FunctionRef<void()> action) noexcept;
// in some cc
#if GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS
bool NoExceptAction(absl::FunctionRef<void()> action) noexcept try {
action();
return true;
} catch(...) {
return false;
}
#else
bool NoExceptAction(absl::FunctionRef<void()> action) noexcept {
action(); // Will crash, would have crashed anyway.
return true;
}
#endif
// In Recordable.cc
void Recordable::SetIdentity(...) {
usable_ = usable_ & NoExceptAction([&]() { SetIdentityImpl(...); });
}
Then we will drop (not send to Cloud Trace) any Recordable
s where usable_
is false
.
This is all for a TODO bug and future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #11288
std::array<char, 2 * opentelemetry::trace::TraceId::kSize> hex_trace_buf; | ||
span_context.trace_id().ToLowerBase16(hex_trace_buf); | ||
std::string const hex_trace(hex_trace_buf.data(), | ||
2 * opentelemetry::trace::TraceId::kSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hex_trace_buf.size()
perhaps, to avoid repeating the template parameter, and to perpetuate the "data/size" pairing convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Fixed.
c6e046a
to
26875f5
Compare
// std::chrono::system_clock may not have nanosecond resolution on some | ||
// platforms, so we avoid using it for conversions between OpenTelemetry | ||
// time and Protobuf time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. It seems like opentelemetry::common::SystemTimestamp
's implicit conversion to std::chrono::system_clock::time_point
is a rounding accident waiting to happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thanks for the warning.
// platforms, so we avoid using it for conversions between OpenTelemetry | ||
// time and Protobuf time. | ||
auto t = absl::FromUnixNanos(start_time.time_since_epoch().count()); | ||
*span_.mutable_start_time() = internal::ToProtoTimestamp(std::move(t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absl::Time
is one of those always-pass-by-value exceptions, so drop the move()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Part of the work for #11156
Implement the identity and timestamp setters for a
Recordable
. This change should make the class usable with Cloud Trace.@devbww might be interested in the
absl::Time
business.This change is