NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/context/propagation/text_map_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 "opentelemetry/context/context.h"
7 #include "opentelemetry/nostd/function_ref.h"
8 #include "opentelemetry/nostd/string_view.h"
9 #include "opentelemetry/version.h"
10 
12 namespace context
13 {
14 namespace propagation
15 {
16 
17 // TextMapCarrier is the storage medium used by TextMapPropagator.
19 {
20 public:
21  // returns the value associated with the passed key.
22  virtual nostd::string_view Get(nostd::string_view key) const noexcept = 0;
23 
24  // stores the key-value pair.
25  virtual void Set(nostd::string_view key, nostd::string_view value) noexcept = 0;
26 
27  /* list of all the keys in the carrier.
28  By default, it returns true without invoking callback */
29  virtual bool Keys(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept
30  {
31  return true;
32  }
33  virtual ~TextMapCarrier() = default;
34 };
35 
36 // The TextMapPropagator class provides an interface that enables extracting and injecting
37 // context into carriers that travel in-band across process boundaries. HTTP frameworks and clients
38 // can integrate with TextMapPropagator by providing the object containing the
39 // headers, and a getter and setter function for the extraction and
40 // injection of values, respectively.
41 
43 {
44 public:
45  // Returns the context that is stored in the carrier with the TextMapCarrier as extractor.
46  virtual context::Context Extract(const TextMapCarrier &carrier,
47  context::Context &context) noexcept = 0;
48 
49  // Sets the context for carrier with self defined rules.
50  virtual void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept = 0;
51 
52  // Gets the fields set in the carrier by the `inject` method
53  virtual bool Fields(nostd::function_ref<bool(nostd::string_view)> callback) const noexcept = 0;
54 
55  virtual ~TextMapPropagator() = default;
56 };
57 } // namespace propagation
58 } // namespace context
nostd::function_ref
Definition: includes/opentelemetry/nostd/function_ref.h:17
context::propagation::TextMapCarrier::Keys
virtual bool Keys(nostd::function_ref< bool(nostd::string_view)>) const noexcept
Definition: includes/opentelemetry/context/propagation/text_map_propagator.h:29
context::propagation::TextMapPropagator::Fields
virtual bool Fields(nostd::function_ref< bool(nostd::string_view)> callback) const noexcept=0
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::TextMapPropagator::~TextMapPropagator
virtual ~TextMapPropagator()=default
context::propagation::TextMapCarrier::Set
virtual void Set(nostd::string_view key, nostd::string_view value) noexcept=0
context::propagation::TextMapCarrier::~TextMapCarrier
virtual ~TextMapCarrier()=default
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
context::propagation::TextMapPropagator::Extract
virtual context::Context Extract(const TextMapCarrier &carrier, context::Context &context) noexcept=0
context::propagation::TextMapPropagator::Inject
virtual void Inject(TextMapCarrier &carrier, const context::Context &context) noexcept=0
context::Context
Definition: includes/opentelemetry/context/context.h:23
context::propagation::TextMapCarrier
Definition: includes/opentelemetry/context/propagation/text_map_propagator.h:18
context::propagation::TextMapCarrier::Get
virtual nostd::string_view Get(nostd::string_view key) const noexcept=0
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37