NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/includes/opentelemetry/sdk/metrics/view/predicate.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 <vector>
7 #include "opentelemetry/common/macros.h"
8 #include "opentelemetry/nostd/string_view.h"
9 #include "opentelemetry/sdk/common/global_log_handler.h"
10 
11 #if OPENTELEMETRY_HAVE_WORKING_REGEX
12 # include <regex>
13 #endif
14 
16 namespace sdk
17 {
18 namespace metrics
19 {
20 class Predicate
21 {
22 public:
23  virtual ~Predicate() = default;
24  virtual bool Match(opentelemetry::nostd::string_view string) const noexcept = 0;
25 };
26 
27 class PatternPredicate : public Predicate
28 {
29 public:
30  PatternPredicate(opentelemetry::nostd::string_view pattern) : reg_key_{pattern.data()} {}
31  bool Match(opentelemetry::nostd::string_view str) const noexcept override
32  {
33 #if OPENTELEMETRY_HAVE_WORKING_REGEX
34  return std::regex_match(str.data(), reg_key_);
35 #else
36  // TBD - Support regex match for GCC4.8
38  "PatternPredicate::Match - failed. std::regex not fully supported for this compiler.");
39  return false; // not supported
40 #endif
41  }
42 
43 private:
44 #if OPENTELEMETRY_HAVE_WORKING_REGEX
45  std::regex reg_key_;
46 #else
47  std::string reg_key_;
48 #endif
49 };
50 
51 class ExactPredicate : public Predicate
52 {
53 public:
54  ExactPredicate(opentelemetry::nostd::string_view pattern) : pattern_{pattern} {}
55  bool Match(opentelemetry::nostd::string_view str) const noexcept override
56  {
57  if (pattern_ == str)
58  {
59  return true;
60  }
61  return false;
62  }
63 
64 private:
65  std::string pattern_;
66 };
67 
68 class MatchEverythingPattern : public Predicate
69 {
70  bool Match(opentelemetry::nostd::string_view /* str */) const noexcept override { return true; }
71 };
72 
73 class MatchNothingPattern : public Predicate
74 {
75  bool Match(opentelemetry::nostd::string_view /* str */) const noexcept override { return false; }
76 };
77 } // namespace metrics
78 } // namespace sdk
sdk::metrics::ExactPredicate::ExactPredicate
ExactPredicate(opentelemetry::nostd::string_view pattern)
Definition: 9.2/includes/opentelemetry/sdk/metrics/view/predicate.h:54
sdk::metrics::PatternPredicate::Match
bool Match(opentelemetry::nostd::string_view str) const noexcept override
Definition: 9.2/includes/opentelemetry/sdk/metrics/view/predicate.h:31
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
sdk::metrics::Predicate::~Predicate
virtual ~Predicate()=default
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
sdk::metrics::Predicate::Match
virtual bool Match(opentelemetry::nostd::string_view string) const noexcept=0
OTEL_INTERNAL_LOG_ERROR
#define OTEL_INTERNAL_LOG_ERROR(...)
Definition: includes/opentelemetry/sdk/common/global_log_handler.h:171
sdk::metrics::ExactPredicate::Match
bool Match(opentelemetry::nostd::string_view str) const noexcept override
Definition: 9.2/includes/opentelemetry/sdk/metrics/view/predicate.h:55
sdk::metrics::PatternPredicate::PatternPredicate
PatternPredicate(opentelemetry::nostd::string_view pattern)
Definition: 9.2/includes/opentelemetry/sdk/metrics/view/predicate.h:30
sdk
Definition: includes/opentelemetry/sdk/common/atomic_shared_ptr.h:13
metrics
Definition: includes/opentelemetry/metrics/async_instruments.h:10
nostd::string_view
std::string_view string_view
Definition: includes/opentelemetry/std/string_view.h:18