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

Add apm trace sampling #5492

Merged
merged 5 commits into from
Sep 20, 2024
Merged

Conversation

pchila
Copy link
Member

@pchila pchila commented Sep 10, 2024

What does this PR do?

This PR adds the possibility to specify apm sample rate in elastic agent APM configuration

Why is it important?

Specifying a sample rate allows controlling the ingestion rate, reducing overhead and storage requirements when self-monitoring is active

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@pchila pchila added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Sep 10, 2024
@pchila pchila self-assigned this Sep 10, 2024
Copy link
Contributor

mergify bot commented Sep 10, 2024

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@pchila pchila added backport-8.x Automated backport to the 8.x branch with mergify and removed backport-skip labels Sep 10, 2024
Copy link
Contributor

mergify bot commented Sep 10, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.

Copy link
Contributor

mergify bot commented Sep 10, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b add-apm-trace-sampling upstream/add-apm-trace-sampling
git merge upstream/main
git push upstream add-apm-trace-sampling

@v1v v1v removed the backport-v8.x label Sep 11, 2024
@pchila pchila force-pushed the add-apm-trace-sampling branch 2 times, most recently from 5e6bc04 to 38bd965 Compare September 12, 2024 13:17
@pchila pchila marked this pull request as ready for review September 12, 2024 14:48
@pchila pchila requested a review from a team as a code owner September 12, 2024 14:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

More testing code then actual change code. I appreciate the attention to coverage in this change, well done!

Copy link
Contributor

@andrzej-stencel andrzej-stencel left a comment

Choose a reason for hiding this comment

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

I'm not seeing any validation for the value of SamplingRate. Should there be any? I assume the value of SamplingRate should be a positive number lower than 1?

@pchila
Copy link
Member Author

pchila commented Sep 17, 2024

I'm not seeing any validation for the value of SamplingRate. Should there be any? I assume the value of SamplingRate should be a positive number lower than 1?

According to the APM documentation https://www.elastic.co/guide/en/apm/agent/go/current/configuration.html#config-transaction-sample-rate it should be a float between 0.0 and 1.0

If we have to add a validation also on agent side we would need to rely on ucfg module as we do for all the rest of the config although I would prefer to leave that to any validation performed in the apm module

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
20.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarQube

@ycombinator
Copy link
Contributor

SonarQube is complaining about lines in run.go being not tested; code in this file is not easy to unit test. Force merging...

@ycombinator ycombinator merged commit b284e56 into elastic:main Sep 20, 2024
12 of 13 checks passed
mergify bot pushed a commit that referenced this pull request Sep 20, 2024
* Update elastic-agent-client dependency to 7.16.0

* Add support for APM sampling rate config

* fixup! Add support for APM sampling rate config

* Add unit tests for APM config triggering component changes

* make notice

(cherry picked from commit b284e56)

# Conflicts:
#	go.mod
#	go.sum
pchila added a commit that referenced this pull request Sep 23, 2024
* Update elastic-agent-client dependency to 7.16.0

* Add support for APM sampling rate config

* fixup! Add support for APM sampling rate config

* Add unit tests for APM config triggering component changes

* make notice

(cherry picked from commit b284e56)

# Conflicts:
#	go.mod
#	go.sum
pchila added a commit that referenced this pull request Sep 23, 2024
* Add apm trace sampling (#5492)

* Update elastic-agent-client dependency to 7.16.0

* Add support for APM sampling rate config

* Add unit tests for APM config triggering component changes

(cherry picked from commit b284e56)

---------

Co-authored-by: Paolo Chilà <paolo.chila@elastic.co>
belimawr pushed a commit to belimawr/elastic-agent that referenced this pull request Sep 27, 2024
* Update elastic-agent-client dependency to 7.16.0

* Add support for APM sampling rate config

* fixup! Add support for APM sampling rate config

* Add unit tests for APM config triggering component changes

* make notice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify enhancement New feature or request skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add missing tracing sampling APM config section
6 participants