Originally suggested by @okue
It'd be nice to have a dedicated MeterIdPrefixFunction implementation for gRPC, so that the tag for grpc-status is added automatically.
To make MeterIdPrefixFunction easier to customize,
how about adding some functions to MeterIdPrefixFunction?
static MeterIdPrefixFunction ofDefault(
String name,
BiConsumer<MeterRegistry, ? super RequestOnlyLog> consumer
) {
...
}
or
default MeterIdPrefixFunction andThen(
Function3<MeterRegistry, ? super RequestOnlyLog, MeterIdPrefix, MeterIdPrefix> consumer
) {
...
}
That's a good idea. I like the latter. What do you think, @line/dx?
I also prefer the andThen version. But Java does not have Function3 or triple function. We might need a customizer interface.
Now, we can set grpc-status to MeterIdPrefix easily using MeterIdPrefixFunction#andThen(MeterIdPrefixFunctionCustomizer).
BTW, is it better to offer GrpcMeterIdPrefixFunction?
If so, should GrpcMeterIdPrefixFunction use andThen, or optimize something..?
That's a good question. I think it will be useful to provide one out of the box. It'd be nice if we have an optimized version, but we will have to refactor a little bit to de-duplicate the common logic from the default prefix function. Alternatively, we could duplicate a little bit and just write some tight test cases.
I prefer GrpcMeterIdPrefixFunction because grpc-status can be gotten from:
How could we get the grpc-status trailer from a gRPC-Web response?
Probably worth getting this done before 1.0 to solve the gRPC-Web trailer handling problem..
Let me work on this after finishing #2911
When using gRPC with armeria-spring-boot, all services are decorated with MeterIdPrefixFunction.ofDefault.
I'd be happy if GrpcMeterIdPrefixFunction is used for gRPC services.