Skip to content
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

Limit errorMessage length on metrics endpoint #29

Closed
flaviostutz opened this issue May 12, 2021 · 5 comments · Fixed by #33
Closed

Limit errorMessage length on metrics endpoint #29

flaviostutz opened this issue May 12, 2021 · 5 comments · Fixed by #33
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@flaviostutz
Copy link
Member

flaviostutz commented May 12, 2021

On some of our deployments we had a problem with large error messages being used to notify errors because the /metrics endpoint starts to generate too much data on its output, specially if there are lots of different messages being tracked.

My proposal is to limit by default the maximum message output length to 50 chars in order to minimize accidental performance bottlenecks.

For example, the client do

req.setAttribute("error-info", "Some error is going on here, so please be patient while we finish our coffee!")

In this case the related errorMessage will be "Some error is going on here, so please be patient|"
The ending "|" indicates that the message was truncated.

What do you think?

@CarlosPanarello
Copy link

Or use a list of strings separated by comma passed by environment. Other solution will be create an interface/Enum as parameter for message error besides string.

@flaviostutz
Copy link
Member Author

I didn't get it. Could you please write an example?

@CarlosPanarello
Copy link

For example create a environment like this
list_of_errors= keyError1:Error in http request, keyError2:name incorrect , keyError3:invalid data

Then create a class that gets this list and put in some Map to be access with the key parameter.

Or modify they method to add errorMessage to accept only Enum types, this will force to use only strings that will be create at build time.

Ziul added a commit that referenced this issue May 19, 2021
fixes #29 and fixes #30

- support custom regex to filter
- support custom max value
- support to select the correct group of the regex

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>
@flaviostutz
Copy link
Member Author

Could you exercise with some examples of messages, config and result, pls?

@CarlosPanarello
Copy link

Something like this to create a map from a environment
Then we can use this map to get value from key.

 String envs = "keyError1:Error in http request,keyError2:name incorrect,keyError3:invalid data";
        Arrays.stream(envs.split(","))
            .forEach(env -> map.put(env.split(":")[0].trim(), env.split(":" )[1].trim()));

        map.get("keyError1");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants