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

[#8001] sampling rate can be updated without restarting application #8002

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

yjqg6666
Copy link
Contributor

@yjqg6666 yjqg6666 commented Jul 2, 2021

Resolve #8001.

feature

Make the sampling rate mutable at runtime and can update the sampling rate temporarily.

How to use this feature

Method 1

This is the recommended method if you have 'the cluster feature' enabled.

Query/update the sampling rate from Pinpoint web UI.

The config "config.enable.samplingRate" in web need to be enabled, or all of the rate values would be 'N/A'.

image

Click the cell to edit sampling rate and press 'Enter' to confirm and update.

image

If you are using percent sampling type, the rate can be a decimal (xx.xx), 1(full sampling), 0 (disable sampling).
If you are using counting sampling type, the rate must be an integer (default max 100), 100(full sampling), 0 (disable sampling).

Method 2

This is the only method if you do NOT want to enable the cluster feature.

download arthas

$ curl -O https://arthas.aliyun.com/arthas-boot.jar
$ java -jar arthas-boot.jar <your running app pid>
arthas@pid >

Check the current sampling rate:

arthas > vmtool --action getInstances --classLoaderClass com.navercorp.pinpoint.bootstrap.classloader.ParallelClassLoader --className com.navercorp.pinpoint.profiler.sampler.SamplingRateSampler 

The output:

@SamplingRateSampler[][
@SamplingRateSampler[SamplingRateSampler{counter=12345samplingRate=20}],
]

Update sampling rate to 100%:

arthas > vmtool --action getInstances --classLoaderClass com.navercorp.pinpoint.bootstrap.classloader.ParallelClassLoader --className com.navercorp.pinpoint.profiler.sampler.SamplingRateSampler --express 'instances[0].updateSamplingRate(1)'

The output:

@SamplingRateSampler[][
@SamplingRateSampler[SamplingRateSampler{counter=12378samplingRate=1}],
]

It can also be scripted:

$ java -jar arthas-boot.jar -c 'vmtool --action getInstances --classLoaderClass com.navercorp.pinpoint.bootstrap.classloader.ParallelClassLoader --className com.navercorp.pinpoint.profiler.sampler.SamplingRateSampler --express "instances[0].updateSamplingRate(1)" ' <your running app pid>

Tasks

  • sampling rate is updatable at runtime(without rebooting)
  • sampling rate can be updated through external tool
  • runtime sampling rate can be queried through collector/web by api
  • sampling rate can be updated through collector/web by api
  • sampling rate can be queried/update from web UI.

Changed module

  • profiler
  • agent
  • collector
  • web api
  • web angular/ui
  • grpc
  • thrift (cluster communication)

@yjqg6666
Copy link
Contributor Author

yjqg6666 commented Jul 2, 2021

Since the samplingRate property is changed to volatile, some ignorable performance penalties may be added.

@codecov-commenter
Copy link

codecov-commenter commented Jul 2, 2021

Codecov Report

Merging #8002 (430d496) into master (77e606c) will decrease coverage by 0.35%.
The diff coverage is 100.00%.

❗ Current head 430d496 differs from pull request most recent head db96783. Consider uploading reports for the commit db96783 to get more accurate results

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #8002      +/-   ##
============================================
- Coverage     39.80%   39.44%   -0.36%     
+ Complexity    11478    10930     -548     
============================================
  Files          3364     3158     -206     
  Lines         89754    86833    -2921     
  Branches       9950     9833     -117     
============================================
- Hits          35723    34251    -1472     
+ Misses        50979    49601    -1378     
+ Partials       3052     2981      -71     
Impacted Files Coverage Δ
...orp/pinpoint/profiler/sampler/CountingSampler.java 75.00% <100.00%> (+5.00%) ⬆️
...npoint/test/plugin/util/ThreadContextCallable.java 0.00% <0.00%> (-100.00%) ⬇️
...inpoint/profiler/logging/Log4j2ContextFactory.java 0.00% <0.00%> (-100.00%) ⬇️
...rofiler/logging/EmptyShutdownCallbackRegistry.java 0.00% <0.00%> (-100.00%) ⬇️
...st/plugin/shared/ReflectionDependencyResolver.java 0.00% <0.00%> (-88.00%) ⬇️
...inpoint/profiler/context/StatefulAsyncContext.java 0.00% <0.00%> (-80.00%) ⬇️
...int/profiler/context/DefaultAsyncTraceContext.java 17.64% <0.00%> (-79.23%) ⬇️
...pinpoint/profiler/context/DefaultAsyncContext.java 0.00% <0.00%> (-62.80%) ⬇️
...int/bootstrap/async/AsyncContextAccessorUtils.java 25.00% <0.00%> (-60.72%) ⬇️
...vercorp/pinpoint/bootstrap/agentdir/FileUtils.java 19.44% <0.00%> (-53.89%) ⬇️
... and 890 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77e606c...db96783. Read the comment docs.

@yjqg6666
Copy link
Contributor Author

PR pinpoint-apm/pinpoint-grpc-idl#11 need to be merged and the grpc-idl submodule need to be updated to reference the commit.

@yjqg6666
Copy link
Contributor Author

@emeroad The PR action check would fail if the grpc-idl PR is not merged.

@yjqg6666 yjqg6666 changed the title [#8001] updatable sampling rate (WIP) [#8001] updatable sampling rate Aug 13, 2021
@yjqg6666
Copy link
Contributor Author

@emeroad @binDongKim The feature is completed. PTAL.

@binDongKim I have changed/added some angular code introduced by the commit.

@yjqg6666 yjqg6666 changed the title [#8001] updatable sampling rate [#8001] sampling rate can be updated without restarting application Aug 13, 2021
@yjqg6666
Copy link
Contributor Author

Rebased on the current master.

@emeroad emeroad added this to the 2.4.0 milestone Sep 29, 2021
@yjqg6666
Copy link
Contributor Author

yjqg6666 commented Mar 9, 2022

Rebased on the current master.

@emeroad emeroad modified the milestones: 2.4.0, 2.5.0 Apr 20, 2022
@emeroad emeroad modified the milestones: 2.5.0, 2.5.1 Dec 21, 2022
@emeroad emeroad modified the milestones: 2.5.1, 2.6.0 Apr 11, 2023
@emeroad emeroad modified the milestones: 3.0.0, 3.1.0 May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sampling rate can be updated without restarting application
3 participants