From 78df532c8c2d4ce1917675b702d1b492f34eebb3 Mon Sep 17 00:00:00 2001 From: Brandur Date: Thu, 15 Nov 2018 14:45:45 -0800 Subject: [PATCH] Only send telemetry if request ID was present Tweaks telemetry implementation slightly to be inline with the recent implementation in stripe-php. Telemetry isn't much good if a request ID wasn't present, so we only send telemetry if it was. --- lib/stripe/stripe_client.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/stripe/stripe_client.rb b/lib/stripe/stripe_client.rb index eef49cc58..6c7c2d8e0 100644 --- a/lib/stripe/stripe_client.rb +++ b/lib/stripe/stripe_client.rb @@ -225,7 +225,8 @@ def execute_request_with_rescues(api_base, context) resp = yield context = context.dup_from_response(resp) log_response(context, request_start, resp.status, resp.body) - if Stripe.enable_telemetry? + + if Stripe.enable_telemetry? && context.request_id request_duration_ms = ((Time.now - request_start) * 1000).to_int @last_request_metrics = StripeRequestMetrics.new(context.request_id, request_duration_ms) end