NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/context/propagation/composite_propagator.h
Go to the documentation of this file.
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include <memory>
7 #include <vector>
8 
9 #include "opentelemetry/context/propagation/text_map_propagator.h"
10 #include "opentelemetry/version.h"
11 
13 namespace context
14 {
15 namespace propagation
16 {
17 
19 {
20 public:
21  CompositePropagator(std::vector<std::unique_ptr<TextMapPropagator>> propagators)
22  : propagators_(std::move(propagators))
23  {}
24 
36  void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
37  {
38  for (auto &p : propagators_)
39  {
40  p->Inject(carrier, context);
41  }
42  }
43 
54  context::Context &context) noexcept override
55  {
56  auto first = true;
57  context::Context tmp_context;
58  for (auto &p : propagators_)
59  {
60  if (first)
61  {
62  tmp_context = p->Extract(carrier, context);
63  first = false;
64  }
65  else
66  {
67  tmp_context = p->Extract(carrier, tmp_context);
68  }
69  }
70  return propagators_.size() ? tmp_context : context;
71  }
72 
78  bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept override
79  {
80  bool status = true;
81  for (auto &p : propagators_)
82  {
83  status = status && p->Fields(callback);
84  }
85  return status;
86  }
87 
88 private:
89  std::vector<std::unique_ptr<TextMapPropagator>> propagators_;
90 };
91 } // namespace propagation
92 } // namespace context
context::propagation::CompositePropagator::Fields
bool Fields(nostd::function_ref< bool(nostd::string_view)> callback) const noexcept override
Invoke callback with fields set to carrier by inject method for all the configured propagators Return...
Definition: includes/opentelemetry/context/propagation/composite_propagator.h:78
nostd::function_ref
Definition: includes/opentelemetry/nostd/function_ref.h:17
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
context
Definition: includes/opentelemetry/context/context.h:16
context::propagation::TextMapPropagator
Definition: includes/opentelemetry/context/propagation/text_map_propagator.h:42
context::propagation::CompositePropagator::CompositePropagator
CompositePropagator(std::vector< std::unique_ptr< TextMapPropagator >> propagators)
Definition: includes/opentelemetry/context/propagation/composite_propagator.h:21
context::propagation::CompositePropagator::Inject
void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept override
Run each of the configured propagators with the given context and carrier.
Definition: includes/opentelemetry/context/propagation/composite_propagator.h:36
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
absl::move
constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t< T > && move(T &&t) noexcept
Definition: includes/opentelemetry/nostd/internal/absl/utility/utility.h:199
context::propagation::CompositePropagator
Definition: includes/opentelemetry/context/propagation/composite_propagator.h:18
context::propagation::CompositePropagator::Extract
context::Context Extract(const TextMapCarrier &carrier, context::Context &context) noexcept override
Run each of the configured propagators with the given context and carrier.
Definition: includes/opentelemetry/context/propagation/composite_propagator.h:53
std
Extensions to the C++ standard library.
Definition: includes/opentelemetry/nostd/string_view.h:212
context::Context
Definition: includes/opentelemetry/context/context.h:23
context::propagation::TextMapCarrier
Definition: includes/opentelemetry/context/propagation/text_map_propagator.h:18
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37