Skip to content

Conversation

@cryptomail
Copy link
Contributor

@cryptomail cryptomail commented Oct 12, 2025

Allows applications to configure any instrumentation backend that responds to #instrument(event_name, payload), e.g. ActiveSupport::Notifications

Usage

ZendeskAPI.configure do |config|
  config.instrumentation = ActiveSupport::Notifications
end

Instrumentation Events

zendesk.request

  • When: All requests (emitted regardless of status code)
  • Payload: duration (ms), endpoint, method, status

zendesk.rate_limit

  • When: Status < 500 AND rate limit headers present
  • Not emitted for: 5xx errors, missing headers
  • Payload: endpoint, status, remaining, limit, reset
  • Note: Includes successful requests and 4xx errors when rate limit headers are present

zendesk.cache_hit

  • When: 304 Not Modified served from cache
  • Requires: Cache enabled, matching ETag
  • Payload: endpoint, status (304)

zendesk.cache_miss

  • When: 200 OK with ETag cached for future requests
  • Requires: Cache enabled, ETag header present
  • Payload: endpoint, status (200)

zendesk.retry

  • When: Before retry sleep (429, 503, or exception)
  • Requires: Retry enabled; exceptions need retry_on_exception: true
  • Payload: attempt (starts at 1), endpoint, method, delay (seconds), reason
  • Reasons: "rate_limited" (429), "server_error" (503), "exception" (network failures)

Key assumptions/decisions

  • Users must supply their own compatible config.instrumentation, this lib does not pull in activesupport
  • duration reports round-trip time including network call and response processing middleware
  • Rate limit events only for status < 500 (client/rate limit errors)
  • Request events emitted for all requests (not filtered by status)
  • Instrumentation failures logged at debug level or silently swallowed

@cryptomail cryptomail requested a review from a team as a code owner October 12, 2025 22:30
@cryptomail cryptomail force-pushed the jteitelbaum/add-notifications branch 2 times, most recently from feb3f26 to d473fbd Compare November 6, 2025 04:26
@Thomascountz Thomascountz force-pushed the jteitelbaum/add-notifications branch from 10af0f4 to 5b7644a Compare November 7, 2025 13:05
Co-authored-by: Thomas Countz <thomascountz@gmail.com>

Applications can configure any instrumentation backend that responds
to #instrument(event_name, payload), e.g. ActiveSupport::Notifications

Example:

ZendeskAPI.configure do |config|
  config.instrumentation = ActiveSupport::Notifications
end

Events:

zendesk.request:
- When: All requests (emitted regardless of status code)
- Payload: duration (ms), endpoint, method, status

zendesk.rate_limit:
- When: Status < 500 AND rate limit headers present
- Not emitted for: 5xx errors, missing headers
- Payload: endpoint, status, remaining, limit, reset
- Note: Includes successful requests and 4xx errors when rate limit headers are present

zendesk.cache_hit:
- When: 304 Not Modified served from cache
- Requires: Cache enabled, matching ETag
- Payload: endpoint, status (304)

zendesk.cache_miss:
- When: 200 OK with ETag cached for future requests
- Requires: Cache enabled, ETag header present
- Payload: endpoint, status (200)

zendesk.retry:
- When: Before retry sleep (429, 503, or exception)
- Requires: Retry enabled; exceptions need retry_on_exception: true
- Payload: attempt (starts at 1), endpoint, method, delay (seconds), reason
- Reasons: "rate_limited" (429), "server_error" (503), "exception" (network failures)

Key assumptions/decisions:

- Users must supply their own compatible config.instrumentation, this lib does not pull in activesupport
- duration reports round-trip time including network call and response processing middleware
- Rate limit events only for status < 500 (client/rate limit errors)
- Request events emitted for all requests (not filtered by status)
- Instrumentation failures logged at debug level or silently swallowed
@Thomascountz Thomascountz force-pushed the jteitelbaum/add-notifications branch from 5b7644a to b4a5fd0 Compare November 7, 2025 13:07
@Thomascountz Thomascountz merged commit 507a2ae into main Nov 7, 2025
11 checks passed
@Thomascountz Thomascountz deleted the jteitelbaum/add-notifications branch November 7, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants