1 /*
2 *
3 * Copyright 2018 gRPC authors.
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
19 #ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_REGISTERED_OPENCENSUS_OBJECTS_H
20 #define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_REGISTERED_OPENCENSUS_OBJECTS_H
21
22 #include <grpc/support/port_platform.h>
23
24 #include "opencensus/stats/stats.h"
25 #include "opencensus/tags/tag_key.h"
26
27 #include "src/cpp/server/load_reporter/constants.h"
28
29 namespace grpc {
30 namespace load_reporter {
31
32 // Note that the functions here are specified as inline to share the static
33 // objects across all the translation units including this header. See more
34 // details on https://en.cppreference.com/w/cpp/language/inline.
35
36 // Measures.
37
MeasureStartCount()38 inline ::opencensus::stats::MeasureInt64 MeasureStartCount() {
39 static const ::opencensus::stats::MeasureInt64 measure =
40 ::opencensus::stats::MeasureInt64::Register(
41 kMeasureStartCount, kMeasureStartCount, kMeasureStartCount);
42 return measure;
43 }
44
MeasureEndCount()45 inline ::opencensus::stats::MeasureInt64 MeasureEndCount() {
46 static const ::opencensus::stats::MeasureInt64 measure =
47 ::opencensus::stats::MeasureInt64::Register(
48 kMeasureEndCount, kMeasureEndCount, kMeasureEndCount);
49 return measure;
50 }
51
MeasureEndBytesSent()52 inline ::opencensus::stats::MeasureInt64 MeasureEndBytesSent() {
53 static const ::opencensus::stats::MeasureInt64 measure =
54 ::opencensus::stats::MeasureInt64::Register(
55 kMeasureEndBytesSent, kMeasureEndBytesSent, kMeasureEndBytesSent);
56 return measure;
57 }
58
MeasureEndBytesReceived()59 inline ::opencensus::stats::MeasureInt64 MeasureEndBytesReceived() {
60 static const ::opencensus::stats::MeasureInt64 measure =
61 ::opencensus::stats::MeasureInt64::Register(kMeasureEndBytesReceived,
62 kMeasureEndBytesReceived,
63 kMeasureEndBytesReceived);
64 return measure;
65 }
66
MeasureEndLatencyMs()67 inline ::opencensus::stats::MeasureInt64 MeasureEndLatencyMs() {
68 static const ::opencensus::stats::MeasureInt64 measure =
69 ::opencensus::stats::MeasureInt64::Register(
70 kMeasureEndLatencyMs, kMeasureEndLatencyMs, kMeasureEndLatencyMs);
71 return measure;
72 }
73
MeasureOtherCallMetric()74 inline ::opencensus::stats::MeasureDouble MeasureOtherCallMetric() {
75 static const ::opencensus::stats::MeasureDouble measure =
76 ::opencensus::stats::MeasureDouble::Register(kMeasureOtherCallMetric,
77 kMeasureOtherCallMetric,
78 kMeasureOtherCallMetric);
79 return measure;
80 }
81
82 // Tags.
83
TagKeyToken()84 inline ::opencensus::tags::TagKey TagKeyToken() {
85 static const ::opencensus::tags::TagKey token =
86 opencensus::tags::TagKey::Register(kTagKeyToken);
87 return token;
88 }
89
TagKeyHost()90 inline ::opencensus::tags::TagKey TagKeyHost() {
91 static const ::opencensus::tags::TagKey token =
92 opencensus::tags::TagKey::Register(kTagKeyHost);
93 return token;
94 }
95
TagKeyUserId()96 inline ::opencensus::tags::TagKey TagKeyUserId() {
97 static const ::opencensus::tags::TagKey token =
98 opencensus::tags::TagKey::Register(kTagKeyUserId);
99 return token;
100 }
101
TagKeyStatus()102 inline ::opencensus::tags::TagKey TagKeyStatus() {
103 static const ::opencensus::tags::TagKey token =
104 opencensus::tags::TagKey::Register(kTagKeyStatus);
105 return token;
106 }
107
TagKeyMetricName()108 inline ::opencensus::tags::TagKey TagKeyMetricName() {
109 static const ::opencensus::tags::TagKey token =
110 opencensus::tags::TagKey::Register(kTagKeyMetricName);
111 return token;
112 }
113
114 } // namespace load_reporter
115 } // namespace grpc
116
117 #endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_REGISTERED_OPENCENSUS_OBJECTS_H \
118 */
119