Skip to content
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

Code improvements for ETW exporter #519

Merged
merged 94 commits into from
Apr 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
6bd4aaa
Drafts for proper TLD operation. Verified that TLD flow works well wi…
maxgolov Jan 12, 2021
f8a3af1
Add CODEOWNERS for ETW exporter
maxgolov Jan 15, 2021
035d863
Add support for owning Properties container
maxgolov Jan 15, 2021
1141e29
Make SpanContextKeyValueIterable empty container by default
maxgolov Jan 15, 2021
01cd9ac
is_key_value_iterable does not property test for subclasses of KeyVal…
maxgolov Jan 15, 2021
01c693c
Allow C string type
maxgolov Jan 15, 2021
66b1ee2
Add ability for vendors to customize their ETW field names
maxgolov Jan 15, 2021
90ecfd0
Code refactor to address outstanding feature parity issues
maxgolov Jan 15, 2021
5acc2d3
Code formatting
maxgolov Jan 15, 2021
013d1fd
Fix glob for Bazel build
maxgolov Jan 15, 2021
956e38d
Fix Bazel formatting issue
maxgolov Jan 15, 2021
bcc54f7
Merge branch 'master' into maxgolov/etw_exporter
maxgolov Jan 15, 2021
846ad71
Wrong #ifdef in test
maxgolov Jan 16, 2021
16ccb2a
Add prometheus to Visual Studio 2019 CMake build configuration
maxgolov Jan 16, 2021
fc55f3c
Add support for span<uint8_t> and const char * to OTLP exporter
maxgolov Jan 16, 2021
1b039a8
Sort OwnedAttributeValue in the same order as AttributeValue (for con…
maxgolov Jan 16, 2021
af1718f
Use enums instead of hardcoded constants
maxgolov Jan 16, 2021
d142031
Add prometheus-cpp to vcpkg build on Windows
maxgolov Jan 16, 2021
c02a822
include(CTest) and only then if(BUILD_TESTING)
maxgolov Jan 16, 2021
d86267f
Merge branch 'maxgolov/etw_exporter' of https://github.com/open-telem…
maxgolov Jan 16, 2021
c4d73ad
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jan 16, 2021
afd035e
Fix CI failures
maxgolov Jan 16, 2021
a1141e4
Add nlohmann/json to CMake build
maxgolov Jan 16, 2021
93b2480
Compile empty stub for writeMsgPack when HAVE_MSGPACK is not defined
maxgolov Jan 16, 2021
897da33
Build Bazel with ETW-MsgPack exporter
maxgolov Jan 16, 2021
07952be
Add nlohmann_json to bazel build of ETW exporter
maxgolov Jan 16, 2021
09d8fa9
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jan 19, 2021
8a737c7
Incremental clean-up and simplify Bazel build
maxgolov Jan 20, 2021
a4b459d
Merge branch 'master' into maxgolov/etw_exporter
maxgolov Jan 20, 2021
0c3b167
Update .github/CODEOWNERS
maxgolov Jan 21, 2021
fc2cbb3
Merge branch 'master' into maxgolov/etw_exporter
maxgolov Jan 22, 2021
b7153eb
Allow populating Span from byte buffer
maxgolov Jan 29, 2021
a09a941
Allow populating TraceId from byte buffer
maxgolov Jan 29, 2021
5de423b
Allow populating ActivityId and RelatedActivity based on SpanId and P…
maxgolov Jan 29, 2021
4b5d3b7
Automated context propagation
maxgolov Jan 29, 2021
fdda4da
Include headers for CoCreateGuid
maxgolov Jan 29, 2021
ee14876
Added 3-level deep spans to test
maxgolov Jan 29, 2021
51461d4
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Jan 29, 2021
ebcd88e
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Feb 2, 2021
c81d08e
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Feb 2, 2021
44f0ce2
Reformat code
maxgolov Feb 2, 2021
c3a7442
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Feb 25, 2021
6d70f6d
Build Release without debug info
maxgolov Feb 25, 2021
81f0db9
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Mar 11, 2021
9475c16
Rename test provider to OpenTelemetry-ETW-Provider
maxgolov Mar 11, 2021
0d993d0
Merge branch 'maxgolov/etw_exporter_ActivityId' of https://github.com…
maxgolov Mar 11, 2021
e159b2c
Reformat code using latest formatter
maxgolov Mar 11, 2021
4adafce
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Mar 17, 2021
c9f1efa
define HAVE_TLD only if it hasn't been defined yet
maxgolov Mar 20, 2021
ec0ef2e
Fix C++17 issue regarding deprecated C++11 codecvt
maxgolov Mar 20, 2021
48adeea
Add tests for detailed decorator and min decorator
maxgolov Mar 20, 2021
c3d0dc8
Add smarter ref-counting logic to ETW provider, allowing multiple tra…
maxgolov Mar 20, 2021
753521b
ETW Tracer improvements:
maxgolov Mar 20, 2021
5ed213c
Code formatting changes
maxgolov Mar 20, 2021
1d46f76
Add time routines to utils
maxgolov Mar 23, 2021
131f801
Fix bug in format passing
maxgolov Mar 23, 2021
51bea36
Add separate tests for TLD (TraceLoggingDynamic) encoding and MsgPack…
maxgolov Mar 23, 2021
4543a47
Clean-up field names for ETW notation (common field names used for bo…
maxgolov Mar 23, 2021
48991c0
ETW/MsgPack: Chunk Span Start, Span Event, Span Stop as individual ET…
maxgolov Mar 23, 2021
8678a91
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Mar 26, 2021
665422e
Fix GMock linkage error on Windows
maxgolov Mar 26, 2021
fb71a95
Merge branch 'maxgolov/cmake_windows_fix' of https://github.com/open-…
maxgolov Mar 26, 2021
f459bd3
Addressing code review comments
maxgolov Mar 27, 2021
4fd5528
Remove unused templates
maxgolov Mar 27, 2021
da56e3e
Add benchmark to compare Properties vs initializer list vs unordered_…
maxgolov Mar 30, 2021
2951a1e
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Mar 30, 2021
127f149
Update exporters/etw/include/opentelemetry/exporters/etw/etw_provider.h
maxgolov Mar 31, 2021
b51040a
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Mar 31, 2021
0f2b8d6
Merge branch 'main' of https://github.com/open-telemetry/opentelemetr…
maxgolov Apr 1, 2021
b78797f
Revert "Find GTest via CONFIG mode to reference gmock (#640)"
maxgolov Apr 1, 2021
a683ed5
Add time formatting utility
maxgolov Apr 1, 2021
1db003e
Rename 'kind' field to 'OpCode' (start or stop)
maxgolov Apr 1, 2021
3a7831a
Tests are no longer included in Windows build
maxgolov Apr 1, 2021
b0c31bf
New feature to consolidate all Span info on end of Span into separate…
maxgolov Apr 1, 2021
bcf7325
Apply code formatting rules
maxgolov Apr 1, 2021
1561bd0
Add support for const char* and byte arrays under feature gate in Zip…
maxgolov Apr 1, 2021
b51cd39
Rename type to Google coding style kTypeString
maxgolov Apr 2, 2021
61b2f7c
Addressing code review comments: remove api change
maxgolov Apr 2, 2021
467f823
Addressing code review comments: rename namespace from ETW to etw
maxgolov Apr 2, 2021
576d510
Remove ETW recordable class as it is not needed
maxgolov Apr 2, 2021
a1653b4
Remove HAVE_CSTRING_TYPE build option
maxgolov Apr 2, 2021
57ab55b
Remove API changes
maxgolov Apr 2, 2021
1b0baf7
Rename namespace from ETW to etw
maxgolov Apr 2, 2021
e37cee5
Rename namespace from ETW to etw
maxgolov Apr 2, 2021
63f793d
Address code review comment: rename enum types to follow Google codin…
maxgolov Apr 2, 2021
a8afc39
Remove HAVE_CSTRING_TYPE
maxgolov Apr 2, 2021
18b2f9b
Rename enum types to follow Google coding style
maxgolov Apr 2, 2021
c2777e2
Remove HAVE_CSTRING_TYPE build option
maxgolov Apr 2, 2021
bf8a3d4
Remove HAVE_CSTRING_TYPE option and rename enums to follow Google Cod…
maxgolov Apr 2, 2021
8feee53
Rename namespace from ETW to etw
maxgolov Apr 2, 2021
888a040
Rename types to match Google coding style
maxgolov Apr 2, 2021
69c5e66
Fix mismatched ifdef
maxgolov Apr 2, 2021
80512b5
Revert changes to TraceZ
maxgolov Apr 2, 2021
550f2d8
true should be returned from Null object pattern to indicate success
maxgolov Apr 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Code owners file.
# This file controls who is tagged for review for any given pull request.

# For ETW exporter
exporters/etw/* @reyang @maxgolov @lalitb @ThomsonTan @open-telemetry/cpp-approvers

# For anything not explicitly taken by someone else:
* @open-telemetry/cpp-approvers
24 changes: 10 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ if(WIN32)
option(WITH_ETW "Whether to include the ETW Exporter in the SDK" ON)
if(WITH_ETW)
add_definitions(-DHAVE_MSGPACK)
# Option below will be removed once we donate the TraceLoggingDynamic.h to
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
# OSS
add_definitions(-DHAVE_NO_TLD)
endif(WITH_ETW)
endif(WIN32)

Expand Down Expand Up @@ -167,8 +164,8 @@ endif()

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")

include(CTest)
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
if(BUILD_TESTING)
include(CTest)
if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a)
# Prefer GTest from build tree. GTest is not always working with
# CMAKE_PREFIX_PATH
Expand All @@ -181,21 +178,17 @@ if(BUILD_TESTING)
${CMAKE_BINARY_DIR}/lib/libgmock.a)
elseif(WIN32)
# Make sure we are always bootsrapped with vcpkg on Windows
find_package(GTest CONFIG)
if(NOT GTest_FOUND)
find_package(GTest)
if(NOT (GTEST_FOUND OR GTest_FOUND))
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
install_windows_deps()
find_package(GTest CONFIG REQUIRED)
find_package(GTest REQUIRED)
endif()
set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main GTest::gmock)
else()
# Prefer GTest installed by OS distro, brew or vcpkg package manager
find_package(GTest CONFIG REQUIRED)
set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main GTest::gmock)
endif()
if(GTEST_INCLUDE_DIRS)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
find_package(GTest REQUIRED)
endif()
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}")
enable_testing()
# Benchmark respects the CMAKE_PREFIX_PATH
Expand All @@ -217,6 +210,9 @@ if(WITH_EXAMPLES)
endif()
add_subdirectory(ext)

# Add nlohmann/json submodule to include directories
include_directories(third_party/nlohmann-json/single_include)

# Export cmake config and support find_packages(opentelemetry-cpp CONFIG) Write
# config file for find_packages(opentelemetry-cpp CONFIG)
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
Expand Down
214 changes: 116 additions & 98 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -1,108 +1,126 @@
{
"configurations": [
"configurations": [
maxgolov marked this conversation as resolved.
Show resolved Hide resolved
{
"name": "nostd-x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "nostd-x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "nostd-x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"cmakeToolchain": "",
"variables": [
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
},
{
"name": "nostd-x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"cmakeToolchain": "",
"variables": [
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
},
{
"name": "stdlib-x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
},
{
"name": "WITH_PROMETHEUS",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "stdlib-x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [
"msvc_x64_x64"
],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"cmakeToolchain": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "stdlib-x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
},
{
"name": "stdlib-x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"cmakeToolchain": "",
"variables": [
{
"name": "WITH_STL",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_OTLP",
"value": "True",
"type": "BOOL"
},
{
"name": "WITH_EXAMPLES",
"value": "true",
"type": "BOOL"
}
]
"name": "WITH_PROMETHEUS",
"value": "True",
"type": "BOOL"
}
]
]
}
]
}
37 changes: 15 additions & 22 deletions api/include/opentelemetry/common/attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ using AttributeValue =
uint64_t,
double,
nostd::string_view,
#ifdef HAVE_CSTRING_TYPE
// TODO: add C-string as possible value on API surface
const char *,
#endif
#ifdef HAVE_SPAN_BYTE
// TODO: 8-bit byte arrays / binary blobs are not part of OT spec yet!
// Ref: https://github.com/open-telemetry/opentelemetry-specification/issues/780
Expand All @@ -37,26 +33,23 @@ using AttributeValue =

enum AttributeType
{
TYPE_BOOL,
TYPE_INT,
TYPE_INT64,
TYPE_UINT,
TYPE_UINT64,
TYPE_DOUBLE,
TYPE_STRING,
#ifdef HAVE_CSTRING_TYPE
TYPE_CSTRING,
#endif
kTypeBool,
kTypeInt,
kTypeInt64,
kTypeUInt,
kTypeUInt64,
kTypeDouble,
kTypeString,
#ifdef HAVE_SPAN_BYTE
TYPE_SPAN_BYTE,
kTypeSpanByte,
#endif
TYPE_SPAN_BOOL,
TYPE_SPAN_INT,
TYPE_SPAN_INT64,
TYPE_SPAN_UINT,
TYPE_SPAN_UINT64,
TYPE_SPAN_DOUBLE,
TYPE_SPAN_STRING
kTypeSpanBool,
kTypeSpanInt,
kTypeSpanInt64,
kTypeSpanUInt,
kTypeSpanUInt64,
kTypeSpanDouble,
kTypeSpanString
};

} // namespace common
Expand Down
11 changes: 10 additions & 1 deletion api/include/opentelemetry/common/key_value_iterable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ struct is_key_value_iterable
};
} // namespace detail

/**
* @brief Container for key-value pairs that can transform every value in it to one of types
* listed in common::AttributeValue. It may contain value types that are not directly map'able
* to primitive value types. In that case the `ForEachKeyValue` method acts as a transform to
* convert the value type to one listed under AtributeValue (bool, int32_t, int64_t, uint32_t,
* uint64_t, double, nostd::string_view, or arrays of primite types). For example, if UUID,
* GUID, or UTF-16 string type is passed as one of values stored inside this container, the
* container itself may provide a custom implementation of `ForEachKeyValue` to transform the
* 'non-standard' type to one of the standard types.
*/
template <class T>
class KeyValueIterableView final : public KeyValueIterable
{
static_assert(detail::is_key_value_iterable<T>::value, "Must be a key-value iterable");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed ? To accommodate Properties class ? Just want to ensure that this won't make it error-prone if someone tries to create it's instance with incorrect type.

Copy link
Contributor Author

@maxgolov maxgolov Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it, adding an explanation of why exactly. Short answer is that it's a transform into KeyValueIterable where Value = common::AtributeValue, but the original container T - may have wider typing system! Its own value may be an extension over the basic set of OTLP types. That container T then transforms the values to use only common::AttributeValue type of values. This is the original comment on top of this template:

/**
 * @brief Container for key-value pairs that can transform every value in it to one of types
 * listed in common::AttributeValue. It may contain value types that are not directly map'able
 * to primitive value types. In that case the `ForEachKeyValue` method acts as a transform to
 * convert the value type to one listed under AtributeValue (bool, int32_t, int64_t, uint32_t,
 * uint64_t, double, nostd::string_view, or arrays of primite types). For example, if UUID,
 * GUID, or UTF-16 string type is passed as one of values stored inside this container, the
 * container itself may provide a custom implementation of `ForEachKeyValue` to transform the
 * 'non-standard' type to one of the standard types.
 */

I would like to extend this template later on, by moving Properties from ETW exporter into common helper class that lives in API includes. That way we can support ANY type on API surface, and the helper would transform-convert the types into proper common::AttributeValue. It's a handy pattern that would be immensely helpful for byte arrays , for UUID / GUID, and practically for any other useful ValueType. As long as container provides a transform. For example, that container may transform GUID to string. Or byte array to base64 string. Or convert time_t or any sort of other timespec or ticks structure to uint64_t, for example. Devs may follow this pattern to bridge / shim other SDKs and APIs to normalized view within the confines of OpenTelemetry typing system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be safe. The actual contract is captured in the signature of ForEachKeyValue.


public:
explicit KeyValueIterableView(const T &container) noexcept : container_{&container} {}
Expand Down
17 changes: 17 additions & 0 deletions api/include/opentelemetry/trace/span_context_kv_iterable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,22 @@ class SpanContextKeyValueIterable
*/
virtual size_t size() const noexcept = 0;
};

/**
* @brief Null Span context that does not carry any information.
*/
class NullSpanContext : public SpanContextKeyValueIterable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a long name, but let's use NullSpanContextKeyValueIterable. To be consistent with SpanContextKeyValueIterable. NullSpanContext is ambiguous.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, to avoid an additional class, one could also do this:

using SpanContextKeyValueIterableInitializerList = SpanContextKeyValueIterableView<std::initializer_list<
          std::pair<SpanContext,
                    std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>>>>;

And then define your additional StartSpan method like this:

 nostd::shared_ptr<Span> StartSpan(nostd::string_view name,
                                    const common::KeyValueIterable &attributes,
                                    const StartSpanOptions &options = {}) noexcept
  {
    return this->StartSpan(name, attributes, SpanContextKeyValueIterableInitializerList({}), options);
  }

Just to avoid a clutter of types that we also need to document (and that are error-prone, e. g. return false in case of success). We also have NullKeyValueIterable, however, it's not used anywhere ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can refactor this in a separate (unrelated PR) by moving these into separate helper header or something. That would also enable NullTracerProvider cases, unrelated to ETW per se. Right now it is more or less "internal" detail that I think we can rename / adjust before GA.

{
public:
bool ForEachKeyValue(
nostd::function_ref<bool(SpanContext, const opentelemetry::common::KeyValueIterable &)>
callback) const noexcept override
{
return true;
}

size_t size() const noexcept override { return 0; };
};

} // namespace trace
OPENTELEMETRY_END_NAMESPACE
Loading