Skip to content

Fix/review and test suite#4

Merged
cmwright33 merged 10 commits into
mainfrom
fix/review-and-test-suite
May 19, 2026
Merged

Fix/review and test suite#4
cmwright33 merged 10 commits into
mainfrom
fix/review-and-test-suite

Conversation

@cmwright33
Copy link
Copy Markdown
Owner

No description provided.

cmwright33 and others added 10 commits May 16, 2026 01:57
- Add .github/workflows/ci.yml: runs rubocop and rspec across Ruby 3.1/3.2/3.3
- Add examples/initializer.rb: copy-paste template for config/initializers/apidepth.rb

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The parse attempt was superseded by the request spy approach below it
but never cleaned up, causing a Ruby unused-variable warning.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exercises the full pipeline: Net::HTTP instrumentation → event capture
→ flush → collector ingest → query API verification.

Makes a real outbound call to api.stripe.com (expects 401), flushes to
the collector, then verifies via /v1/vendors, /v1/endpoints, and SDK stats.
Uses a per-run env tag (integration-$PID) to isolate results across runs.

Usage:
  COLLECTOR_URL=https://... API_KEY=apd_... ruby scripts/integration_test.rb

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- stats[:total_sent] doesn't exist — use queue_size == 0 to verify drain
- /v1/endpoints env filter was too strict (gem env tag may differ without Rails)
  — query by vendor only, which is sufficient to prove the event landed

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…or query

The collector's /v1/endpoints defaults to env="production" when no env
param is given. Pass Apidepth.configuration.environment explicitly so
the query matches the env tag on the events we just flushed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Net::HTTP.prepend is called by the Railtie at Rails boot. Without Rails
the Railtie never runs, so Net::HTTP was never instrumented and all events
were silently dropped. Wire it up manually in the standalone script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The gem's collector_url is the full ingest endpoint (includes /v1/events),
not just the base URL. COLLECTOR_URL env var is the base — append the path
when configuring the gem so the POST lands on the right route.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New RateLimitHeaders module extracts quota state from response headers and
attaches rl_remaining, rl_limit, rl_reset_at (epoch ms) to events when
recognised headers are present. Returns nil when no headers are found so
events stay lean for vendors that don't send quota data.

Header coverage (priority order per field):
  remaining: x-ratelimit-remaining-requests, x-ratelimit-remaining, ratelimit-remaining
  limit:     x-ratelimit-limit-requests, x-ratelimit-limit, ratelimit-limit
  reset_at:  x-ratelimit-reset-requests, x-ratelimit-reset, ratelimit-reset, retry-after

reset_at normalisation handles three formats:
  Unix timestamps (n > 1e9) → epoch ms
  Seconds-from-now (small integer) → now_ms + n*1000
  OpenAI duration strings ("1s", "20ms", "1m30s") → now_ms + parsed duration

Vendor coverage: OpenAI, Anthropic, GitHub, IETF RateLimit draft,
HubSpot, Fastly, Stripe (Retry-After on 429 only).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents RateLimitHeaders behaviour: supported header names (priority order),
reset_at normalisation (Unix ts / seconds-from-now / OpenAI duration strings),
per-vendor coverage notes, and the passthrough behaviour for vendors that
don't send quota headers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds rubocop ~> 1.65 to gemspec so CI can run bundle exec rubocop.
Adds .rubocop.yml with project-appropriate limits (line length 120,
method length 35, AbcSize 50). Autocorrected all 115 safe violations
and manually fixed Lint/UselessConstantScoping (moved PRIVATE_HOST_PATTERN
above private in collector.rb), Layout/LineLength in vendor_registry.rb,
and disabled Style/MultilineBlockChain for the thread .tap pattern in
registry_loader.rb. Zero offenses on 10 files inspected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cmwright33 cmwright33 merged commit decde54 into main May 19, 2026
0 of 9 checks passed
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.

1 participant