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

feat(rum): propagate sampling decision through tracestate #953

Merged
merged 7 commits into from
Feb 2, 2021

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Jan 25, 2021

  • fix Record sampling weight to transactions/spans and propagate #845
  • Adds a new option propagateTracestate boolean to optionally add the tracestate header to all outgoing requests from the browser that are captured as transactions and spans .
  • sent as sample_rate and sr in both v2 and v3 spec in the APM server.
  • Updated the config doc and also CORS docs.

@apmmachine
Copy link
Contributor

apmmachine commented Jan 25, 2021

📦 Bundlesize report

Filename Size(bundled) Size(gzip) Diff(gzip)
elastic-apm-opentracing.umd.min.js 62.2 KiB 19.8 KiB ⚠️ 147 Bytes
elastic-apm-rum.umd.min.js 56.3 KiB 18.4 KiB ⚠️ 142 Bytes

@apmmachine
Copy link
Contributor

apmmachine commented Jan 25, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #953 updated

    • Start Time: 2021-02-01T19:41:48.336+0000
  • Duration: 68 min 17 sec

  • Commit: ee3e110

Test stats 🧪

Test Results
Failed 0
Passed 1037
Skipped 13
Total 1050

Steps errors 3

Expand to view the steps failures

Run tests: Elastic Stack 7.0.0 - @elastic/apm-rum - none
  • Took 3 min 13 sec . View more details on here
Run tests: Elastic Stack 8.0.0-SNAPSHOT - @elastic/apm-rum-core - saucelabs
  • Took 6 min 57 sec . View more details on here
Error signal
  • Took 0 min 0 sec . View more details on here

Copy link
Contributor

@hmdhk hmdhk left a comment

Choose a reason for hiding this comment

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

Thanks @vigneshshanmugam , a few points:

  • I think we still need some validation for tracestate to avoid sending a large header by mistake or a similar bug (Also adding a test for this)
  • The tests are failing at the moment
  • I will review the spec in a bit more detail and give this another review.

@vigneshshanmugam
Copy link
Member Author

@jahtalab I have added minimum validation for the values that we set, i think it should good to catch bugs that can arise due to bad sampling value. Also added and fixed the tests.

Copy link
Contributor

@hmdhk hmdhk left a comment

Choose a reason for hiding this comment

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

@vigneshshanmugam , I've added a few comments:

The spec mentions this as well, which is currently missing:

For non-sampled transactions set the transaction attributes sampled: false and sample_rate: 0, and omit context. No spans should be captured.

Also, the spec mentions storing the sampe_rate on spans as well, are we relying on apm-server to do this?

Agents will record the sampling rate on transactions and spans as sample_rate

docs/distributed-tracing-guide.asciidoc Outdated Show resolved Hide resolved
packages/rum-core/src/common/utils.js Outdated Show resolved Hide resolved
packages/rum-core/src/common/utils.js Outdated Show resolved Hide resolved
@vigneshshanmugam
Copy link
Member Author

Also, the spec mentions storing the sampe_rate on spans as well, are we relying on apm-server to do this?

I spoke with Server team yesterday and we would have to do this in the agent side for now as they cant infer in v2 API. I will change the code to propagate the info for spans.

@hmdhk
Copy link
Contributor

hmdhk commented Feb 1, 2021

@vigneshshanmugam , would you please take a look at the failing tests as well?

Copy link
Contributor

@hmdhk hmdhk left a comment

Choose a reason for hiding this comment

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

LGTM

@hmdhk hmdhk merged commit 6461364 into elastic:master Feb 2, 2021
@vigneshshanmugam vigneshshanmugam deleted the tracestate-propagation branch February 2, 2021 14:43
David-Development pushed a commit to David-Development/apm-agent-rum-js that referenced this pull request Oct 20, 2021
* feat(rum): propagate sampling decision through tracestate

* chore: fix tests with sampling rate

* docs: update docs with new config and cors

* chore: add validation test and fix tests

* chore: test if repeat function exists

* chore: address review

* chore: keep context as it is
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.

Record sampling weight to transactions/spans and propagate
3 participants