-
Notifications
You must be signed in to change notification settings - Fork 99
feat(ds): Use sample rate in trace context if missing from DSC #4620
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
Conversation
Yep seems like the right place to do this. Integration test 😙🤌. |
@jan-auer brought up a good point to me, do we need to make this change, ideally people affected by this can upgrade their SDK version, this change may have unintended side effects in Relay, when the DSC is accessed before running this correction. |
@Dav1dde Yes, I agree that the ideal is not to touch Relay in this case. I am not sure we are in ideal circumstances though 😄 @jan-auer and others are currently looking at how widespread this issue is - if it was just Electron, that would be one thing, but Cocoa and the latest Python SDKs also appear to be missing the DSC sample rate (but populate it in trace context). We'll see how the investigation shakes out. |
If we settle on a solution that requires customers to upgrade their SDKs, we have no control over when or if they will upgrade. That creates a risk to our business that we need to avoid at all reasonable costs. This is not a theoretical discussion; we have a product launch that depends on our ability to record accurate sampling rates. While I understand the possibility of unintended side effects, we can and should mitigate this risk with automated tests. This is what I recommend:
@jan-auer thoughts? |
I'm going to start working on an integration test for this while the discussion continues. (I don't see a test for making sure the |
Added integration tests. They showed that the logic I added to try to read the sample rate from trace context On the plus side, the tests do confirm that the workaround for Electron (reading trace context's On the minus side, this change does not address the issue we found in the Python SDK - in that case the final event JSON is missing |
I'm going to respond to several comments here without quoting the individual points:
In combination with other SDK bugs where no sample rate or the wrong sample rate was sent to Relay, this means that for every SDK there is a certain minimum version to allow correct extrapolation. We need to document these versions, and potentially suggest an SDK update in-product. For most SDKs, this has been added a long time ago, but in some this is recent. We can move forward with this workaround, but it will not solve the larger problem affecting far more users. I strongly suggest we determine all affected SDKs and encourage upgrades. |
Closing for now, with the reasons above described by Jan. |
Our Electron SDK is not populating the
sample_rate
field in DSC (see getsentry/sentry-electron#1114). As a result, span metric extrapolation does not work as the client's sample rate is unknown.Although we will also fix this in the SDK, it will take time for clients to upgrade. In the meantime, it would be nice if data sent by existing SDK versions could work too.
In the case of the Electron SDK, the client sample rate is being sent in the transaction event payload, inside the trace context:
This PR checks if we are missing a DSC sample rate (because that field is missing, or the entire DSC is missing), and if so, tries to find a client sample rate in the transaction event payload to use and copies it into the DSC. The first place we check is trace context's documented
client_sample_rate
field, falling back to the non-standardsentry.sample_rate
in trace context'sdata
being used by Electron.I would like to add an integration test to this PR as well, but I'll get to that tomorrow if the concept and direction seem sound. Thanks!