Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
Loading...
Searching...
No Matches
tracing_options.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright 2020-Present Couchbase, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
21
22#include <chrono>
23#include <cstddef>
24#include <memory>
25
26namespace couchbase
27{
29{
30public:
31 static constexpr std::size_t default_orphaned_sample_size{ 64 };
32 static constexpr std::chrono::milliseconds default_orphaned_emit_interval{ std::chrono::seconds{
33 10 } };
34
35 static constexpr std::size_t default_threshold_sample_size{ 64 };
36 static constexpr std::chrono::milliseconds default_threshold_emit_interval{ std::chrono::seconds{
37 10 } };
38 static constexpr std::chrono::milliseconds default_key_value_threshold{ 500 };
39 static constexpr std::chrono::milliseconds default_query_threshold{ std::chrono::seconds{ 1 } };
40 static constexpr std::chrono::milliseconds default_view_threshold{ std::chrono::seconds{ 1 } };
41 static constexpr std::chrono::milliseconds default_search_threshold{ std::chrono::seconds{ 1 } };
42 static constexpr std::chrono::milliseconds default_analytics_threshold{ std::chrono::seconds{
43 1 } };
44 static constexpr std::chrono::milliseconds default_management_threshold{ std::chrono::seconds{
45 1 } };
46 static constexpr std::chrono::milliseconds default_eventing_threshold{ std::chrono::seconds{
47 1 } };
48
50 {
51 enabled_ = enable;
52 return *this;
53 }
54
55 auto orphaned_emit_interval(std::chrono::milliseconds interval) -> tracing_options&
56 {
57 orphaned_emit_interval_ = interval;
58 return *this;
59 }
60
61 auto orphaned_sample_size(std::size_t number_or_samples) -> tracing_options&
62 {
63 orphaned_sample_size_ = number_or_samples;
64 return *this;
65 }
66
67 auto threshold_emit_interval(std::chrono::milliseconds interval) -> tracing_options&
68 {
69 threshold_emit_interval_ = interval;
70 return *this;
71 }
72
73 auto threshold_sample_size(std::size_t number_or_samples) -> tracing_options&
74 {
75 threshold_sample_size_ = number_or_samples;
76 return *this;
77 }
78
79 auto key_value_threshold(std::chrono::milliseconds duration) -> tracing_options&
80 {
81 key_value_threshold_ = duration;
82 return *this;
83 }
84
85 auto query_threshold(std::chrono::milliseconds duration) -> tracing_options&
86 {
87 query_threshold_ = duration;
88 return *this;
89 }
90
91 auto view_threshold(std::chrono::milliseconds duration) -> tracing_options&
92 {
93 view_threshold_ = duration;
94 return *this;
95 }
96
97 auto search_threshold(std::chrono::milliseconds duration) -> tracing_options&
98 {
99 search_threshold_ = duration;
100 return *this;
101 }
102
103 auto analytics_threshold(std::chrono::milliseconds duration) -> tracing_options&
104 {
105 analytics_threshold_ = duration;
106 return *this;
107 }
108
109 auto management_threshold(std::chrono::milliseconds duration) -> tracing_options&
110 {
111 management_threshold_ = duration;
112 return *this;
113 }
114
115 auto eventing_threshold(std::chrono::milliseconds duration) -> tracing_options&
116 {
117 eventing_threshold_ = duration;
118 return *this;
119 }
120
121 auto tracer(std::shared_ptr<tracing::request_tracer> custom_tracer) -> tracing_options&
122 {
123 tracer_ = std::move(custom_tracer);
124 return *this;
125 }
126
127 struct built {
129 std::chrono::milliseconds orphaned_emit_interval;
131 std::chrono::milliseconds threshold_emit_interval;
133 std::chrono::milliseconds key_value_threshold;
134 std::chrono::milliseconds query_threshold;
135 std::chrono::milliseconds view_threshold;
136 std::chrono::milliseconds search_threshold;
137 std::chrono::milliseconds analytics_threshold;
138 std::chrono::milliseconds management_threshold;
139 std::chrono::milliseconds eventing_threshold;
140 std::shared_ptr<tracing::request_tracer> tracer;
141 };
142
143 [[nodiscard]] auto build() const -> built
144 {
145 return {
146 enabled_,
147 orphaned_emit_interval_,
148 orphaned_sample_size_,
149 threshold_emit_interval_,
150 threshold_sample_size_,
151 key_value_threshold_,
152 query_threshold_,
153 view_threshold_,
154 search_threshold_,
155 analytics_threshold_,
156 management_threshold_,
157 eventing_threshold_,
158 tracer_,
159 };
160 }
161
162private:
163 bool enabled_{ true };
164 std::chrono::milliseconds orphaned_emit_interval_{ default_orphaned_emit_interval };
165 std::size_t orphaned_sample_size_{ default_orphaned_sample_size };
166
167 std::chrono::milliseconds threshold_emit_interval_{ default_threshold_emit_interval };
168 std::size_t threshold_sample_size_{ default_threshold_sample_size };
169 std::chrono::milliseconds key_value_threshold_{ default_key_value_threshold };
170 std::chrono::milliseconds query_threshold_{ default_query_threshold };
171 std::chrono::milliseconds view_threshold_{ default_view_threshold };
172 std::chrono::milliseconds search_threshold_{ default_search_threshold };
173 std::chrono::milliseconds analytics_threshold_{ default_analytics_threshold };
174 std::chrono::milliseconds management_threshold_{ default_management_threshold };
175 std::chrono::milliseconds eventing_threshold_{ default_eventing_threshold };
176
177 std::shared_ptr<tracing::request_tracer> tracer_{ nullptr };
178};
179} // namespace couchbase
Definition tracing_options.hxx:29
auto tracer(std::shared_ptr< tracing::request_tracer > custom_tracer) -> tracing_options &
Definition tracing_options.hxx:121
auto search_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:97
auto orphaned_sample_size(std::size_t number_or_samples) -> tracing_options &
Definition tracing_options.hxx:61
auto threshold_emit_interval(std::chrono::milliseconds interval) -> tracing_options &
Definition tracing_options.hxx:67
auto orphaned_emit_interval(std::chrono::milliseconds interval) -> tracing_options &
Definition tracing_options.hxx:55
auto query_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:85
auto threshold_sample_size(std::size_t number_or_samples) -> tracing_options &
Definition tracing_options.hxx:73
auto enable(bool enable) -> tracing_options &
Definition tracing_options.hxx:49
static constexpr std::size_t default_threshold_sample_size
Definition tracing_options.hxx:35
auto build() const -> built
Definition tracing_options.hxx:143
static constexpr std::chrono::milliseconds default_key_value_threshold
Definition tracing_options.hxx:38
static constexpr std::chrono::milliseconds default_analytics_threshold
Definition tracing_options.hxx:42
static constexpr std::chrono::milliseconds default_view_threshold
Definition tracing_options.hxx:40
auto management_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:109
auto key_value_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:79
auto analytics_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:103
static constexpr std::chrono::milliseconds default_threshold_emit_interval
Definition tracing_options.hxx:36
static constexpr std::chrono::milliseconds default_query_threshold
Definition tracing_options.hxx:39
static constexpr std::chrono::milliseconds default_management_threshold
Definition tracing_options.hxx:44
static constexpr std::chrono::milliseconds default_search_threshold
Definition tracing_options.hxx:41
auto eventing_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:115
static constexpr std::size_t default_orphaned_sample_size
Definition tracing_options.hxx:31
static constexpr std::chrono::milliseconds default_eventing_threshold
Definition tracing_options.hxx:46
auto view_threshold(std::chrono::milliseconds duration) -> tracing_options &
Definition tracing_options.hxx:91
static constexpr std::chrono::milliseconds default_orphaned_emit_interval
Definition tracing_options.hxx:32
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28
Definition tracing_options.hxx:127
std::chrono::milliseconds management_threshold
Definition tracing_options.hxx:138
std::size_t threshold_sample_size
Definition tracing_options.hxx:132
std::chrono::milliseconds analytics_threshold
Definition tracing_options.hxx:137
std::size_t orphaned_sample_size
Definition tracing_options.hxx:130
std::chrono::milliseconds view_threshold
Definition tracing_options.hxx:135
bool enabled
Definition tracing_options.hxx:128
std::chrono::milliseconds search_threshold
Definition tracing_options.hxx:136
std::chrono::milliseconds query_threshold
Definition tracing_options.hxx:134
std::chrono::milliseconds orphaned_emit_interval
Definition tracing_options.hxx:129
std::chrono::milliseconds eventing_threshold
Definition tracing_options.hxx:139
std::chrono::milliseconds threshold_emit_interval
Definition tracing_options.hxx:131
std::shared_ptr< tracing::request_tracer > tracer
Definition tracing_options.hxx:140
std::chrono::milliseconds key_value_threshold
Definition tracing_options.hxx:133