YugabyteDB (2.13.1.0-b60, 21121d69985fbf76aa6958d8f04a9bfa936293b5)

Coverage Report

Created: 2022-03-22 16:43

/Users/deen/code/yugabyte-db/ent/src/yb/cdc/cdc_metrics.cc
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  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,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
//
18
// The following only applies to changes made to this file as part of YugaByte development.
19
//
20
// Portions Copyright (c) YugaByte, Inc.
21
//
22
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
23
// in compliance with the License.  You may obtain a copy of the License at
24
//
25
// http://www.apache.org/licenses/LICENSE-2.0
26
//
27
// Unless required by applicable law or agreed to in writing, software distributed under the License
28
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
29
// or implied.  See the License for the specific language governing permissions and limitations
30
// under the License.
31
//
32
#include "yb/cdc/cdc_metrics.h"
33
34
#include "yb/util/metrics.h"
35
#include "yb/util/trace.h"
36
37
38
// CDC Tablet metrics.
39
// Todo(Rahul): Figure out appropriate aggregation functions for these metrics.
40
METRIC_DEFINE_coarse_histogram(cdc, rpc_payload_bytes_responded, "CDC Bytes Responded",
41
  yb::MetricUnit::kBytes,
42
  "Payload size of responses to CDC GetChanges requests (only when records are included)");
43
METRIC_DEFINE_counter(cdc, rpc_heartbeats_responded, "CDC Rpc Heartbeat Count",
44
  yb::MetricUnit::kRequests,
45
  "Number of responses to CDC GetChanges requests without a record payload.");
46
METRIC_DEFINE_gauge_int64(cdc, last_read_opid_term, "CDC Last Read OpId (Term)",
47
  yb::MetricUnit::kOperations,
48
  "ID of the Last Read Producer Operation from a CDC GetChanges request. Format = term.index");
49
METRIC_DEFINE_gauge_int64(cdc, last_read_opid_index, "CDC Last Read OpId (Index)",
50
  yb::MetricUnit::kOperations,
51
  "ID of the Last Read Producer Operation from a CDC GetChanges request. Format = term.index");
52
METRIC_DEFINE_gauge_int64(cdc, last_checkpoint_opid_index, "CDC Last Checkpoint OpId (Index)",
53
  yb::MetricUnit::kOperations,
54
  "ID of the Last Checkpoint Sent by Consumer in a CDC GetChanges request. Format = term.index");
55
METRIC_DEFINE_gauge_uint64(cdc, last_read_hybridtime, "CDC Last Read HybridTime.",
56
  yb::MetricUnit::kMicroseconds,
57
  "HybridTime of the Last Read Operation from a CDC GetChanges request");
58
METRIC_DEFINE_gauge_uint64(cdc, last_read_physicaltime, "CDC Last Read Physical TIme.",
59
  yb::MetricUnit::kMicroseconds,
60
  "Physical Time of the Last Read Operation from a CDC GetChanges request");
61
METRIC_DEFINE_gauge_uint64(cdc, last_checkpoint_physicaltime, "CDC Last Committed Physical Time.",
62
                           yb::MetricUnit::kMicroseconds,
63
                           "Physical Time of the Last Committed Operation on Consumer.");
64
METRIC_DEFINE_gauge_int64(cdc, last_readable_opid_index, "CDC Last Readable OpId (Index)",
65
  yb::MetricUnit::kOperations,
66
  "Index of the Last Producer Operation that a CDC GetChanges request COULD read.");
67
METRIC_DEFINE_gauge_int64(cdc, async_replication_sent_lag_micros, "CDC Physical Time Lag Last Sent",
68
                          yb::MetricUnit::kMicroseconds,
69
                          "Lag between commit time of last record polled and last record applied on"
70
                          "producer.",
71
                          {0, yb::AggregationFunction::kMax} /* optional_args */);
72
METRIC_DEFINE_gauge_int64(cdc, async_replication_committed_lag_micros,
73
                          "CDC Physical Time Lag Last Committed",
74
                          yb::MetricUnit::kMicroseconds,
75
                          "Lag between last record applied on consumer and producer.",
76
                          {0, yb::AggregationFunction::kMax} /* optional_args */);
77
78
// CDC Server Metrics
79
METRIC_DEFINE_counter(server, cdc_rpc_proxy_count, "CDC Rpc Proxy Count", yb::MetricUnit::kRequests,
80
  "Number of CDC GetChanges requests that required proxy forwarding");
81
82
namespace yb {
83
namespace cdc {
84
85
#define MINIT(x) x(METRIC_##x.Instantiate(entity))
86
#define GINIT(x) x(METRIC_##x.Instantiate(entity, 0))
87
CDCTabletMetrics::CDCTabletMetrics(const scoped_refptr<MetricEntity>& entity)
88
    : MINIT(rpc_payload_bytes_responded),
89
      MINIT(rpc_heartbeats_responded),
90
      GINIT(last_read_opid_term),
91
      GINIT(last_read_opid_index),
92
      GINIT(last_checkpoint_opid_index),
93
      GINIT(last_read_hybridtime),
94
      GINIT(last_read_physicaltime),
95
      GINIT(last_checkpoint_physicaltime),
96
      GINIT(last_readable_opid_index),
97
      GINIT(async_replication_sent_lag_micros),
98
      GINIT(async_replication_committed_lag_micros),
99
444
      entity_(entity) {}
100
101
CDCServerMetrics::CDCServerMetrics(const scoped_refptr<MetricEntity>& entity)
102
    : MINIT(cdc_rpc_proxy_count),
103
8.74k
      entity_(entity) { }
104
#undef MINIT
105
#undef GINIT
106
107
} // namespace cdc
108
} // namespace yb