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

Fix JMX Metrics export error #2992

Merged
merged 1 commit into from
Dec 8, 2022
Merged

Fix JMX Metrics export error #2992

merged 1 commit into from
Dec 8, 2022

Conversation

LiYangSir
Copy link
Contributor

…el/issues/2989

Describe what this PR does / why we need it

Fix JMX Metrics export error, Before registering, first escape the special characters [*, ?, ", \n, =, :] in the resource name.

  1. Solve the problem of "cannot add mbean for pattern name" exception thrown during registration, eg [*, ?].
  2. Solve the problem of "invalid character in value part of property" exception when creating ObjectName, eg[", \n, =, :]

Does this pull request fix one issue?

Fixes #2989

Describe how you did it

Escape the resourceName by call "quote" method before creating the registration, escape if the resource name contains special characters, otherwise do nothing.

Describe how to verify it

By installing the new jar package locally and retesting the resource name containing 6 special characters, there is no abnormality in the Record log, and there is no abnormality in the Mbean display.

try (Entry entry = SphU.entry("*HelloWorld")) {
    // Your business logic here.
    System.out.println("hello world");
} catch (BlockException e) {
    // Handle rejected request.
}

image

image

Special notes for reviews

None

@CLAassistant
Copy link

CLAassistant commented Dec 8, 2022

CLA assistant check
All committers have signed the CLA.

@sczyh30 sczyh30 added kind/bug Category issues or prs related to bug. area/metrics Issues or PRs related to metrics and monitoring labels Dec 8, 2022
@sczyh30
Copy link
Member

sczyh30 commented Dec 8, 2022

cc @xiangtianyu @garroshh @BlueSodaWater for review

BlueSodaWater
BlueSodaWater previously approved these changes Dec 8, 2022
@garroshh
Copy link
Contributor

garroshh commented Dec 8, 2022

LGTM

notice:for those special characters,metrics lable value will add “” and \, but that's right.
when i visit http://localhost:8092/*version with special character in browser or visit http://localhost:8092/\*version with special character in cli,generate the metric like fllow pic:

image

@LiYangSir
Copy link
Contributor Author

@garroshh Added string quote and escapes for special character to resource name when there are special characters

Copy link
Member

@sczyh30 sczyh30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@garroshh garroshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sczyh30 sczyh30 merged commit 141d54f into alibaba:master Dec 8, 2022
@sczyh30
Copy link
Member

sczyh30 commented Dec 8, 2022

Thanks for contributing and look forward to more! 👍

LearningGp pushed a commit that referenced this pull request Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics Issues or PRs related to metrics and monitoring kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]Metrics export error when resource name includes '*'
5 participants