-
Notifications
You must be signed in to change notification settings - Fork 446
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 Exporter - Add support for Sampler and ID Generator #1547
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1dd5b5f
support id_generator, sampling
lalitb baa4b06
format
lalitb ddb47c9
Merge branch 'main' into etw-sampling
lalitb 9f48332
fix build
lalitb 0dc35b7
fix
lalitb cc1035f
format
lalitb 5e3a17c
fix crash
lalitb f2f4f10
fix
lalitb bd68184
fix crash
lalitb 3773f51
Merge branch 'main' into etw-sampling
lalitb 9381a99
format
lalitb beee84b
Merge branch 'main' into etw-sampling
ThomsonTan e0ddc94
fix
lalitb 3f7bb6a
add custom id generator tests
lalitb 2760e06
add id gener test
lalitb ceef1e9
Merge branch 'main' into etw-sampling
lalitb 9edcb10
Merge branch 'main' into etw-sampling
lalitb 8456710
Merge branch 'main' into etw-sampling
ThomsonTan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
exporters/etw/include/opentelemetry/exporters/etw/etw_random_id_generator.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#include "opentelemetry/sdk/trace/id_generator.h" | ||
#include "opentelemetry/version.h" | ||
|
||
#ifdef _WIN32 | ||
# include "Windows.h" | ||
#endif | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace trace | ||
{ | ||
|
||
class ETWRandomIdGenerator : public IdGenerator | ||
{ | ||
|
||
opentelemetry::trace::SpanId GenerateSpanId() noexcept override | ||
{ | ||
GUID span_id; | ||
// Generate random GUID | ||
CoCreateGuid(&span_id); | ||
const auto *spanIdPtr = reinterpret_cast<const uint8_t *>(std::addressof(span_id)); | ||
|
||
// Populate SpanId with that GUID | ||
nostd::span<const uint8_t, opentelemetry::trace::SpanId::kSize> spanIdBytes( | ||
spanIdPtr, spanIdPtr + opentelemetry::trace::SpanId::kSize); | ||
return opentelemetry::trace::SpanId(spanIdBytes); | ||
} | ||
|
||
opentelemetry::trace::TraceId GenerateTraceId() noexcept override | ||
{ | ||
GUID trace_id; | ||
CoCreateGuid(&trace_id); | ||
// Populate TraceId of the Tracer with the above GUID | ||
const auto *traceIdPtr = reinterpret_cast<const uint8_t *>(std::addressof(trace_id)); | ||
nostd::span<const uint8_t, opentelemetry::trace::TraceId::kSize> traceIdBytes( | ||
traceIdPtr, traceIdPtr + opentelemetry::trace::TraceId::kSize); | ||
return opentelemetry::trace::TraceId(traceIdBytes); | ||
} | ||
}; | ||
} // namespace trace | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ThomsonTan - Can you please review this PR when you have time? The changes were crashing earlier while creating Spans that are not sampled. The fix is to create the
Tracer
usingstd::shared_ptr
, and then move/encapsulate it tonostd::shared_ptr
(as done in line 1014 and 1016 above).