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