Google Cloud C++ Client  2.7.0
C++ Client Library for Google Cloud Platform
tracing_options.h
Go to the documentation of this file.
1 // Copyright 2020 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACING_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACING_OPTIONS_H
17 
18 #include "google/cloud/version.h"
19 #include <cstdint>
20 #include <string>
21 
22 namespace google {
23 namespace cloud {
25 /**
26  * The configuration parameters for RPC/protobuf tracing.
27  *
28  * The default options are:
29  * single_line_mode=on
30  * use_short_repeated_primitives=on
31  * truncate_string_field_longer_than=128
32  */
34  public:
35  TracingOptions() = default;
36  TracingOptions(TracingOptions const&) = default;
37  TracingOptions& operator=(TracingOptions const&) = default;
40 
41  friend bool operator==(TracingOptions const& a, TracingOptions const& b);
42  friend bool operator!=(TracingOptions const& a, TracingOptions const& b) {
43  return !(a == b);
44  }
45 
46  /// Override the default options with values from @p `str`.
47  TracingOptions& SetOptions(std::string const& str);
48 
49  /// The entire message will be output on a single line with no line breaks.
50  bool single_line_mode() const { return single_line_mode_; }
51 
52  /// Print repeated primitives in a compact format instead of each value on
53  /// its own line.
55  return use_short_repeated_primitives_;
56  }
57 
58  /// If non-zero, truncate all string/bytes fields longer than this.
59  std::int64_t truncate_string_field_longer_than() const {
60  return truncate_string_field_longer_than_;
61  }
62 
63  private:
64  bool single_line_mode_ = true;
65  bool use_short_repeated_primitives_ = true;
66  std::int64_t truncate_string_field_longer_than_ = 128;
67 };
68 
70 } // namespace cloud
71 } // namespace google
72 
73 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_TRACING_OPTIONS_H