Skip to content

Support thread pool metric collect#95

Merged
wu-sheng merged 12 commits intoapache:mainfrom
xu1009:feature/support-java-thread-pool
Jan 29, 2022
Merged

Support thread pool metric collect#95
wu-sheng merged 12 commits intoapache:mainfrom
xu1009:feature/support-java-thread-pool

Conversation

@xu1009
Copy link
Copy Markdown
Contributor

@xu1009 xu1009 commented Jan 20, 2022

@wu-sheng
Copy link
Copy Markdown
Member

MeterService is already hosting the created metric. Please read how CounterConstructInterceptor works. And you should reduce unnecessary codes.

@wu-sheng wu-sheng added enhancement New feature or request plugin labels Jan 20, 2022
@wu-sheng wu-sheng added this to the 8.9.0 milestone Jan 20, 2022
@wu-sheng
Copy link
Copy Markdown
Member

BTW, I am asking @mrproliu to enhance the plugin test tool, which will be able to verify metrics, like it did for tracing data.

@mrproliu
Copy link
Copy Markdown
Contributor

BTW, I am asking @mrproliu to enhance the plugin test tool, which will be able to verify metrics, like it did for tracing data.

I have already enhanced it, It could receive the meter data from meter report protocol. If you want to use it, here is the documentation and also have plugin test been used.

@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 24, 2022

the way is to make new thread type add is simple, just get ThreadPoolExecutor instacne and register it, and then, the main metric can be send to the backend

@wu-sheng
Copy link
Copy Markdown
Member

the way is to make new thread type add is simple, just get ThreadPoolExecutor instacne and register it, and then, the main metric can be send to the backend

You just need to create the metric, register it and hold it in the pool object. What we recommended is making your PR easier.

@wu-sheng
Copy link
Copy Markdown
Member

@xu1009 Please take a deep like at our comments. Most things you did have been provided at the core level. Because most of this registration mechanism is a common requirement.

@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 24, 2022

@xu1009 Please take a deep like at our comments. Most things you did have been provided at the core level. Because most of this registration mechanism is a common requirement.

in this way, every new plugin needs to create metirc, i want to extract these common things to core

@wu-sheng
Copy link
Copy Markdown
Member

in this way, every new plugin needs to create metirc, i want to extract these common things to core

What is the issue of creating a metric?
You don't need to consider that. How to create a metric is a core level thing. The plugin should keep all logic simple.
If you want to discuss what core APIs lack, we could work on that separately.

@wu-sheng
Copy link
Copy Markdown
Member

Please fix the CI and add meter plugin test according to the link above. #95 (comment)

@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 24, 2022

ok, i add it lately

@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 24, 2022

the test seems not work in new mac book with m1 cpu

@wu-sheng
Copy link
Copy Markdown
Member

the test seems not work in new mac book with m1 cpu

Yes, we may not have enough images for m1 testing. As most of the team are still using the intel chip.

Could you find a Linux to run this? Or try to locate what is the block(s) in AARM?

@wu-sheng
Copy link
Copy Markdown
Member

Please take a little look at #73, these 2 files should be updated, one for CI, the other for people reading.

image

@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 24, 2022

the test seems not work in new mac book with m1 cpu

Yes, we may not have enough images for m1 testing. As most of the team are still using the intel chip.

Could you find a Linux to run this? Or try to locate what is the block(s) in AARM?

image

not have image, i will try it in other tomorrow, our company has used M1 widely ==

@wu-sheng
Copy link
Copy Markdown
Member

not have image, i will try it in other tomorrow, our company has used M1 widely ==

I see, take a look at https://hub.docker.com/_/eclipse-temurin?tab=tags. AdoptOpenJDK has moved to Eclipse Temurin. I can see AARM images are available there.

FYI @dmsolr

@wu-sheng
Copy link
Copy Markdown
Member

If you will submit any pull request about enhancing M1 testing, please submit through another pull request with detailed steps about running which case locally.
I think I am the only few ppl in the project committer team using the M1 series(M1 Max) chip. I have to verify this locally.

@wu-sheng
Copy link
Copy Markdown
Member

Are you going to update this PR? No update for 3 days.

@wu-sheng wu-sheng removed this from the 8.9.0 milestone Jan 28, 2022
@xu1009
Copy link
Copy Markdown
Contributor Author

xu1009 commented Jan 28, 2022

Are you going to update this PR? No update for 3 days.

sorry, very busy with my own job these days, i am lookig this

@wu-sheng wu-sheng requested a review from mrproliu January 29, 2022 00:01
@wu-sheng wu-sheng added this to the 8.10.0 milestone Jan 29, 2022
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>optional-plugins</artifactId>
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.

Questions,

  1. Should we merge this plugin into the existing undertow tracing plugin?
  2. Should we make it works in default? I can see this is an optional plugin, but a thread pool plugin should not impact the performance, right?

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.

About (1), if you want this plugin to be disabled separately from the tracing plugin, I am fine to keep the codes in another plugin jar. But (2) should be considered.

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.

@xu1009 Please follow this, then we could merge on both sides.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thread pool plugin may impact performance, because it has lock when java get the metric, so it is optional plugin, peoeple really need can add it

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.

The fetching period is 20s, I think it's find to keep it in default.
This lock happens in every getting and returning threads from pool. It is not a big impact.
Agree?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, but the fetching period can be modified by user, if it is set 1s, and the service has high qps, it may impact

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.

Manual setting equals optional plugin. So, don't worry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so we make the plugin in default, an add config control it ?

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.

Moving it to default is enough. Don't need to add a new config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok

mrproliu
mrproliu previously approved these changes Jan 29, 2022
Copy link
Copy Markdown
Contributor

@mrproliu mrproliu left a comment

Choose a reason for hiding this comment

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

LGTM

@wu-sheng wu-sheng merged commit 8e3213b into apache:main Jan 29, 2022
Comment thread CHANGES.md
8.10.0
------------------

* Support Java thread pool metric collect.
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.

This PR only provides thread pool metrics of Undertow, but the change log makes me (and probably other users) feel that we support JDK's thread pool. WDYT @wu-sheng ?

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.

Updated, check the latest codes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I noted that the V9.0.0 just display tomcat thread pool metric. Now I have many customized thread pool which created by "org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor". How can I collect the metric of my thread pool and display it in UI?Is need to write another customized plugins or just need write some config?

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.

Check #146 you may be interested.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I had checked #146 before i asked and i had read the code. The code does not contains any METRIC about "CorePoolSize","MaximumPoolSize".
image

I find a plugin more closer I wanted but hard coded[org.apache.skywalking.apm.plugin.undertow.worker.thread.pool.UndertowWorkerThreadPoolConstructorIntercept]. So I want to konw if i have to write some customized plugin which the count is same to the ThreadPool count?Or have some config more convenient?

image

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.

Why only including two methods, there was a long discussion on that PR, you could check.

You definitely could write a new plugin to do whatever you want, but you should know, that the discussion context is recommended for you before you take action. There are risks to instrument all, which is why we don't do that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, i will check later

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@wu-sheng There are many thread pools in my project, such as ThreadPoolA and ThreadPoolB. If I want to monitor the metrics of these two thread pools separately, do I need to add a new plugin to the agent and two rules to the threadpool.ymal of OAP like:
- name: ThreadPoolA
exp: ThreadPoolA.avg(['metric_type', 'pool_name', 'instance', 'service'])
- name: ThreadPoolB
exp: ThreadPoolB.avg(['metric_type', 'pool_name', 'instance', 'service'])

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.

Learn MAL, your questions are irrelevant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants