noop_propagator.h 990 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. #pragma once
  4. #include "opentelemetry/context/propagation/text_map_propagator.h"
  5. #include "opentelemetry/version.h"
  6. OPENTELEMETRY_BEGIN_NAMESPACE
  7. namespace context
  8. {
  9. namespace propagation
  10. {
  11. /**
  12. * No-op implementation TextMapPropagator
  13. */
  14. class NoOpPropagator : public TextMapPropagator
  15. {
  16. public:
  17. /** Noop extract function does nothing and returns the input context */
  18. context::Context Extract(const TextMapCarrier & /*carrier*/,
  19. context::Context &context) noexcept override
  20. {
  21. return context;
  22. }
  23. /** Noop inject function does nothing */
  24. void Inject(TextMapCarrier & /*carrier*/,
  25. const context::Context & /* context */) noexcept override
  26. {}
  27. bool Fields(nostd::function_ref<bool(nostd::string_view)> /* callback */) const noexcept override
  28. {
  29. return true;
  30. }
  31. };
  32. } // namespace propagation
  33. } // namespace context
  34. OPENTELEMETRY_END_NAMESPACE