Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf(proxy): improve metrics performance #526

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@

package com.automq.rocketmq.proxy.grpc;

import apache.rocketmq.v2.AckMessageResponse;
import apache.rocketmq.v2.ChangeInvisibleDurationResponse;
import apache.rocketmq.v2.EndTransactionResponse;
import apache.rocketmq.v2.HeartbeatResponse;
import apache.rocketmq.v2.QueryRouteResponse;
import apache.rocketmq.v2.ReceiveMessageResponse;
import apache.rocketmq.v2.SendMessageResponse;
import apache.rocketmq.v2.Status;
import com.automq.rocketmq.proxy.metrics.ProxyMetricsManager;
import com.automq.rocketmq.proxy.model.ProxyContextExt;
Expand All @@ -38,6 +45,22 @@ protected ProxyContext createContext() {
}

private <T> String getResponseStatus(T response) {
if (response instanceof SendMessageResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof ReceiveMessageResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof AckMessageResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof ChangeInvisibleDurationResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof EndTransactionResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof QueryRouteResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
} else if (response instanceof HeartbeatResponse detailResponse) {
return detailResponse.getStatus().getCode().name().toLowerCase();
}

try {
Method getStatus = response.getClass().getDeclaredMethod("getStatus");
Status status = (Status) getStatus.invoke(response);
Expand Down