skywalking
skywalking copied to clipboard
[Feature] provides sample option in python agent
Search before asking
- [X] I had searched in the issues and found no similar feature requirement.
Description
Support sample option like SW_AGENT_SAMPLE in java agent
Use case
Reduce the trace storage load
Related issues
#5997
Are you willing to submit a pull request to implement this on your own?
- [X] Yes I am willing to submit a pull request on my own!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
fyi @Superskyyy
Could you briefly describe your idea? Is it possible to dynamically update the value of sample based on the configuration file?
@CodePrometheus I will achieve the function through following tasks:
- Add SW_AGENT_SAMPLE in skywalking/config.py
- Create a
sampling_servicewithtry_sampling,reset_sampling_factorand other methods.try_samplingwill add one to a counter property of sampling_service.reset_sampling_factorwill clear the counter. - Modify skywalking/trace/context.py to check if
sampling_service.try_samplingreturns true every time before creating a new SpanContext. Ifsampling_service.try_samplingreturns false,get_contextshould return NoopContext. - A scheduler thread will be started when initializing a sampling service, it will reset the sampling factor every 3 seconds.
Dynamically updating the value based on the configuration file or environment variables will not be implemented.
Could you briefly describe your idea? Is it possible to dynamically update the value of sample based on the configuration file?
@CodePrometheus Could you be more specific about this? What do you mean based on file?
The above logic seems to be as same as Java agent sampling.
@CodePrometheus Could you be more specific about this? What do you mean based on file?
The above logic seems to be as same as Java agent sampling.
Yes, the above logic is similar to the existing sample_n_per_3_secs in Java agent. I want to refer to dynamic configuration, ref https://github.com/apache/skywalking/issues/6114
I am not sure whether python agent supports dynamic configuration in the kernel already? @Superskyyy
I am not sure whether python agent supports dynamic configuration in the kernel already? @Superskyyy
Currently, this capability is not implemented in python-agent.
@tsonglew Are you going to add this too?
@tsonglew Are you going to add this too?
Yes, I will create another mr for config change events