Skip to content

Commit

Permalink
Polish gh-5609 (#5752)
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye authored Dec 23, 2024
1 parent 0aaf730 commit 580636c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.core.instrument.binder.grpc;

import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames;

Expand All @@ -27,6 +28,8 @@
*/
public class DefaultGrpcClientObservationConvention implements GrpcClientObservationConvention {

private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN);

@Override
public String getName() {
return "grpc.client";
Expand All @@ -39,9 +42,9 @@ public String getContextualName(GrpcClientObservationContext context) {

@Override
public KeyValues getLowCardinalityKeyValues(GrpcClientObservationContext context) {
String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN;
return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode),
LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
KeyValue statusCodeKeyValue = context.getStatusCode() != null
? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN;
return KeyValues.of(statusCodeKeyValue, LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()),
LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.micrometer.core.instrument.binder.grpc;

import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import io.micrometer.core.instrument.binder.grpc.GrpcObservationDocumentation.LowCardinalityKeyNames;

Expand All @@ -27,6 +28,8 @@
*/
public class DefaultGrpcServerObservationConvention implements GrpcServerObservationConvention {

private static final KeyValue STATUS_CODE_UNKNOWN = LowCardinalityKeyNames.STATUS_CODE.withValue(UNKNOWN);

@Override
public String getName() {
return "grpc.server";
Expand All @@ -39,9 +42,9 @@ public String getContextualName(GrpcServerObservationContext context) {

@Override
public KeyValues getLowCardinalityKeyValues(GrpcServerObservationContext context) {
String statusCode = context.getStatusCode() != null ? context.getStatusCode().name() : UNKNOWN;
return KeyValues.of(LowCardinalityKeyNames.STATUS_CODE.withValue(statusCode),
LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
KeyValue statusCodeKeyValue = context.getStatusCode() != null
? LowCardinalityKeyNames.STATUS_CODE.withValue(context.getStatusCode().name()) : STATUS_CODE_UNKNOWN;
return KeyValues.of(statusCodeKeyValue, LowCardinalityKeyNames.METHOD.withValue(context.getMethodName()),
LowCardinalityKeyNames.SERVICE.withValue(context.getServiceName()),
LowCardinalityKeyNames.METHOD_TYPE.withValue(context.getMethodType().name()));
}
Expand Down

0 comments on commit 580636c

Please sign in to comment.