-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,657 additions
and
113 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile clean | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
mkdir -p doxyoutput | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
clean: | ||
rm -rf doxyoutput | ||
@$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file was deleted.
Oops, something went wrong.
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,84 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
# import os | ||
# import sys | ||
# sys.path.insert(0, os.path.abspath('.')) | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'OpenTelemetry C++ API' | ||
copyright = '2021, OpenTelemetry authors' | ||
author = 'OpenTelemetry authors' | ||
|
||
# Run doxygen | ||
# ----------- | ||
# For the readthedocs builds, for some reason exhale doesn't find doxygen. | ||
# So we run it manually here. | ||
import subprocess | ||
import os | ||
if not os.path.isdir('doxyoutput'): | ||
os.mkdir('doxyoutput') | ||
subprocess.call(['doxygen']) | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"breathe", | ||
"exhale", | ||
] | ||
|
||
breathe_projects = { | ||
"OpenTelemetry C++ API": "./doxyoutput/xml" | ||
} | ||
|
||
breathe_default_project = "OpenTelemetry C++ API" | ||
|
||
exhale_args = { | ||
"containmentFolder": "otel_api", | ||
"rootFileName": "otel_api.rst", | ||
"rootFileTitle": "Reference documentation", | ||
"doxygenStripFromPath": "..", | ||
"exhaleUseDoxyfile": True, | ||
"createTreeView": True, | ||
} | ||
|
||
primary_domain = "cpp" | ||
|
||
higlight_language = "cpp" | ||
|
||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = "sphinx_rtd_theme" | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] |
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,2 @@ | ||
OpenTelemetry C++ API | ||
===================== |
83 changes: 83 additions & 0 deletions
83
api/include/opentelemetry/trace/propagation/composite_propagator.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,83 @@ | ||
#include <initializer_list> | ||
#include <memory> | ||
#include <vector> | ||
#include "opentelemetry/trace/propagation/text_map_propagator.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace trace | ||
{ | ||
namespace propagation | ||
{ | ||
|
||
template <typename T> | ||
class CompositePropagator : public TextMapPropagator<T> | ||
{ | ||
public: | ||
CompositePropagator(std::vector<std::unique_ptr<TextMapPropagator<T>>> propagators) | ||
: propagators_(std::move(propagators)) | ||
{} | ||
// Rules that manages how context will be extracted from carrier. | ||
using Getter = nostd::string_view (*)(const T &carrier, nostd::string_view trace_type); | ||
|
||
// Rules that manages how context will be injected to carrier. | ||
using Setter = void (*)(T &carrier, | ||
nostd::string_view trace_type, | ||
nostd::string_view trace_description); | ||
|
||
/** | ||
* Run each of the configured propagators with the given context and carrier. | ||
* Propagators are run in the order they are configured, so if multiple | ||
* propagators write the same carrier key, the propagator later in the list | ||
* will "win". | ||
* | ||
* @param setter Rules that manages how context will be injected to carrier. | ||
* @param carrier Carrier into which context will be injected | ||
* @param context Context to inject | ||
* | ||
*/ | ||
|
||
void Inject(Setter setter, T &carrier, const context::Context &context) noexcept override | ||
{ | ||
for (auto &p : propagators_) | ||
{ | ||
p->Inject(setter, carrier, context); | ||
} | ||
} | ||
|
||
/** | ||
* Run each of the configured propagators with the given context and carrier. | ||
* Propagators are run in the order they are configured, so if multiple | ||
* propagators write the same context key, the propagator later in the list | ||
* will "win". | ||
* | ||
* @param setter Rules that manages how context will be extracte from carrier. | ||
* @param context Context to add values to | ||
* @param carrier Carrier from which to extract context | ||
*/ | ||
context::Context Extract(Getter getter, | ||
const T &carrier, | ||
context::Context &context) noexcept override | ||
{ | ||
auto first = true; | ||
context::Context tmp_context; | ||
for (auto &p : propagators_) | ||
{ | ||
if (first) | ||
{ | ||
tmp_context = p->Extract(getter, carrier, context); | ||
first = false; | ||
} | ||
else | ||
{ | ||
tmp_context = p->Extract(getter, carrier, tmp_context); | ||
} | ||
} | ||
return propagators_.size() ? tmp_context : context; | ||
} | ||
|
||
private: | ||
std::vector<std::unique_ptr<TextMapPropagator<T>>> propagators_; | ||
}; | ||
} // namespace propagation | ||
} // namespace trace | ||
OPENTELEMETRY_END_NAMESPACE; |
Oops, something went wrong.