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

[Feature] provides sample option in python agent #12155

Open
3 tasks done
tsonglew opened this issue Apr 23, 2024 · 9 comments
Open
3 tasks done

[Feature] provides sample option in python agent #12155

tsonglew opened this issue Apr 23, 2024 · 9 comments
Assignees
Labels
agent Language agent related. feature New feature python Python agent related

Comments

@tsonglew
Copy link

Search before asking

  • 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?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

@tsonglew tsonglew added the feature New feature label Apr 23, 2024
@wu-sheng wu-sheng added the python Python agent related label Apr 23, 2024
@wu-sheng
Copy link
Member

fyi @Superskyyy

@wu-sheng wu-sheng added the agent Language agent related. label Apr 23, 2024
@CodePrometheus
Copy link
Contributor

Could you briefly describe your idea? Is it possible to dynamically update the value of sample based on the configuration file?

@tsonglew
Copy link
Author

tsonglew commented May 2, 2024

@CodePrometheus I will achieve the function through following tasks:

  1. Add SW_AGENT_SAMPLE in skywalking/config.py
  2. Create a sampling_service with try_sampling, reset_sampling_factor and other methods. try_sampling will add one to a counter property of sampling_service. reset_sampling_factor will clear the counter.
  3. Modify skywalking/trace/context.py to check if sampling_service.try_sampling returns true every time before creating a new SpanContext. If sampling_service.try_sampling returns false, get_context should return NoopContext.
  4. 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.

@wu-sheng
Copy link
Member

wu-sheng commented May 4, 2024

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

@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 #6114

@wu-sheng
Copy link
Member

wu-sheng commented May 4, 2024

I am not sure whether python agent supports dynamic configuration in the kernel already? @Superskyyy

@CodePrometheus
Copy link
Contributor

I am not sure whether python agent supports dynamic configuration in the kernel already? @Superskyyy

Currently, this capability is not implemented in python-agent.

@wu-sheng
Copy link
Member

wu-sheng commented May 8, 2024

@tsonglew Are you going to add this too?

@tsonglew
Copy link
Author

@tsonglew Are you going to add this too?

Yes, I will create another mr for config change events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent Language agent related. feature New feature python Python agent related
Projects
None yet
Development

No branches or pull requests

3 participants