mirror of https://github.com/grpc/grpc-java.git
service: CalMetricRecorder.recordCallMetric is deprecated, use CalMetricRecorder.recordRequestCostMetric (#9410)
This commit is contained in:
parent
1fe3ed9b53
commit
5f1a1d4f35
|
|
@ -141,7 +141,7 @@ public class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {
|
||||||
recorder.recordUtilizationMetric(entry.getKey(), entry.getValue());
|
recorder.recordUtilizationMetric(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, Double> entry : report.getRequestCostMap().entrySet()) {
|
for (Map.Entry<String, Double> entry : report.getRequestCostMap().entrySet()) {
|
||||||
recorder.recordCallMetric(entry.getKey(), entry.getValue());
|
recorder.recordRequestCostMetric(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package io.grpc.services;
|
package io.grpc.services;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.errorprone.annotations.InlineMe;
|
||||||
import io.grpc.Context;
|
import io.grpc.Context;
|
||||||
import io.grpc.ExperimentalApi;
|
import io.grpc.ExperimentalApi;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
@ -92,8 +93,25 @@ public final class CallMetricRecorder {
|
||||||
*
|
*
|
||||||
* @return this recorder object
|
* @return this recorder object
|
||||||
* @since 1.47.0
|
* @since 1.47.0
|
||||||
|
* @deprecated use {@link #recordRequestCostMetric} instead.
|
||||||
|
* This method will be removed in the future.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@InlineMe(replacement = "this.recordRequestCostMetric(name, value)")
|
||||||
public CallMetricRecorder recordCallMetric(String name, double value) {
|
public CallMetricRecorder recordCallMetric(String name, double value) {
|
||||||
|
return recordRequestCostMetric(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Records a call metric measurement for request cost.
|
||||||
|
* If RPC has already finished, this method is no-op.
|
||||||
|
*
|
||||||
|
* <p>A latter record will overwrite its former name-sakes.
|
||||||
|
*
|
||||||
|
* @return this recorder object
|
||||||
|
* @since 1.48.1
|
||||||
|
*/
|
||||||
|
public CallMetricRecorder recordRequestCostMetric(String name, double value) {
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ public class CallMetricRecorderTest {
|
||||||
recorder.recordUtilizationMetric("util1", 154353.423);
|
recorder.recordUtilizationMetric("util1", 154353.423);
|
||||||
recorder.recordUtilizationMetric("util2", 0.1367);
|
recorder.recordUtilizationMetric("util2", 0.1367);
|
||||||
recorder.recordUtilizationMetric("util3", 1437.34);
|
recorder.recordUtilizationMetric("util3", 1437.34);
|
||||||
recorder.recordCallMetric("cost1", 37465.12);
|
recorder.recordRequestCostMetric("cost1", 37465.12);
|
||||||
recorder.recordCallMetric("cost2", 10293.0);
|
recorder.recordRequestCostMetric("cost2", 10293.0);
|
||||||
recorder.recordCallMetric("cost3", 1.0);
|
recorder.recordRequestCostMetric("cost3", 1.0);
|
||||||
recorder.recordCpuUtilizationMetric(0.1928);
|
recorder.recordCpuUtilizationMetric(0.1928);
|
||||||
recorder.recordMemoryUtilizationMetric(47.4);
|
recorder.recordMemoryUtilizationMetric(47.4);
|
||||||
|
|
||||||
|
|
@ -65,11 +65,11 @@ public class CallMetricRecorderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lastValueWinForMetricsWithSameName() {
|
public void lastValueWinForMetricsWithSameName() {
|
||||||
recorder.recordCallMetric("cost1", 3412.5435);
|
recorder.recordRequestCostMetric("cost1", 3412.5435);
|
||||||
recorder.recordCallMetric("cost2", 6441.341);
|
recorder.recordRequestCostMetric("cost2", 6441.341);
|
||||||
recorder.recordCallMetric("cost1", 6441.341);
|
recorder.recordRequestCostMetric("cost1", 6441.341);
|
||||||
recorder.recordCallMetric("cost1", 4654.67);
|
recorder.recordRequestCostMetric("cost1", 4654.67);
|
||||||
recorder.recordCallMetric("cost2", 75.83);
|
recorder.recordRequestCostMetric("cost2", 75.83);
|
||||||
recorder.recordMemoryUtilizationMetric(1.3);
|
recorder.recordMemoryUtilizationMetric(1.3);
|
||||||
recorder.recordMemoryUtilizationMetric(3.1);
|
recorder.recordMemoryUtilizationMetric(3.1);
|
||||||
recorder.recordUtilizationMetric("util1", 28374.21);
|
recorder.recordUtilizationMetric("util1", 28374.21);
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class OrcaMetricReportingServerInterceptorTest {
|
||||||
entry.getValue());
|
entry.getValue());
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, Double> entry : applicationCostMetrics.entrySet()) {
|
for (Map.Entry<String, Double> entry : applicationCostMetrics.entrySet()) {
|
||||||
CallMetricRecorder.getCurrent().recordCallMetric(entry.getKey(),
|
CallMetricRecorder.getCurrent().recordRequestCostMetric(entry.getKey(),
|
||||||
entry.getValue());
|
entry.getValue());
|
||||||
}
|
}
|
||||||
CallMetricRecorder.getCurrent().recordCpuUtilizationMetric(cpuUtilizationMetrics);
|
CallMetricRecorder.getCurrent().recordCpuUtilizationMetric(cpuUtilizationMetrics);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue