Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
5ea2e9f
Fix permissions on shell scripts
maxgolov Apr 12, 2020
96fa468
Draft sketch of EventProperties variant for LogEvent API surface
maxgolov Apr 20, 2020
9e398aa
Remove unnecessary headers
maxgolov Apr 20, 2020
1468119
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov May 29, 2020
9acb77c
Add vcpkg submodule and build scripts to use it on Windows
maxgolov May 29, 2020
6fb3a75
Implementation that makes use of Standard Library as much as possible:
maxgolov May 30, 2020
67a9f44
Changes:
maxgolov May 30, 2020
b003fc4
Add OT types to event::Properties and event::Property
maxgolov Jun 1, 2020
10f499e
Add to_span_ptr template
maxgolov Jun 1, 2020
f3b9eae
Add Close() method with default close duration
maxgolov Jun 1, 2020
711de7a
Header-only implementation of Console Tracer
maxgolov Jun 1, 2020
f0427e5
Update EventSender example to show both API surfaces
maxgolov Jun 1, 2020
4c1cd55
Add enum for variant types. Add support for C-string const char * and…
maxgolov Jun 2, 2020
cb7326a
Transform from event::Properties to AttributeValue
maxgolov Jun 2, 2020
8fe51b1
Header-only Console Tracer implementation
maxgolov Jun 2, 2020
f839760
Add .gitignore for MSBuild project
maxgolov Jun 2, 2020
830a502
Implementation of various tracer streams:
maxgolov Jun 3, 2020
1072ccf
Fix an issue with UUID std::string copy by converting UUID to nostd::…
maxgolov Jun 3, 2020
9b185ba
Clean-up utils timestamp
maxgolov Jun 4, 2020
7c8b159
Add Windows pipe example
maxgolov Jun 4, 2020
5d036c5
Rename time field from ts to time
maxgolov Jun 4, 2020
a222d52
Rename to "StreamTracer" and comment out unused header for now
maxgolov Jun 4, 2020
9ce018a
Verified that standard STL with ms-gsl works with gcc-9 on Mac OS X
maxgolov Jun 7, 2020
0e7c661
Fix an issue with clang
maxgolov Jun 7, 2020
2557c35
Fixes to ensure that iterators work properly for both nostd and STL i…
maxgolov Jun 10, 2020
b3a0c19
Revert layout changes
maxgolov Jun 11, 2020
2c988c8
Trimmed down implementation of pure Standard Library STL API surface …
maxgolov Jun 11, 2020
1f718a2
Add Google Test to submodules
maxgolov Jun 11, 2020
4eeaaee
Clean-up string_view iterators
maxgolov Jun 11, 2020
3d30ff6
Remove googletest
maxgolov Jun 11, 2020
f79bf8d
Add CI for Linux and Mac
maxgolov Jun 11, 2020
0f1e3e5
Update build tools script for Linux
maxgolov Jun 11, 2020
bc7a3be
Fix path to STL types header
maxgolov Jun 11, 2020
fe21b45
Create main.yml
maxgolov Jun 11, 2020
6270846
Tests were not including algorithm header
maxgolov Jun 11, 2020
5b8966c
Use nostd::string_view on API surface
maxgolov Jun 11, 2020
03bfd28
Add build options to build both STL and nostd flavors
maxgolov Jun 11, 2020
be2cdef
Temporary fix for atomic_shared_ptr.h issue with gcc-9.3 (c++20 compi…
maxgolov Jun 11, 2020
b6df1ca
Fix all tests to work with both: nostd and standard library implement…
maxgolov Jun 11, 2020
d4e0e67
Modify all nostd tests to allow aliasing to Standard Library implemen…
maxgolov Jun 11, 2020
3788e79
Build infra improvements for Windows
maxgolov Jun 11, 2020
42a0c93
Fix CMake build for Windows
maxgolov Jun 11, 2020
416b543
nostd::span has expectations that do not match those of C++ standard …
maxgolov Jun 11, 2020
410fc22
Standard Library always throws
maxgolov Jun 11, 2020
e273b0b
Add benchmark into sample app
maxgolov Jun 11, 2020
926d012
Add full testsuit for both build configurations
maxgolov Jun 11, 2020
23f614d
Add performance tests for core foundation classes on Windows and POSIX
maxgolov Jun 12, 2020
277b8fa
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jun 12, 2020
9fbe2bb
Add GitHub actions
maxgolov Jun 12, 2020
ac62995
Readd 'experimental' Event API
maxgolov Jun 12, 2020
9ad55fb
TraceStreamer should compile with or without Google Benchmark
maxgolov Jun 12, 2020
406fbb0
Local Visual Studio solution for convenient editing and experimentation
maxgolov Jun 12, 2020
7f0e450
Add output dirs to .gitignore
maxgolov Jun 12, 2020
b0777c0
Merge branch 'master' of https://github.com/maxgolov/opentelemetry-cpp
maxgolov Jun 12, 2020
c79d4f7
Clean-up GitHub Actions
maxgolov Jun 12, 2020
9702905
Testing workflow
maxgolov Jun 12, 2020
ac03ac1
Fix actions
maxgolov Jun 12, 2020
36d0627
Make scripts executable
maxgolov Jun 12, 2020
ebf7fea
Try to install GTest + build it locally
maxgolov Jun 12, 2020
5f98e6b
Add Windows Tools
maxgolov Jun 12, 2020
6ac3a6f
Install tools
maxgolov Jun 12, 2020
1ba4157
Let Linux build GTest from source
maxgolov Jun 12, 2020
266cfe6
Remove Ubuntu 16.xx from build loop
maxgolov Jun 12, 2020
8f07150
Clean-up CMakeLists.txt for GCC-7 support
maxgolov Jun 12, 2020
15c38e0
Adjust the script to work on Mac OS X
maxgolov Jun 12, 2020
72abaee
Build GTest on Mac from source
maxgolov Jun 12, 2020
08076bb
GTest does not properly ask for C++11 on Mac OS X / clang
maxgolov Jun 12, 2020
e15c002
Resolve an issue with std::get on Mac OS X
maxgolov Jun 12, 2020
4bebaf1
Create api-compatibility.md
maxgolov Jun 13, 2020
79dc7b6
Update api-compatibility.md
maxgolov Jun 13, 2020
f94cf69
Improve build and test infra on Windows
maxgolov Jun 15, 2020
9f3cb7f
Merge branch 'master' of https://github.com/maxgolov/opentelemetry-cpp
maxgolov Jun 15, 2020
d921169
Add separate build loop for vs2017 and vs2019
maxgolov Jun 15, 2020
7bd0a0d
Rename api-compatibility.md to abi-compatibility.md
maxgolov Jun 15, 2020
ccfd1c7
Update README.md
maxgolov Jun 15, 2020
b857464
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jun 22, 2020
f7d6e28
Fix ISO C++11 compiler warning that results in a build error: can onl…
maxgolov Jun 22, 2020
131b2e6
Bazel build: add benchmark to some tests
maxgolov Jun 22, 2020
9d7a693
Add compare operators to nostd::string_view
maxgolov Jun 22, 2020
9acefa5
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jun 24, 2020
302734a
Added tests
maxgolov Jun 29, 2020
d59c460
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jun 30, 2020
366f81d
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jul 2, 2020
ff0c1e0
Provide some usage examples for nostd classes used on API surface
maxgolov Jul 3, 2020
6ece3ec
Resolve ambiguity that breaks gcc compilation
maxgolov Jul 3, 2020
96dcbe2
Merge branch 'maxgolov/nostd_examples' of https://github.com/maxgolov…
maxgolov Jul 13, 2020
8135f5e
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jul 13, 2020
fb83a19
Merge of latest opentelemetry master branch + adjust files to use nos…
maxgolov Jul 15, 2020
187d800
Don't include type_traits.h - implemented in nostd.h
maxgolov Jul 15, 2020
3f66116
Minor clean-up
maxgolov Jul 15, 2020
55eb3f7
Temporarily comment out the failing test
maxgolov Jul 15, 2020
657e4c8
Modify build scripts to iteratively run tests for each compiler
maxgolov Jul 15, 2020
6a33447
Remove code comment
maxgolov Jul 15, 2020
3bfc177
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Jul 17, 2020
27cdca0
Minor formatting change
maxgolov Jul 17, 2020
37f0a82
Add ETWTracer reference SDK example that implements OpenTelemetry API…
maxgolov Jul 17, 2020
b931949
Fixes for C++11 and C++14
maxgolov Jul 20, 2020
6fa1e11
Example script that shows how to use logmant to capture ETW events
maxgolov Jul 20, 2020
464dcb8
Allow GUID format: starts with curly brace, but no dashes
maxgolov Jul 20, 2020
124ad8b
Make code compile with Visual Studio 2015 (vc140)
maxgolov Jul 27, 2020
77d0612
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Aug 3, 2020
717c7ed
Clean-up warnings for Visual Studio 2015
maxgolov Aug 3, 2020
740dfb9
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Aug 5, 2020
d9a435a
Temporary fix to allow addition of new types in AttributeValue
maxgolov Aug 5, 2020
e4d2171
Clean-up usage of std::memcmp
maxgolov Aug 7, 2020
2f6cb5b
Fix Mac OS X issue with std::get on rvalue
maxgolov Aug 7, 2020
33af4af
Turn off format
maxgolov Aug 7, 2020
a1ab6c7
Use NullKeyValueIterable - it's faster
maxgolov Aug 7, 2020
dac6090
Fix for NullKeyValueIterable
maxgolov Aug 7, 2020
915ee19
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Aug 7, 2020
769afdc
Fix std::get issues with index accessor, change metrics to use nostd.h
maxgolov Aug 7, 2020
86a1eba
Fix Mac OS X clang std::get variant issue
maxgolov Aug 7, 2020
fe9d40e
Split nostd.h into separate headers
maxgolov Aug 12, 2020
d548ed4
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Aug 12, 2020
cb8e437
Update ms-gsl
maxgolov Aug 12, 2020
6f24b21
Remove space
maxgolov Aug 12, 2020
85fa56b
Update vcpkg
maxgolov Aug 12, 2020
3a22787
Print Bazel test errors in console
maxgolov Aug 12, 2020
ebd0727
Fix gcc build issue with std::size_t
maxgolov Aug 12, 2020
4cbdf9e
Add cstring header for std::strlen
maxgolov Aug 12, 2020
2fc1da0
Revert reference change - it breaks on gcc-4.8
maxgolov Aug 12, 2020
420867f
Temporary patch to turn otlp exporter off
maxgolov Aug 12, 2020
611df39
Merge branch 'master' into master
maxgolov Aug 12, 2020
fba85a4
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Aug 28, 2020
0407173
Merge branch 'master' of https://github.com/open-telemetry/openteleme…
maxgolov Sep 3, 2020
17dc5e6
- Update ETWTracer to be compatible with latest mainline changes
maxgolov Sep 3, 2020
8dd6267
- refactor runtime_context.h
maxgolov Sep 3, 2020
9761067
Remove threadlocal_context.h pollution
maxgolov Sep 3, 2020
3cb7423
Add missing header to test/trace/noop_test.cc
maxgolov Sep 3, 2020
90466a7
Add ThreadLocalContext::stack_ to runtime_context_test.cc
maxgolov Sep 3, 2020
6ac7f0e
Add more details to ETW provider example
maxgolov Sep 3, 2020
2c8fbc5
Fix formatting
maxgolov Sep 4, 2020
34a7b0d
Format code
maxgolov Sep 4, 2020
1c725c4
Add verbosity to format tool
maxgolov Sep 4, 2020
4ce4e97
Print list of files before actually crashing :)
maxgolov Sep 4, 2020
4004c2d
Big formatting change (no code changes) to make formatter happy
maxgolov Sep 4, 2020
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
37 changes: 37 additions & 0 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: C/C++ CI on Mac OS X

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
- build/*
pull_request:
branches:
- master
- build/*
schedule:
- cron: 0 2 * * 1-5

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build on ${{ matrix.os }} ${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
config: [release]
os: [macos-latest]
steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Build
run: tools/build.sh ${{ matrix.config }}

- name: Test
run: ./tools/run-tests-all.sh
37 changes: 37 additions & 0 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: C/C++ CI on Ubuntu

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
- build/*
pull_request:
branches:
- master
- build/*
schedule:
- cron: 0 2 * * 1-5

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build on ${{ matrix.os }} ${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
config: [release]
os: [ubuntu-18.04, ubuntu-20.04]
steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Build
run: tools/build.sh ${{ matrix.config }}

- name: Test
run: ./tools/run-tests-all.sh
47 changes: 47 additions & 0 deletions .github/workflows/build-windows-2016.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: C/C++ CI on Windows 2016 (vs2017)

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
- build/*
pull_request:
branches:
- master
- build/*
schedule:
- cron: 0 2 * * 1-5

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build on Windows ${{ matrix.arch }}-${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: [x64]
config: [release]
os: [windows-2016]
steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Setup build tools
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\setup-buildtools.cmd

- name: Build
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\build-vs2017-x64.cmd ${{ matrix.config }}

- name: Test
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\run-tests-all.cmd
47 changes: 47 additions & 0 deletions .github/workflows/build-windows-2019.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: C/C++ CI on Windows 2019 (vs2019)

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
- build/*
pull_request:
branches:
- master
- build/*
schedule:
- cron: 0 2 * * 1-5

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build on Windows ${{ matrix.arch }}-${{ matrix.config }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
arch: [x64]
config: [release]
os: [windows-2019]
steps:

- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Setup build tools
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\setup-buildtools.cmd

- name: Build
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\build-vs2019-x64.cmd ${{ matrix.config }}

- name: Test
run: |
cd "$Env:GITHUB_WORKSPACE"
.\tools\run-tests-all.cmd
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@

# Bazel files
/bazel-*

# Output directories
/out
/out.*
# Indicator that the tools were deployed
.buildtools
# Tools module
/tools/vcpkg
19 changes: 19 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
[submodule "third_party/prometheus-cpp"]
path = third_party/prometheus-cpp
url = https://github.com/jupp0r/prometheus-cpp.git

[submodule "tools/vcpkg"]
path = tools/vcpkg
url = https://github.com/Microsoft/vcpkg
branch = master

[submodule "third_party/ms-gsl"]
path = "third_party/ms-gsl"
url = https://github.com/microsoft/GSL
branch = master
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be picking a specific version of ms-GSL for those who opt-in to it?

it wasn't clear from the repo how folks understand what version they're using and pull in bug fixes.

additionally, if we want to guarantee any kind of ABI/API compat we probably need to know exactly which version is getting linked in when the flag is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right now it's pulling the latest. But since we use submodules - for CMake build we pin-point to specific commit ID. Technically the MS-GSL is only needed for older compilers without C++20 support, i.e. latest-latest Mac and latest gcc-9+ (as well as vs2019 with c++_latest flag) no longer require MS-GSL. As an alternative - I also want to add an option to build with ABSEIL instead of MS-GSL....

Re. pinning in Bazel - I am not sure how to do it. I wonder if we add Abseil, then test the combo of Bazel+Abseil, and CMake+GSL, that'd be covering the most needed build configurations for those who want to build statically. I can add CMake+Abseil build flavor.


[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest
branch = master

[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://github.com/google/benchmark
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()

option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)

option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: if both option are usable or not usable together, should we call that out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsuereth - This is complicated, but I'll try to elaborate :)

  • technically Abseil would be best for vs2015 support, because there is no alternate good variant working with vs2015. Only absl::variant works. The one we borrowed from MPark - nostd::variant - does not compile for vs2015, to be more exact - it has problems with complex aggregate variant types.

  • now Abseil actually requires statically linked library of itself, which I 'hacked' - if we only use Abseil for variant and nothing else. Whereas GSL itself is header-only. In certain environments I'd prefer the full set of everything to be built with Standard Library and, preferably, header-only --- not needing Abseil (e.g. if I compile the OpenTelemetry SDK for inclusion in some Azure cloud Service).

So - it's problematic on all accounts everywhere:

  • nostd::variant - the one we have today, is not compiling on vs2015. The only one compiling is absl::variant
  • absl::variant - if used without any hacks, requires Abseil STATIC lib (messy)
  • whereas GSL only has gsl::span and does not have gsl::variant :(

So -- to answer your question, in my setup I would prefer:

  • just a portion of Abseil for absl::variant (but not the entire Abseil) + MS-GSL for span ... whereas
  • Google projects would probably prefer Abseil for everything ... whereas
  • dynamic libs prefer nostd:: classes... except this won't work for vs2015. We may need to borrow just the variant from Abseil, tweak it so that it doesn't require static linking of the core Abseil, and replace MPark (nostd::variant) with Abseil... Which I wanted to do in a separate PR.

if(WITH_ABSEIL)
add_definitions(-DHAVE_ABSEIL)
find_package(absl CONFIG REQUIRED)
set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city)
# target_link_libraries(main PRIVATE absl::any absl::base absl::bits
# absl::city)
endif()

if(WITH_STL)
# We require at least C++17. C++20 is optimal to avoid gsl::span
add_definitions(-DHAVE_CPP_STDLIB -DHAVE_GSL)
# We ask for 20, but we may get C++17
set(CMAKE_CXX_STANDARD 20)
# Guidelines Support Library path
set(GSL_DIR third_party/ms-gsl)
include_directories(${GSL_DIR}/include)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS_SPEED "/O2")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /Zc:__cplusplus ${CMAKE_CXX_FLAGS_SPEED}")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a")
endif()
endif()

option(WITH_OTPROTOCOL
"Whether to include the OpenTelemetry Protocol in the SDK" OFF)

Expand Down
6 changes: 6 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ install(
if(BUILD_TESTING)
add_subdirectory(test)
endif()

if(WITH_STL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: can we include ABSEIL here too?

message("Building with standard library types...")
else()
message("Building with nostd types...")
endif()
16 changes: 11 additions & 5 deletions api/include/opentelemetry/common/attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@ OPENTELEMETRY_BEGIN_NAMESPACE
namespace common
{
using AttributeValue = nostd::variant<bool,
int,
int32_t,
int64_t,
unsigned int,
uint32_t,
uint64_t,
double,
nostd::string_view,
const char *,
#ifdef HAVE_SPAN_BYTE
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this part of this PR or noise?

If so, are there any concerns around this #ifidef causing compatibility issues with dynamic linking SDKs, or are we ONLY using this in a static-linked manner?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jsuereth - apologies, I'm gonna send another PR from a separate branch to minimize the 'noise'. My master branch contained changes that I needed for some other flows, e.g. byte array support is needed for my internal customer needs, which is logged as an open issue in OT spec (but not implemented yet).

I'll try to answer your questions in the new PR.

nostd::span<const uint8_t>, // TODO: not part of OT spec yet
#endif
nostd::span<const bool>,
nostd::span<const int>,
nostd::span<const int32_t>,
nostd::span<const int64_t>,
nostd::span<const unsigned int>,
nostd::span<const uint32_t>,
nostd::span<const uint64_t>,
nostd::span<const double>,
nostd::span<const nostd::string_view>>;
Expand All @@ -35,7 +39,9 @@ enum AttributeType
TYPE_DOUBLE,
TYPE_STRING,
TYPE_CSTRING,
// TYPE_SPAN_BYTE, // TODO: not part of OT spec yet
#if HAVE_SPAN_BYTE
TYPE_SPAN_BYTE, // TODO: not part of OT spec yet
#endif
TYPE_SPAN_BOOL,
TYPE_SPAN_INT,
TYPE_SPAN_INT64,
Expand Down
5 changes: 3 additions & 2 deletions api/include/opentelemetry/context/context.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstring>
#include "opentelemetry/context/context_value.h"
#include "opentelemetry/nostd/shared_ptr.h"
#include "opentelemetry/nostd/string_view.h"
Expand Down Expand Up @@ -65,7 +66,7 @@ class Context
{
if (key.size() == data->key_length_)
{
if (memcmp(key.data(), data->key_, data->key_length_) == 0)
if (std::memcmp(key.data(), data->key_, data->key_length_) == 0)
{
return data->value_;
}
Expand All @@ -81,7 +82,7 @@ class Context
{
if (key.size() == data->key_length_)
{
if (memcmp(key.data(), data->key_, data->key_length_) == 0)
if (std::memcmp(key.data(), data->key_, data->key_length_) == 0)
{
return true;
}
Expand Down
61 changes: 61 additions & 0 deletions api/include/opentelemetry/context/iruntime_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include "opentelemetry/context/context.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace context
{

// The Token object provides is returned when attaching objects to the
// RuntimeContext object and is associated with a context object, and
// can be provided to the RuntimeContext Detach method to remove the
// associated context from the RuntimeContext.
class Token
{
public:
bool operator==(const Context &other) noexcept { return context_ == other; }

// The ContextDetacher object automatically attempts to detach
// the Token when all copies of the Token are out of scope.
class ContextDetacher
{
public:
ContextDetacher(Context context) : context_(context) {}

~ContextDetacher();

private:
Context context_;
};

Token() noexcept = default;

// A constructor that sets the token's Context object to the
// one that was passed in.
Token(Context context)
{
context_ = context;

detacher_ = nostd::shared_ptr<ContextDetacher>(new ContextDetacher(context_));
};

Context context_;

nostd::shared_ptr<ContextDetacher> detacher_;
};

class IRuntimeContext
{
public:
// Provides a token with the passed in context
Token CreateToken(Context context) noexcept { return Token(context); };

virtual Context InternalGetCurrent() noexcept = 0;

virtual Token InternalAttach(Context context) noexcept = 0;

virtual bool InternalDetach(Token &token) noexcept = 0;
};

} // namespace context
OPENTELEMETRY_END_NAMESPACE
Loading