YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/tablet/tablet_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/tablet/tablet_metrics.h"
33
34
#include "yb/util/metrics.h"
35
36
// Tablet-specific metrics.
37
METRIC_DEFINE_counter(tablet, rows_inserted, "Rows Inserted",
38
    yb::MetricUnit::kRows,
39
    "Number of rows inserted into this tablet since service start");
40
METRIC_DEFINE_counter(tablet, rows_updated, "Rows Updated",
41
    yb::MetricUnit::kRows,
42
    "Number of row update operations performed on this tablet since service start");
43
METRIC_DEFINE_counter(tablet, rows_deleted, "Rows Deleted",
44
    yb::MetricUnit::kRows,
45
    "Number of row delete operations performed on this tablet since service start");
46
47
METRIC_DEFINE_counter(tablet, insertions_failed_dup_key, "Duplicate Key Inserts",
48
                      yb::MetricUnit::kRows,
49
                      "Number of inserts which failed because the key already existed");
50
51
METRIC_DEFINE_coarse_histogram(table, write_op_duration_client_propagated_consistency,
52
  "Write Op Duration with Propagated Consistency",
53
  yb::MetricUnit::kMicroseconds,
54
  "Duration of writes to this tablet with external consistency set to CLIENT_PROPAGATED.");
55
56
METRIC_DEFINE_coarse_histogram(table, snapshot_read_inflight_wait_duration,
57
  "Time Waiting For Snapshot Reads",
58
  yb::MetricUnit::kMicroseconds,
59
  "Time spent waiting for in-flight writes to complete for READ_AT_SNAPSHOT scans.");
60
61
METRIC_DEFINE_coarse_histogram(
62
    table, redis_read_latency, "HandleRedisReadRequest latency", yb::MetricUnit::kMicroseconds,
63
    "Time taken to handle a RedisReadRequest");
64
65
METRIC_DEFINE_coarse_histogram(
66
    table, ql_read_latency, "HandleQLReadRequest latency", yb::MetricUnit::kMicroseconds,
67
    "Time taken to handle a QLReadRequest");
68
69
METRIC_DEFINE_coarse_histogram(
70
    table, write_lock_latency, "Write lock latency", yb::MetricUnit::kMicroseconds,
71
    "Time taken to acquire key locks for a write operation");
72
73
METRIC_DEFINE_gauge_uint32(tablet, compact_rs_running,
74
  "RowSet Compactions Running",
75
  yb::MetricUnit::kMaintenanceOperations,
76
  "Number of RowSet compactions currently running.");
77
78
METRIC_DEFINE_gauge_uint32(tablet, delta_minor_compact_rs_running,
79
  "Minor Delta Compactions Running",
80
  yb::MetricUnit::kMaintenanceOperations,
81
  "Number of delta minor compactions currently running.");
82
83
METRIC_DEFINE_gauge_uint32(tablet, delta_major_compact_rs_running,
84
  "Major Delta Compactions Running",
85
  yb::MetricUnit::kMaintenanceOperations,
86
  "Number of delta major compactions currently running.");
87
88
METRIC_DEFINE_counter(tablet, not_leader_rejections,
89
  "Not Leader Rejections",
90
  yb::MetricUnit::kRequests,
91
  "Number of RPC requests rejected due to fact that this node is not LEADER.");
92
93
METRIC_DEFINE_counter(tablet, leader_memory_pressure_rejections,
94
  "Leader Memory Pressure Rejections",
95
  yb::MetricUnit::kRequests,
96
  "Number of RPC requests rejected due to memory pressure while LEADER.");
97
98
METRIC_DEFINE_counter(tablet, majority_sst_files_rejections,
99
  "Majority SST files number Rejections",
100
  yb::MetricUnit::kRequests,
101
  "Number of RPC requests rejected due to number of majority SST files.");
102
103
METRIC_DEFINE_counter(tablet, transaction_conflicts,
104
  "Distributed Transaction Conflicts",
105
  yb::MetricUnit::kRequests,
106
  "Number of conflicts detected among uncommitted distributed transactions.");
107
108
METRIC_DEFINE_counter(tablet, expired_transactions,
109
  "Expired Distributed Transactions",
110
  yb::MetricUnit::kRequests,
111
  "Number of expired distributed transactions.");
112
113
METRIC_DEFINE_counter(tablet, restart_read_requests,
114
  "Read Requests Requiring Restart",
115
  yb::MetricUnit::kRequests,
116
  "Number of read requests that require restart.");
117
118
METRIC_DEFINE_counter(tablet, consistent_prefix_read_requests,
119
    "Consistent Prefix Read Requests",
120
    yb::MetricUnit::kRequests,
121
    "Number of consistent prefix read requests");
122
123
METRIC_DEFINE_counter(tablet, pgsql_consistent_prefix_read_rows,
124
                      "Consistent Prefix Read Requests",
125
                      yb::MetricUnit::kRequests,
126
                      "Number of pgsql rows read as part of a consistent prefix request");
127
128
METRIC_DEFINE_counter(tablet, tablet_data_corruptions,
129
  "Tablet Data Corruption Detections",
130
  yb::MetricUnit::kUnits,
131
  "Number of times this tablet was flagged for corrupted data");
132
133
using strings::Substitute;
134
135
namespace yb {
136
namespace tablet {
137
138
#define MINIT(entity, x) x(METRIC_##x.Instantiate(entity))
139
TabletMetrics::TabletMetrics(const scoped_refptr<MetricEntity>& table_entity,
140
                             const scoped_refptr<MetricEntity>& tablet_entity)
141
  : MINIT(table_entity, snapshot_read_inflight_wait_duration),
142
    MINIT(table_entity, redis_read_latency),
143
    MINIT(table_entity, ql_read_latency),
144
    MINIT(table_entity, write_lock_latency),
145
    MINIT(table_entity, write_op_duration_client_propagated_consistency),
146
    MINIT(tablet_entity, not_leader_rejections),
147
    MINIT(tablet_entity, leader_memory_pressure_rejections),
148
    MINIT(tablet_entity, majority_sst_files_rejections),
149
    MINIT(tablet_entity, transaction_conflicts),
150
    MINIT(tablet_entity, expired_transactions),
151
    MINIT(tablet_entity, restart_read_requests),
152
    MINIT(tablet_entity, consistent_prefix_read_requests),
153
    MINIT(tablet_entity, pgsql_consistent_prefix_read_rows),
154
    MINIT(tablet_entity, tablet_data_corruptions),
155
88.8k
    MINIT(tablet_entity, rows_inserted) {
156
88.8k
}
157
#undef MINIT
158
159
ScopedTabletMetricsTracker::ScopedTabletMetricsTracker(scoped_refptr<Histogram> latency)
160
3.72M
    : latency_(latency), start_time_(MonoTime::Now()) {}
161
162
3.71M
ScopedTabletMetricsTracker::~ScopedTabletMetricsTracker() {
163
3.71M
  latency_->Increment(MonoTime::Now().GetDeltaSince(start_time_).ToMicroseconds());
164
3.71M
}
165
} // namespace tablet
166
} // namespace yb