Skip to content

Commit 418ae8a

Browse files
authored
ref(sdk): Add metrics between capturing and sending the envelope (#26171)
* ref(sdk): Add metrics between capturing and sending the envelope The sent requests for the relay transport are lower then the captured envelopes, which implies there is somewhere in between where the events are not making it out. This again bisects the space somewhat, between the existing capture_envelope check and the send_request, checking that events are being submitted to a worker and how many send_envelopes result out of that should give more insight.
1 parent c2f018c commit 418ae8a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/sentry/utils/sdk.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,27 @@ def traces_sampler(sampling_context):
212212
return float(settings.SENTRY_BACKEND_APM_SAMPLING or 0)
213213

214214

215-
# Patches the send_request function to check outgoing requests and patches the update_rate_limits function as it is first to be called after the response.
215+
# Patches transport functions to add metrics to improve resolution around events sent to our ingest
216216
# TODO(k-fish): Remove after backend transaction findings are in.
217217
def patch_transport_for_instrumentation(transport, transport_name):
218+
_worker_submit = transport._worker.submit
219+
if _worker_submit:
220+
221+
def patched_worker_submit(*args, **kwargs):
222+
metrics.incr(f"internal.worker_submit.{transport_name}.events")
223+
return _worker_submit(*args, **kwargs)
224+
225+
transport._worker.submit = patched_worker_submit
226+
227+
_send_envelope = transport._send_envelope
228+
if _send_envelope:
229+
230+
def patched_send_envelope(*args, **kwargs):
231+
metrics.incr(f"internal.send_envelope.{transport_name}.events")
232+
return _send_envelope(*args, **kwargs)
233+
234+
transport._send_envelope = patched_send_envelope
235+
218236
_send_request = transport._send_request
219237
if _send_request:
220238

0 commit comments

Comments
 (0)