-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ETW Exporter - Add support for Sampler and ID Generator (#1547)
- Loading branch information
Showing
4 changed files
with
186 additions
and
36 deletions.
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