From 8d9f98626ee21a9d8fcb9480415ff226cf0d1b0c Mon Sep 17 00:00:00 2001 From: Bart de Water <496367+bdewater@users.noreply.github.com> Date: Tue, 12 Jul 2022 19:31:02 -0400 Subject: [PATCH 1/2] Update request_end instrumentation example The old example would send IDs (high cardinality - which can be expensive) for URLs like `v1/accounts/acct_123/persons`. The new example tries to filter out anything that looks like an ID, it support nested/namespaced examples such as `/v1/financial_connections/accounts/:id/disconnect` or endpoints with multiple IDs such as `/v1/transfers/:id/reversals/:id`. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f8c848be..748b43589 100644 --- a/README.md +++ b/README.md @@ -260,9 +260,12 @@ For example: ```ruby Stripe::Instrumentation.subscribe(:request_end) do |request_event| + path_parts = event.path.split("/").drop(2) + resource = path_parts.map { |part| part.match?(/\A[a-z_]+\z/) ? part : ":id" }.join("/") + tags = { method: request_event.method, - resource: request_event.path.split('/')[2], + resource: resource, code: request_event.http_status, retries: request_event.num_retries } From 520dade1cbc2e8f284f29529e167ff9071cb4c50 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> Date: Fri, 14 Oct 2022 16:39:20 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 58c1b772d..69dea24da 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ For example: ```ruby Stripe::Instrumentation.subscribe(:request_end) do |request_event| + # Filter out high-cardinality ids from `path` path_parts = event.path.split("/").drop(2) resource = path_parts.map { |part| part.match?(/\A[a-z_]+\z/) ? part : ":id" }.join("/")