Skip to content

Fix JMX Metrics export error#2992

Merged
sczyh30 merged 1 commit into
alibaba:masterfrom
LiYangSir:fix_jmx_special_character
Dec 8, 2022
Merged

Fix JMX Metrics export error#2992
sczyh30 merged 1 commit into
alibaba:masterfrom
LiYangSir:fix_jmx_special_character

Conversation

@LiYangSir

Copy link
Copy Markdown
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

CLAassistant commented Dec 8, 2022

Copy link
Copy Markdown

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

sczyh30 commented Dec 8, 2022

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

garroshh commented Dec 8, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@sczyh30 sczyh30 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@garroshh garroshh left a comment

Copy link
Copy Markdown
Contributor

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

sczyh30 commented Dec 8, 2022

Copy link
Copy Markdown
Member

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.

5 participants