Skip to content

Commit

Permalink
[PLAT-13773] Add event type grouping to ASH
Browse files Browse the repository at this point in the history
Summary: Support grouping by event type for ASH graphs

Test Plan: unit tested + tested manually.

Reviewers: rmadhavan

Reviewed By: rmadhavan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D34740
  • Loading branch information
anmalysh-yb committed May 3, 2024
1 parent e13c915 commit 0b840d6
Show file tree
Hide file tree
Showing 18 changed files with 359 additions and 639 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,26 @@ public class ActiveSessionHistory extends Model {
private String waitEventClass;

@CsvField(pos = 8)
private String waitEventType;

@CsvField(pos = 9)
private String waitEvent;

@CsvField(pos = 9, converterType = UuidConverter.class)
@CsvField(pos = 10, converterType = UuidConverter.class)
private UUID topLevelNodeId;

@CsvField(pos = 10)
@CsvField(pos = 11)
private Long queryId;

@CsvField(pos = 11)
@CsvField(pos = 12)
private Long ysqlSessionId;

@CsvField(pos = 12)
@CsvField(pos = 13)
private String clientNodeIp;

@CsvField(pos = 13)
@CsvField(pos = 14)
private String waitEventAux;

@CsvField(pos = 14)
@CsvField(pos = 15)
private int sampleWeight;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class GraphData {
private String type;
private String waitEventComponent;
private String waitEventClass;
private String waitEventType;
private String waitEvent;
private Map<String, String> labels;
@JsonIgnore private List<GraphPoint> points = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum GraphLabel {
mountPoint("mountpoint"),
waitEventComponent(""),
waitEventClass(""),
waitEventType(""),
waitEvent(""),
clientNodeIp("");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ public GraphResponse getGraph(
graphData.setWaitEventClass(
key.getLabels().remove(GraphLabel.waitEventClass.name()));
}
if (key.getLabels().containsKey(GraphLabel.waitEventType.name())) {
graphData.setWaitEventType(key.getLabels().remove(GraphLabel.waitEventType.name()));
}
if (key.getLabels().containsKey(GraphLabel.waitEvent.name())) {
graphData.setWaitEvent(key.getLabels().remove(GraphLabel.waitEvent.name()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public class ActiveSessionHistoryQuery {

static final String ASH_QUERY_NO_TIMESTAMP =
"select sample_time, root_request_id, rpc_request_id, wait_event_component, wait_event_class,"
+ " wait_event, top_level_node_id, query_id, ysql_session_id, client_node_ip,"
+ " wait_event_aux, sample_weight from pg_catalog.yb_active_session_history";
+ " wait_event_type, wait_event, top_level_node_id, query_id, ysql_session_id,"
+ " client_node_ip, wait_event_aux, sample_weight"
+ " from pg_catalog.yb_active_session_history";

static final String ASH_SAMPLE_TIME_FILTER = " where sample_time >= ";

Expand All @@ -61,6 +62,7 @@ public class ActiveSessionHistoryQuery {
private static final String PRC_REQUEST_ID = "rpc_request_id";
private static final String WAIT_EVENT_COMPONENT = "wait_event_component";
private static final String WAIT_EVENT_CLASS = "wait_event_class";
private static final String WAIT_EVENT_TYPE = "wait_event_type";
private static final String WAIT_EVENT = "wait_event";
private static final String TOP_LEVEL_NODE_ID = "top_level_node_id";
private static final String QUERY_ID = "query_id";
Expand Down Expand Up @@ -232,6 +234,7 @@ private NodeProcessResult processNode(
.setRootRequestId(UUID.fromString(statsJson.get(ROOT_REQUEST_ID).asText()))
.setWaitEventComponent(statsJson.get(WAIT_EVENT_COMPONENT).asText())
.setWaitEventClass(statsJson.get(WAIT_EVENT_CLASS).asText())
.setWaitEventType(statsJson.get(WAIT_EVENT_TYPE).asText())
.setWaitEvent(statsJson.get(WAIT_EVENT).asText())
.setTopLevelNodeId(UUID.fromString(statsJson.get(TOP_LEVEL_NODE_ID).asText()))
.setQueryId(statsJson.get(QUERY_ID).asLong())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE active_session_history ADD COLUMN wait_event_type TEXT;

Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ active_session_history_tserver:
waitEventClass:
name: wait_event_class
assumesGroupBy: ["waitEventComponent"]
waitEventType:
name: wait_event_type
defaultGroupBy: true
assumesGroupBy: ["waitEventComponent"]
waitEvent:
name: wait_event
defaultGroupBy: true
assumesGroupBy: ["waitEventClass", "waitEventComponent"]
additional_filter: "ysql_session_id != 0"
data_columns:
Expand All @@ -123,6 +126,8 @@ active_session_history_tserver:
type: "date"
metadata:
supportedGroupBy:
- label: waitEventType
name: Type
- label: waitEvent
name: Event
- label: waitEventClass
Expand Down Expand Up @@ -158,9 +163,12 @@ active_session_history_ysql:
waitEventClass:
name: wait_event_class
assumesGroupBy: ["waitEventComponent"]
waitEventType:
name: wait_event_type
defaultGroupBy: true
assumesGroupBy: ["waitEventComponent"]
waitEvent:
name: wait_event
defaultGroupBy: true
assumesGroupBy: ["waitEventClass", "waitEventComponent"]
additional_filter: "ysql_session_id != 0"
data_columns:
Expand All @@ -174,6 +182,8 @@ active_session_history_ysql:
type: "date"
metadata:
supportedGroupBy:
- label: waitEventType
name: Type
- label: waitEvent
name: Event
- label: waitEventClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,23 @@ public void setUp() {
pgStatStatementsService.save(createStatements("node2", 1L, 30));
pgStatStatementsService.save(createStatements("node3", 1L, 30));
activeSessionHistoryService.save(
createAshEntries("node1", "TServer", "Consensus", "WAL_Sync", 1L, "0.0.0.0", 50));
createAshEntries(
"node1", "TServer", "Consensus", "Network", "WAL_Sync", 1L, "0.0.0.0", 50));
activeSessionHistoryService.save(
createAshEntries("node1", "YSQL", "YSQLQuery", "QueryProcessing", 200L, "1.1.1.1", 30));
createAshEntries(
"node1", "YSQL", "YSQLQuery", "Network", "QueryProcessing", 200L, "1.1.1.1", 30));
activeSessionHistoryService.save(
createAshEntries("node1", "YSQL", "TServerWait", "CatalogRead", 200L, "1.1.1.1", 50));
createAshEntries(
"node1", "YSQL", "TServerWait", "Network", "CatalogRead", 200L, "1.1.1.1", 50));
activeSessionHistoryService.save(
createAshEntries("node2", "TServer", "Consensus", "WAL_Sync", 1L, "0.0.0.0", 30));
createAshEntries(
"node2", "TServer", "Consensus", "Network", "WAL_Sync", 1L, "0.0.0.0", 30));
activeSessionHistoryService.save(
createAshEntries("node2", "YSQL", "YSQLQuery", "QueryProcessing", 200L, "2.2.2.2", 50));
createAshEntries(
"node2", "YSQL", "YSQLQuery", "Network", "QueryProcessing", 200L, "2.2.2.2", 50));
activeSessionHistoryService.save(
createAshEntries("node2", "YSQL", "TServerWait", "CatalogRead", 300L, "2.2.2.2", 50));
createAshEntries(
"node2", "YSQL", "TServerWait", "Network", "CatalogRead", 300L, "2.2.2.2", 50));

server = MockRestServiceServer.createServer(prometheusClientTemplate);
}
Expand Down Expand Up @@ -484,6 +490,7 @@ private List<ActiveSessionHistory> createAshEntries(
String nodeName,
String waitEventComponent,
String waitEventClass,
String waitEventType,
String waitEvent,
long queryId,
String clientNodeIp,
Expand All @@ -496,6 +503,7 @@ private List<ActiveSessionHistory> createAshEntries(
nodeName,
waitEventComponent,
waitEventClass,
waitEventType,
waitEvent,
queryId,
clientNodeIp))
Expand All @@ -507,6 +515,7 @@ private ActiveSessionHistory createAshEntry(
String nodeName,
String waitEventComponent,
String waitEventClass,
String waitEventType,
String waitEvent,
long queryId,
String clientNodeIp) {
Expand All @@ -518,6 +527,7 @@ private ActiveSessionHistory createAshEntry(
.setRpcRequestId(new Random().nextLong())
.setWaitEventComponent(waitEventComponent)
.setWaitEventClass(waitEventClass)
.setWaitEventType(waitEventType)
.setWaitEvent(waitEvent)
.setTopLevelNodeId(UUID.randomUUID())
.setQueryId(queryId)
Expand Down

0 comments on commit 0b840d6

Please sign in to comment.