-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to customize default serviceName
in RequestLog
#3232
Comments
serviceName
RequestLogserviceName
in RequestLog
For me, it should be useful for sure. IMHO, not only abbreviation algorithm but also other rules seems good to be flags. For instance,
|
That's a nice suggestion. Are you interested in sending a PR? 😉 |
I hope so. 🤣 I am curious about the preference for this of you. If the user invokes |
I think |
The armeria/core/src/main/java/com/linecorp/armeria/common/logging/DefaultRequestLog.java Lines 1050 to 1068 in 8689584
|
Thanks for the references! Let me take a look more in considering that way. |
Before PR, I would like to share the plan first. First of all, I consider to support For me, the config is supposed to be delivered from
and call like If you mind something, please give me an opinion. |
As you know, users can customize the default
Then, this should be |
I also thought the case that a user uses If we only apply the rule in server level not service level as you said, is it better to name In short, it depends on needs. WDYT? |
You don't have to implement all of these implementations at once. You might want to start by designing an API and add more implementations later. |
A Server.builder()
.route()
.defaultServiceName("foobar")
.serviceNaming(name -> name.substring(...))
.build(new MyService()) Do you have cases that such sophisticated |
I see. It seems that I unnecessarily worried layered |
Motivation - #3232 Provide a way to customize default `serviceName` in RequestLog Modifications - Introduce `ServiceNaming` for per-service naming and global naming. - For per-service naming, `ServiceBindingBuilder#defaultServiceNaming()` is added. - For global naming, `ServerBuilder#defaultServiceNaming()` is added. - To prioritize, `VirtualHost` is used. Result - `ServerBuilder` provides a way to apply a naming rule to the service names globally. - `ServiceBindingBuilder` provides a way to apply a naming rule to the service names under bound services.
Related #3232 #3366 Motivation: - Provide a way to shorten a service name in logging. Modifications: - Implement `ShortenedServiceNameProvider` by using forked [`TargetLengthBasedClassNameAbbreviator`](https://github.com/qos-ch/logback/blob/master/logback-classic/src/main/java/ch/qos/logback/classic/pattern/TargetLengthBasedClassNameAbbreviator.java). - Apply caching to abbreviate. ref. [`CachingAbbreviator`](https://github.com/logstash/logstash-logback-encoder/blob/master/src/main/java/net/logstash/logback/CachingAbbreviator.java). - Introduce `TemporaryThreadLocals.intArray(int)` to reuse the int array in the future. Result: - One more option for `ServiceNaming`, `ServiceNaming.shorten(int)`, to shorten a service name. - `ServiceNaming.shorten()` as a shortcut of `ServiceNaming.shorten(0)`.
Can we close this issue? @ikhoon |
Nice catch! This was fixed by #3453. |
The default
serviceName
of a service is an FQCN of the innermost class.And a
serviceName
could get overridden byctx.logBuilder().name(serviceName, methodName)
.Sometimes, users want to globally change the
serviceName
convention to a simple name of the innermost class.We might provide an option to
ServerBuilder
such as:And we can also provide a built-in abbreviation algorithm like logback's Conversion Word.
The text was updated successfully, but these errors were encountered: