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

pkg/trace/stats: support measured spans for trace stats calculation #4866

Merged
merged 1 commit into from
Feb 14, 2020

Conversation

jdgumz
Copy link
Contributor

@jdgumz jdgumz commented Feb 10, 2020

What does this PR do?

Adds support for a _dd.measured flag. This flag can be used to trigger metrics and stats calculations for any span.

Note:
I did not change some of the places where only top-level spans are considered. E.g.,

I have also left the legacy APM event extractor untouched, so it will continue to only process top-level spans:

if !traceutil.HasTopLevel(s) {

Motivation

To allow more spans than just top-level ones to be included for measurement.

@bits-bot
Copy link
Collaborator

bits-bot commented Feb 10, 2020

CLA assistant check
All committers have signed the CLA.

@jdgumz jdgumz requested a review from a team as a code owner February 10, 2020 17:28
@jdgumz jdgumz changed the title Apm/support measured span flag for stats computation [APM] support measured span flag for stats computation Feb 10, 2020
release.json Outdated Show resolved Hide resolved
pkalmakis
pkalmakis previously approved these changes Feb 11, 2020
Copy link
Contributor

@pkalmakis pkalmakis left a comment

Choose a reason for hiding this comment

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

The application code changes are simple enough and seem logical. I think it would be better if you changed less of the test code though, as others will have a higher level of confidence that this change hasn't broken existing functionality.

@gbbr gbbr added the team/agent-apm trace-agent label Feb 12, 2020
@gbbr gbbr added this to the 7.18.0 milestone Feb 12, 2020
pkg/trace/traceutil/span.go Outdated Show resolved Hide resolved
pkg/trace/traceutil/span.go Outdated Show resolved Hide resolved
pkg/trace/traceutil/span.go Show resolved Hide resolved
pkg/trace/traceutil/span.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
@gbbr gbbr changed the title [APM] support measured span flag for stats computation pkg/trace/stats: support measured span flag for stats computation Feb 12, 2020
Copy link
Contributor Author

@jdgumz jdgumz left a comment

Choose a reason for hiding this comment

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

@pkalmakis @gbbr

Thank you for the great feedback! I've made the following changes:

  • Use Span.Metrics to look for _dd.measured.
  • Revert the addition of new test cases to old tests. Now the only changes to old tests are things to help clean up in some small ways (like using countValsEq).
  • Added table-driven tests for new tests that evaluate the measured span-related behavior.
  • I did not include tests for flushing logic with measured spans. I do not believe the flushing code considers top-level spans specifically. Sublayer calculation does however, which is why I wanted that test coverage.

pkg/trace/stats/concentrator_test.go Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes Jesse. This is starting to look a bit better but please bear with me while we iron out all the details. I would also like to kindly ask you to abstain from sprinkling notes as comments all over the PR as these are not helping (quite the opposite). They are distracting from the review. I think most reviewers (including myself) prefer a clean page of code to look at. If anything is unclear or feels like it needs explaining, people generally tend to ask (example)...

Generally, when reviewing, I prefer to read the code as it would be read by someone looking at it in the codebase, where no PR comments exist.

pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Show resolved Hide resolved
pkg/trace/stats/concentrator_test.go Outdated Show resolved Hide resolved
@gbbr
Copy link
Contributor

gbbr commented Feb 13, 2020

Forgot to say: you'll have to use reno to create the release notes. They need to be prefixed with APM :, something like:

---
features:
    - |
      APM: Add support for computing statistics on user-selected spans.

This change supports calculating trace statistics on measured spans selected by the user.
The trace-agent can now compute trace statistics for both top-level and measured spans.
@jdgumz jdgumz changed the title pkg/trace/stats: support measured span flag for stats computation pkg/trace/stats: support measured spans for trace stats computation Feb 13, 2020
@jdgumz jdgumz changed the title pkg/trace/stats: support measured spans for trace stats computation pkg/trace/stats: support measured spans for trace stats calculation Feb 13, 2020
@jdgumz jdgumz force-pushed the apm/support-measured-span-flag-for-stats-computation branch from bf1e6b1 to b996002 Compare February 13, 2020 17:12
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for bearing through the iterations.

@gbbr gbbr merged commit 3ea70de into master Feb 14, 2020
@gbbr gbbr deleted the apm/support-measured-span-flag-for-stats-computation branch February 14, 2020 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team/agent-apm trace-agent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants