Skip to content

Commit

Permalink
Update request_end instrumentation example
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
bdewater authored Jul 12, 2022
1 parent a961665 commit c9c8809
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,12 @@ For example:

```ruby
Stripe::Instrumentation.subscribe(:request_end) do |request_event|
path_parts = request_event.path.split("/").drop(2)
resource = path_parts.select { |part| part.match?(/\A[a-z_]+\z/) }.join("/")

tags = {
method: request_event.method,
resource: request_event.path.split('/')[2],
resource: resource,
code: request_event.http_status,
retries: request_event.num_retries
}
Expand Down

0 comments on commit c9c8809

Please sign in to comment.