-
Notifications
You must be signed in to change notification settings - Fork 423
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
ETW Tracer exporter #376
ETW Tracer exporter #376
Conversation
Codecov Report
@@ Coverage Diff @@
## master #376 +/- ##
==========================================
+ Coverage 94.36% 94.37% +0.01%
==========================================
Files 189 189
Lines 8410 8410
==========================================
+ Hits 7936 7937 +1
+ Misses 474 473 -1
|
2a8d693
to
a79d56d
Compare
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Outdated
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h
Outdated
Show resolved
Hide resolved
33fa87e
to
e33130d
Compare
@pyohannes - I resolved your concern re. |
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 giving this a first review (sorry for chiming in so late in the game). I put some thoughts and questions inline.
Ideally we'd get rid of the (30) TODOs, but I think it's planned to do that after merging this PR, to not prolong the process further.
|
||
/// <summary> | ||
/// stream::Tracer class that allows to send spans to ETW | ||
/// </summary> |
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.
Could we adhere to the established format for doc comments?
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.
By default, the stub generation in Visual Studio for C++ is set to XML Doc Comments (///
). I agree with your suggestion, but I'd like to clean it up in a separate PR, which will have no code changes other than cleaning up the comments from ///
to /**
.
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.
Doc strings should be brought in line with existing standards.
{ | ||
// TODO: support attributes | ||
UNREFERENCED_PARAMETER(attributes); | ||
UNREFERENCED_PARAMETER(links); |
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.
The preferred way to avoid warning for unreferenced parameters is to use then unnamed:
virtual nostd::shared_ptr<trace::Span> StartSpan(
nostd::string_view name,
const common::KeyValueIterable & /*attributes */,
const trace::SpanContextKeyValueIterable & /*links */,
const trace::StartSpanOptions &options = {}) noexcept override
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.
This will be a problem for doxygen: https://stackoverflow.com/questions/55421894/how-do-i-doxygen-document-unnamed-parameters-of-a-function ... Since this module is Windows-specific, I believe UNREFERENCED_PARAMETER
would be appropriate, esp. if we want to run doxygen on that code. Support for both parameters (attributes, links) will be added in a separate PR.. Thus, once these would be actually used, we'd safely remove the UNREFERENCED_PARAMETER
macro (in a separate PR).
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 get your point.
We follow the pattern with unnamed parameters in other places, because it's true to ISO CPP standards. I also think that in most cases implementations of virtual methods in derived classes don't necessarily need documentation.
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_tracer_exporter.h
Outdated
Show resolved
Hide resolved
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
@@ -0,0 +1,7 @@ | |||
#ifdef _WIN32 | |||
|
|||
# define HAVE_NO_TLD |
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.
Should this be defined here, when we also have it defined in a CMakeLists.txt
file? Otherwise this will always override what comes from CMake.
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.
This is kept for now to keep Bazel build happy. This will be removed once we OSS the TraceLoggingDynamic.h
header. Equivalent TLD functionality is available in Go, for example, here: https://godoc.org/github.com/microsoft/go-winio/pkg/etw .. so we will democratize the proper full support of ETW dynamic C++ events and this define will go away. Issue with Bazel is we are trying to avoid conditional compilation to full extent.... Path forward would be to completely eliminate HAVE_NO_TLD
feature gate.
…ID, renaming uuid.hpp to uuid.h
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.
Approved, as @maxgolov prefers to apply changes in different PRs. I tried to summarize open issues below in separate comments.
|
||
/// <summary> | ||
/// stream::Tracer class that allows to send spans to ETW | ||
/// </summary> |
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.
Doc strings should be brought in line with existing standards.
/// <summary> | ||
/// Provider Id (Name or GUID) | ||
/// </summary> | ||
std::string provId; |
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.
Usually for class data members we use lower case with underscores and a trailing underscore. This should be brought in line with existing standards for all occurrences.
https://google.github.io/styleguide/cppguide.html#Variable_Comments
{ | ||
// TODO: support attributes | ||
UNREFERENCED_PARAMETER(attributes); | ||
UNREFERENCED_PARAMETER(links); |
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 get your point.
We follow the pattern with unnamed parameters in other places, because it's true to ISO CPP standards. I also think that in most cases implementations of virtual methods in derived classes don't necessarily need documentation.
break; | ||
} | ||
#pragma warning(pop) | ||
return nostd::shared_ptr<trace::Tracer>{new (std::nothrow) Tracer(*this, name, evtFmt)}; |
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 also just realized that the tracer name is used as ETW provider name. This is broken, for the same reasons given above.
} | ||
|
||
/* clang-format off */ | ||
nlohmann::json jObj = |
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.
The logic for creating the JSON representation of a span should be refactored into its own method and unit tested.
int64_t eventKBSize = (eventByteSize + 1024 - 1) / 1024; | ||
// bool isLargeEvent = eventKBSize >= LargeEventSizeKB; | ||
|
||
// TODO: extract |
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.
All TODO items need to be fixed.
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.
Agreed.
|
||
EXPECT_NO_THROW(span->AddEvent(eventName, event)); | ||
EXPECT_NO_THROW(span->End()); | ||
EXPECT_NO_THROW(tracer->CloseWithMicroseconds(0)); |
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.
It would be great to have an example application illustrating the usage of this exporter, ideally with some instructions on how to receive ETW events. This would help people to use, test and verify the functionality.
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 will commit the ETW listener (written in C#) to contrib repo. Maybe with example how to use this exporter as forward-channel to C#, that may itself then use OpenTelemetry C# to upload the incoming events.
exporters/etw/include/opentelemetry/exporters/etw/etw_provider_exporter.h
Show resolved
Hide resolved
Thanks for reviewing it @pyohannes - I am merging this PR and @maxgolov agreed to fix them in separate incremental PRs |
The PR is the initial commit for the tracer exporter for ETW from the example written by @maxgolov. Issue #326
This PR adds:
Edit 1 (25/11/2020):
code has been updated as per the specification.
-- cc @maxgolov