Fix/review and test suite#4
Merged
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.