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

PHOENIX-6699 Phoenix metrics overwriting DefaultMetricsSystem in Regi… #1431

Closed
wants to merge 1 commit into from

Conversation

stoty
Copy link
Contributor

@stoty stoty commented Apr 28, 2022

…onServers

@stoty stoty force-pushed the PHOENIX-6699 branch 3 times, most recently from 956fc17 to 619eb11 Compare April 28, 2022 11:44
@gjacoby126
Copy link
Contributor

@stoty - how does this affect (if at all) server-side metrics such as MetricsIndexerSource and GlobalIndexCheckerSource?

@stoty
Copy link
Contributor Author

stoty commented Apr 29, 2022

@stoty - how does this affect (if at all) server-side metrics such as MetricsIndexerSource and GlobalIndexCheckerSource?

Those should be added the HBase created MetricSystem structure (it's the happy path), but I'm going to do some more testing on a real cluster, and report back.

@stoty
Copy link
Contributor Author

stoty commented May 2, 2022

@joshelser @gjacoby126
Now I was able to test a real cluster with this patch.
The phoenix metrics are added to the HBase metrics just fine, no change.

{
"name": "Hadoop:service=HBase,name=RegionServer,sub=PhoenixIndexer",
"modelerType": "RegionServer,sub=PhoenixIndexer",
"tag.Context": "phoenix",
"tag.Hostname": "stoty-3.stoty.root.hwx.site",
"IndexPrepareTime_num_ops": 2,
"IndexPrepareTime_min": 0,
"IndexPrepareTime_max": 0,

Copy link
Member

@joshelser joshelser left a comment

Choose a reason for hiding this comment

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

Could you write a quick unit test just to validate that this code doesn't throw a runtime exception? Wouldn't want to find out that this reflection gets broken as a result of some well-intended Hadoop change.

I acknowledge that the unit test may be very naive or even contrived -- it'd simply be good to make sure this reflection doesn't throw an exception (and cause some other breakage).


@Test
//Check MetricsSystemImpl has a String "prefix" field in the Hadoop version we test with
public void testInternalMetricsApi() throws NoSuchFieldException,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you have something like this in mind, @elserj ?


@Test
//Check that MetricsSystemImpl has a String "prefix" field in the Hadoop version we test with
public void testInternalMetricsField() throws NoSuchFieldException,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed the test

Comment on lines +60 to +66
MetricsSystemImpl metrics = (MetricsSystemImpl) DefaultMetricsSystem.instance();
Field prefixField = MetricsSystemImpl.class.getDeclaredField("prefix");
prefixField.setAccessible(true);
String oldValue = (String)prefixField.get(metrics);
prefixField.set(metrics, "dummy");
prefixField.set(metrics, oldValue);
prefixField.setAccessible(false);
Copy link
Member

Choose a reason for hiding this comment

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

I was initially just thinking to make this MetricUtil.isDefaultMetricsInitialized() to avoid keeping this unit test aligned with the code in that method. I guess the likelihood of these drifting is low :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isDefaultMetricsInitialized() already has a catch-all section to avoid failing if the API changes, so it cannot really be tested.

@stoty stoty closed this May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants