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 preview_datadog_agent_sampling #6112

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from
Open

Conversation

BrynCooke
Copy link
Contributor

@BrynCooke BrynCooke commented Oct 3, 2024

Respect x-datadog-sampling-priority (PR #6017)

This PR consists of two fixes:

Datadog priority sampling resolution is not lost.

Previously a x-datadog-sampling-priority of -1 would be converted to 0 for downstream requests and 2 would be converted to 1.

The sampler option in the telemetry.exporters.tracing.common.sampler is not datadog aware.

To get accurate APM metrics all spans must be sent to the datadog agent with a psr or sampling.priority attribute set appropriately to record the sampling decision.

preview_datadog_agent_sampling option in the router.yaml enables this behavior and should be used when exporting to the datadog agent via OTLP or datadog native.

telemetry:
  exporters:
    tracing:
      common:
        # Only 10 percent of spans will be forwarded from the Datadog agent to Datadog. Experiment to find a value that is good for you!
        sampler: 0.1
        # Send all spans to the Datadog agent. 
        preview_datadog_agent_sampling: true

By using these options, you can decrease your Datadog bill as you will only be sending a percentage of spans from the Datadog agent to datadog.

Important

Users must enable preview_datadog_agent_sampling to get accurate APM metrics.

Important

The Router does not support in-agent ingestion control.
Configuring traces_per_second in the Datadog agent will NOT dynamically adjust the Router's sampling rate to meet the target rate.

Important

Sending all spans to the datadog agent may require that you tweak the batch_processor settings in your exporter config. This applies to both OTLP and the Datadog native exporter.

By @BrynCooke in #6017


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@router-perf
Copy link

router-perf bot commented Oct 3, 2024

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@BrynCooke BrynCooke changed the title Add experimental_datadog_agent_sampling Add preview_datadog_agent_sampling Oct 3, 2024
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Oct 3, 2024

✅ Docs Preview Ready

No new or changed pages found.

This mode will change the behaviour of the router for tracing in the following ways:

* Spans are never dropped, instead they are converted to RecordOnly.
* Spans that are sent to otlp and datadog exporters will always look like they have been sampled.
* The `sampling.priority` attribute is populated on spans.
* `psr` is populated in trace state.
* `m` is populated in trace state.
@BrynCooke BrynCooke marked this pull request as ready for review October 3, 2024 19:18
@BrynCooke BrynCooke requested review from a team as code owners October 3, 2024 19:18
Comment on lines 45 to 46
> [!IMPORTANT]
> Sending all spans to the datadog agent may require that you tweak the `batch_processor` settings in your exporter config. This applies to both OTLP and the Datadog native exporter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also mention potential perf impacts ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

apollo-router/src/plugins/telemetry/mod.rs Outdated Show resolved Hide resolved
@BrynCooke BrynCooke requested a review from shorgi October 4, 2024 09:58
@BrynCooke BrynCooke requested a review from bnjjj October 4, 2024 10:16
.changesets/fix_bryn_datadog_agent_sampling.md Outdated Show resolved Hide resolved
.changesets/fix_bryn_datadog_agent_sampling.md Outdated Show resolved Hide resolved
.changesets/fix_bryn_datadog_agent_sampling.md Outdated Show resolved Hide resolved
.changesets/fix_bryn_datadog_agent_sampling.md Outdated Show resolved Hide resolved
.changesets/fix_bryn_datadog_agent_sampling.md Outdated Show resolved Hide resolved
@BrynCooke
Copy link
Contributor Author

@shorgi Thank you for all the docs improvements!

@BrynCooke BrynCooke force-pushed the bryn/datadog-agent-support branch 2 times, most recently from e792674 to 266ebd9 Compare November 4, 2024 14:27
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.

5 participants