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(tracing): Send sample rate and type in transaction item header in envelope #3068

Merged
merged 4 commits into from
Dec 15, 2020

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Nov 23, 2020

Product asked for this data, to get a sense of what kinds of sample rates people are using. It also may help inform future dynamic sampling work in relay.

TODO:

  • The spec didn't mention what should happen in either the case of sampling inheritance or of an explicitly set sampling decision, so I recorded it, but with no sample rate. Happy to change this to something else if anyone would prefer.
  • Make DACI re: propagating this information between SDKs
  • Decide on protocol including propagated info
  • Implement protocol
  • Implement propagation
  • Implement receiving and use of propagated info

EDIT: Agreed with @HazAT that we'll go with the simple version for now: sample rates sent if they come from either traces_sampler or -traces_sample_rate, but not other methods (inheritance and having the sampling decision explicitly set). The rest, listed above, we'll hold on until it's clear we need to do it.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2020

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 19.94 KB (+1.03% 🔺)
@sentry/browser - Webpack 20.76 KB (+0.78% 🔺)
@sentry/react - Webpack 20.76 KB (+0.78% 🔺)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 27.09 KB (+0.78% 🔺)

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

A few comments. Concerned about piggybacking on tags.

Based on the TODO in the PR description, I believe there's still some ironing out of the protocol in Relay? Is there an accompanying PR there?

packages/core/test/lib/request.test.ts Outdated Show resolved Hide resolved
packages/core/test/lib/request.test.ts Outdated Show resolved Hide resolved
packages/tracing/src/hubextensions.ts Outdated Show resolved Hide resolved
packages/tracing/src/hubextensions.ts Show resolved Hide resolved
Comment on lines +24 to +25
const { __sentry_samplingMethod: samplingMethod, __sentry_sampleRate: sampleRate, ...otherTags } = event.tags || {};
event.tags = otherTags;
Copy link
Member

Choose a reason for hiding this comment

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

👍

import { eventToSentryRequest } from '../../src/request';

describe('eventToSentryRequest', () => {
const api = new API('https://dogsarebadatkeepingsecrets@squirrelchasers.ingest.sentry.io/12312012');
Copy link
Member

Choose a reason for hiding this comment

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

I wonder how dogs can be bad at keeping secrets? 🤔

packages/core/test/lib/request.test.ts Outdated Show resolved Hide resolved
@lobsterkatie lobsterkatie force-pushed the kmclb-send-sample-rate-in-events branch from 29467f2 to 0afb3c7 Compare December 15, 2020 16:23
@lobsterkatie lobsterkatie merged commit 7710945 into master Dec 15, 2020
@lobsterkatie lobsterkatie deleted the kmclb-send-sample-rate-in-events branch December 15, 2020 17:57
AbhiPrasad added a commit that referenced this pull request Sep 19, 2022
In our initial work on Dynamic Sampling (#3068), we added the ability to track transaction sampling method.

https://github.com/getsentry/sentry-javascript/pull/3068/files#diff-337facb22f742f05b3326aed66ca6b0d5eb9c782c7c03c88ef0170fd97dc410dR104-R109

```ts
export enum TransactionSamplingMethod {
  Explicit = 'explicitly_set',
  Sampler = 'client_sampler',
  Rate = 'client_rate',
  Inheritance = 'inheritance',
}
```

To use this info, we set the transaction sampling method and sample rate on the transaction event header:

```ts
sample_rates: [{ id: samplingMethod, rate: sampleRate }],
```

In Relay this is used here: https://github.com/getsentry/relay/blob/4b16d279ccf21d3c1d975b652ffca01ebd72a500/relay-general/src/protocol/metrics.rs#L7-L16

This is no longer needed for dynamic sampling context with the introduction of Dynamic Sampling Context, so we can remove this code.
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.

None yet

3 participants