canvas-lms/app/middleware
Isaac Moore dba611db24 Improve Sentry APM sampling decisions
Some clients calling Canvas are including their own sentry-trace header,
which is a header designed to associate traces from multiple services
together; if that header is present, Sentry decides that the transaction
should be sampled to maintain the association.

This change discards the `sentry-trace` header unless there is also a
`Referrer` header which contains the same host the request is for.

This change also switches to using a proc to define the APM sample rate,
which will allow the sample rate to be updated without restarting app
servers.

flag=none
closes DE-1029, DE-1028

test plan:
- verify that tracing can still be enabled/disabled by modifying the
  sampling rate
- verify that calling Canvas with a `sentry-trace` header does not
  override the sampling rate, unless a same-origin `Referrer` header is
  also present

Change-Id: Iddc80c3234975db0e45fa8defcba8eda1f4e0d24
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284485
Reviewed-by: Ryan Norton <rnorton@instructure.com>
Product-Review: Ryan Norton <rnorton@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-02-05 00:17:52 +00:00
..
request_throttle bound request throttle leaking _before_ adding cost of current request 2017-09-19 22:39:09 +00:00
load_account.rb RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00
prevent_non_multipart_parse.rb RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00
request_context_generator.rb add frozen_string_literal_comment to remaining app files 2021-03-30 17:51:08 +00:00
request_context_session.rb add frozen_string_literal_comment to remaining app files 2021-03-30 17:51:08 +00:00
request_throttle.rb rename Canvas::DynamicSettings => DynamicSettings 2022-01-12 21:54:51 +00:00
samesite_transition_cookie_store.rb RuboCop: Lint/UnusedMethodArgument partial 2021-10-21 13:39:12 +00:00
sentry_trace_scrubber.rb Improve Sentry APM sampling decisions 2022-02-05 00:17:52 +00:00
sessions_timeout.rb RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation 2021-11-25 14:03:06 +00:00