Skip to content

feat(rails): report Active Job retry failures - #336

Open
marandaneto wants to merge 1 commit into
mainfrom
feat/rails-job-retry-reporting-zPpC27
Open

marandaneto wants to merge 1 commit into
mainfrom
feat/rails-job-retry-reporting-zPpC27

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

Public API addition: PostHog::Rails::Configuration#report_active_job_retries, default false. It requires auto_instrument_active_job.

Active Job can retry a failed execution without letting the error escape to the terminal exception handler. Applications that need to investigate these failures can now opt in to reporting them when Active Job schedules a retry.

The notification subscriber uses the job's effective saved or extracted identity and session. Retry events reuse filtered job arguments and omit request and worker properties. Missing or disabled clients do nothing. Reporting errors do not interrupt retries. Discarded failures and failures consumed by rescue or terminal retry handlers do not gain reports. Core exception-object deduplication still applies, so reusing one exception object can suppress later retry or terminal reports.

New retry events use source rails.active_job, level error, and mechanism task with handled: false at the job execution boundary, following the exception-event-metadata spec. The existing additional-properties path carries source and level rather than a typed internal metadata channel. The existing job exclusion behavior is unchanged: excluded_exceptions does not filter job reports. This differs from the capture-exception spec's cross-path ignored-type rule. Terminal event metadata is unchanged.

A Rails-only minor changeset, initializer examples, README guidance, and the intentional public API snapshot update are included. No package versions are changed by hand.

💚 How did you test it?

Local validation used Ruby 4.0.7, Bundler 4.0.13, and Rails 7.2.3.1.

  • bundle exec rspec: 2174 examples, 0 failures, 40 pending because optional integrations are unavailable in the base bundle.
  • BUNDLE_PATH=/Users/marandaneto/Github/posthog-ruby/vendor/bundle BUNDLE_GEMFILE=gemfiles/otel.gemfile bundle exec rspec: 2174 examples, 0 failures, 2 existing pending.
  • Retry specs alone: 22 examples, 0 failures. Retry and neighboring context specs: 64 examples, 0 failures, 11 optional-integration pending in the base bundle.
  • bundle exec rubocop: 151 files inspected, no offenses.
  • bundle exec rake public_api:check and git diff --check: passed.

Tests execute real Active Job retries through serialized queue payloads and inspect captured exception events. They cover saved, extracted and numeric identities, nested application context, nested argument filtering, worker context restoration, eventual success, reporting failures, deduplication, exclusions, missing clients, and handled failure boundaries. Two subprocess tests initialize real Rails applications with Active Job loaded before or after the load hook. The Authoring-mode test audit retained all cases. The historical Ruby/Rails matrix was not run locally.

The required isolated autoreview reviewed the exact signed HEAD against origin/main and returned no findings. Human review is still required.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

The changeset file is included and was hand-authored. I did not run pnpm changeset or generate a duplicate.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

marandaneto is the human DRI and PR assignee. Pi's worker subagent used shell/file tools, Git, GitHub CLI, and the autoreview helper with the claude-code/claude-opus-5-5 provider. The local Pi session ID is 01a1b0e4-9039-71a4-a297-fed90e502ce9. There is no public session URL.

The directed scope keeps reporting opt-in, preserves terminal behavior and job exclusions, and restores effective job identity rather than reading a nested application scope. Diff-scoped cleanup and the test audit ran before the signed commit. This draft needs human review and will not be self-approved or merged.

@marandaneto marandaneto self-assigned this Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

posthog-ruby-sync Compliance Report

Date: 2026-11-06T14:36:52.638564+00:00
Duration: 55887ms

⚠️ Some Tests Failed

39/47 tests passed, 8 failed


Capture Tests

⚠️ 23/30 tests passed, 7 failed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 8ms
Format Validation.Event Has Uuid ✅ 6ms
Format Validation.Event Has Lib Properties ✅ 4ms
Format Validation.Distinct Id Is String ✅ 8ms
Format Validation.Token Is Present ✅ 7ms
Format Validation.Custom Properties Preserved ✅ 5ms
Format Validation.Event Has Timestamp ✅ 7ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 6ms
Retry Behavior.Retries On 503 ✅ 5234ms
Retry Behavior.Does Not Retry On 400 ❌ 5ms
Retry Behavior.Does Not Retry On 401 ❌ 6ms
Retry Behavior.Respects Retry After Header ✅ 8011ms
Retry Behavior.Implements Backoff ❌ 238ms
Retry Behavior.Retries On 500 ✅ 5112ms
Retry Behavior.Retries On 502 ✅ 5141ms
Retry Behavior.Retries On 504 ✅ 5146ms
Retry Behavior.Max Retries Respected ❌ 595ms
Deduplication.Generates Unique Uuids ✅ 13ms
Deduplication.Preserves Uuid On Retry ✅ 5113ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10300ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5152ms
Deduplication.No Duplicate Events In Batch ✅ 15ms
Deduplication.Different Events Have Different Uuids ✅ 8ms
Compression.Sends Gzip When Enabled ✅ 6ms
Batch Format.Uses Proper Batch Structure ✅ 5ms
Batch Format.Flush With No Events Sends Nothing ✅ 3ms
Batch Format.Multiple Events Batched Together ❌ 13ms
Error Handling.Does Not Retry On 403 ❌ 4ms
Error Handling.Does Not Retry On 413 ❌ 4ms
Error Handling.Retries On 408 ✅ 5111ms

Failures

retry_behavior.does_not_retry_on_400

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

retry_behavior.does_not_retry_on_401

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

retry_behavior.implements_backoff

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

retry_behavior.max_retries_respected

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

batch_format.multiple_events_batched_together

Expected 1 requests, got 5

error_handling.does_not_retry_on_403

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

error_handling.does_not_retry_on_413

500, message='Internal Server Error', url='http://sdk-adapter:8080/capture'

Feature_Flags Tests

⚠️ 16/17 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 9ms
Request Payload.Flags Request Uses V2 Query Param ✅ 7ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 7ms
Request Payload.Flags Request Omits Authorization Header ✅ 7ms
Request Payload.Token In Flags Body Matches Init ✅ 5ms
Request Payload.Groups Round Trip ✅ 5ms
Request Payload.Groups Default To Empty Object ✅ 5ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 5ms
Request Payload.Disable Geoip Omitted Defaults To False ❌ 7ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 5ms
Request Lifecycle.No Flags Request On Init Alone ✅ 2ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 5ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 7ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 5ms
Retry Behavior.Retries Flags On 502 ✅ 141ms
Retry Behavior.Retries Flags On 504 ✅ 146ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 6ms

Failures

request_payload.disable_geoip_omitted_defaults_to_false

Field 'geoip_disable' not found in /flags request body at path 'geoip_disable'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'flag_keys_to_evaluate', 'token']

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

posthog-ruby-async Compliance Report

Date: 2026-11-06T14:37:36.118922+00:00
Duration: 98216ms

⚠️ Some Tests Failed

46/47 tests passed, 1 failed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 108ms
Format Validation.Event Has Uuid ✅ 105ms
Format Validation.Event Has Lib Properties ✅ 107ms
Format Validation.Distinct Id Is String ✅ 105ms
Format Validation.Token Is Present ✅ 106ms
Format Validation.Custom Properties Preserved ✅ 106ms
Format Validation.Event Has Timestamp ✅ 106ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 107ms
Retry Behavior.Retries On 503 ✅ 5412ms
Retry Behavior.Does Not Retry On 400 ✅ 2107ms
Retry Behavior.Does Not Retry On 401 ✅ 2108ms
Retry Behavior.Respects Retry After Header ✅ 8012ms
Retry Behavior.Implements Backoff ✅ 15611ms
Retry Behavior.Retries On 500 ✅ 5211ms
Retry Behavior.Retries On 502 ✅ 5210ms
Retry Behavior.Retries On 504 ✅ 5211ms
Retry Behavior.Max Retries Respected ✅ 15508ms
Deduplication.Generates Unique Uuids ✅ 109ms
Deduplication.Preserves Uuid On Retry ✅ 5210ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10311ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5213ms
Deduplication.No Duplicate Events In Batch ✅ 109ms
Deduplication.Different Events Have Different Uuids ✅ 106ms
Compression.Sends Gzip When Enabled ✅ 105ms
Batch Format.Uses Proper Batch Structure ✅ 105ms
Batch Format.Flush With No Events Sends Nothing ✅ 4ms
Batch Format.Multiple Events Batched Together ✅ 109ms
Error Handling.Does Not Retry On 403 ✅ 2108ms
Error Handling.Does Not Retry On 413 ✅ 2109ms
Error Handling.Retries On 408 ✅ 5211ms

Feature_Flags Tests

⚠️ 16/17 tests passed, 1 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 106ms
Request Payload.Flags Request Uses V2 Query Param ✅ 106ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 106ms
Request Payload.Flags Request Omits Authorization Header ✅ 106ms
Request Payload.Token In Flags Body Matches Init ✅ 105ms
Request Payload.Groups Round Trip ✅ 107ms
Request Payload.Groups Default To Empty Object ✅ 106ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 106ms
Request Payload.Disable Geoip Omitted Defaults To False ❌ 106ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 106ms
Request Lifecycle.No Flags Request On Init Alone ✅ 2ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 104ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 109ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 105ms
Retry Behavior.Retries Flags On 502 ✅ 253ms
Retry Behavior.Retries Flags On 504 ✅ 208ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 108ms

Failures

request_payload.disable_geoip_omitted_defaults_to_false

Field 'geoip_disable' not found in /flags request body at path 'geoip_disable'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'flag_keys_to_evaluate', 'token']

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

SDK performance: posthog-ruby

Benchmarks completed. No changes flagged for review.

Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.

View all results
Test Measurement Before PR With PR Change Assessment
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Queue an event (32-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (32-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (4,096-byte payload)
Shard: capture
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Queue an event (4,096-byte payload)
Shard: capture
Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​; head:​ Background serialization has no public enqueue completion boundary; use completed-delivery workloads for process-wide allocation counts.​
Evaluate all 10 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate all 100 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate all 1,000 flags
Shard: flags-scaling
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate one boolean flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a cohort-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (early match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (late match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a flag (no match)
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a property-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a regex-filtered flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a rollout flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Evaluate a multivariate flag
Shard: flags-single
Allocated memory per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​; head:​ Ruby has no cumulative allocated-byte counter here; retained ObjectSpace bytes are not allocation volume.​
Capture and deliver events (32-byte payload, burst)
Shard: capture
Allocations per operation 56.27 count/op 56.27 count/op No observed change Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Time per operation 114.36 µs/op 114.39 µs/op <0.1% more time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Idle process memory (RSS) 28.39 MiB 28.38 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 31.15 MiB 31.14 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Managed heap after settling 5.27 MiB 5.27 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 30.39 MiB 30.38 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Process CPU time per operation 30.92 µs/op 30.83 µs/op 0.3% less time Not flagged
Capture and deliver events (32-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 30.84 MiB 30.88 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Allocations per operation 58.65 count/op 58.65 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Time per operation 114.15 µs/op 114.95 µs/op 0.7% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Idle process memory (RSS) 33.18 MiB 33.16 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Observed peak process memory (RSS) 41.88 MiB 41.88 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Managed heap after settling 9.14 MiB 9.14 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process memory after settling (RSS) 39.71 MiB 39.71 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Process CPU time per operation 43.66 µs/op 45.12 µs/op 3.3% more time Not flagged
Capture and deliver events (4,096-byte payload, burst)
Shard: capture
Lifetime peak process memory (RSS) 41.66 MiB 41.67 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Allocations per operation 58.68 count/op 58.68 count/op No observed change Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Time per operation 1.02 ms/op 1.02 ms/op <0.1% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Idle process memory (RSS) 28.23 MiB 28.25 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 30.38 MiB 30.39 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Managed heap after settling 5.27 MiB 5.27 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 30.38 MiB 30.39 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Process CPU time per operation 43.33 µs/op 42.21 µs/op 2.6% less time Not flagged
Capture and deliver events (32-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 30.38 MiB 30.39 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Allocations per operation 58.68 count/op 58.68 count/op No observed change Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Time per operation 1.02 ms/op 1.02 ms/op <0.1% less time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Idle process memory (RSS) 33.09 MiB 33.09 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Observed peak process memory (RSS) 40.46 MiB 40.45 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Managed heap after settling 9.14 MiB 9.14 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process memory after settling (RSS) 40.18 MiB 40.12 MiB 0.2% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Process CPU time per operation 51.24 µs/op 51.48 µs/op 0.5% more time Not flagged
Capture and deliver events (4,096-byte payload, steady)
Shard: capture
Lifetime peak process memory (RSS) 40.77 MiB 40.69 MiB 0.2% less memory Not flagged
Queue an event (32-byte payload)
Shard: capture
Caller-thread CPU time per operation 14.3 µs/op 14 µs/op 2.1% less time Not flagged
Queue an event (32-byte payload)
Shard: capture
Time per operation 14.3 µs/op 14 µs/op 2.1% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Caller-thread CPU time per operation 14.21 µs/op 13.67 µs/op 3.8% less time Not flagged
Queue an event (4,096-byte payload)
Shard: capture
Time per operation 14.21 µs/op 13.67 µs/op 3.8% less time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Allocations per operation 343.02 count/op 343.02 count/op No observed change Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Time per operation 156.58 µs/op 158.76 µs/op 1.4% more time Not flagged
Evaluate all 10 flags
Shard: flags-scaling
Process CPU time per operation 156.57 µs/op 158.76 µs/op 1.4% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Allocations per operation 3,324 count/op 3,324 count/op No observed change Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Time per operation 1.5 ms/op 1.52 ms/op 1% more time Not flagged
Evaluate all 100 flags
Shard: flags-scaling
Process CPU time per operation 1.5 ms/op 1.52 ms/op 1% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Allocations per operation 33,113.56 count/op 33,113.62 count/op <0.1% more Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Time per operation 15.54 ms/op 15.6 ms/op 0.4% more time Not flagged
Evaluate all 1,000 flags
Shard: flags-scaling
Process CPU time per operation 15.54 ms/op 15.6 ms/op 0.4% more time Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Idle process memory (RSS) 39.3 MiB 39.4 MiB 0.2% more memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Observed peak process memory (RSS) 40.95 MiB 40.94 MiB <0.1% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Managed heap after settling 7.97 MiB 7.97 MiB No observed change Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Process memory after settling (RSS) 39.62 MiB 39.48 MiB 0.4% less memory Not flagged
Evaluate 1,000 flags under concurrent load
Shard: flags-memory
Lifetime peak process memory (RSS) 40.62 MiB 40.53 MiB 0.2% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Idle process memory (RSS) 38.16 MiB 38.07 MiB 0.3% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Observed peak process memory (RSS) 41.36 MiB 41.35 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Managed heap after settling 9.48 MiB 9.48 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Process memory after settling (RSS) 41.33 MiB 41.3 MiB <0.1% less memory Not flagged
Refresh 1,000 flag definitions
Shard: flags-memory
Lifetime peak process memory (RSS) 41.36 MiB 41.35 MiB <0.1% less memory Not flagged
Evaluate one boolean flag
Shard: flags-single
Allocations per operation 38 count/op 38 count/op No observed change Not flagged
Evaluate one boolean flag
Shard: flags-single
Time per operation 11.18 µs/op 11.39 µs/op 1.9% more time Not flagged
Evaluate one boolean flag
Shard: flags-single
Process CPU time per operation 11.18 µs/op 11.39 µs/op 1.9% more time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Allocations per operation 38 count/op 38 count/op No observed change Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Time per operation 18.69 µs/op 18.63 µs/op 0.3% less time Not flagged
Evaluate a cohort-filtered flag
Shard: flags-single
Process CPU time per operation 18.69 µs/op 18.62 µs/op 0.3% less time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Allocations per operation 55 count/op 55 count/op No observed change Not flagged
Evaluate a flag (early match)
Shard: flags-single
Time per operation 21.65 µs/op 21.56 µs/op 0.4% less time Not flagged
Evaluate a flag (early match)
Shard: flags-single
Process CPU time per operation 21.65 µs/op 21.56 µs/op 0.4% less time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Allocations per operation 76 count/op 76 count/op No observed change Not flagged
Evaluate a flag (late match)
Shard: flags-single
Time per operation 29.69 µs/op 29.47 µs/op 0.7% less time Not flagged
Evaluate a flag (late match)
Shard: flags-single
Process CPU time per operation 29.68 µs/op 29.46 µs/op 0.7% less time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Allocations per operation 67 count/op 67 count/op No observed change Not flagged
Evaluate a flag (no match)
Shard: flags-single
Time per operation 24.59 µs/op 24.69 µs/op 0.4% more time Not flagged
Evaluate a flag (no match)
Shard: flags-single
Process CPU time per operation 24.59 µs/op 24.69 µs/op 0.4% more time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Allocations per operation 34 count/op 34 count/op No observed change Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Time per operation 13.61 µs/op 13.53 µs/op 0.6% less time Not flagged
Evaluate a property-filtered flag
Shard: flags-single
Process CPU time per operation 13.61 µs/op 13.53 µs/op 0.6% less time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Allocations per operation 99 count/op 99 count/op <0.1% more Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Time per operation 37.03 µs/op 37.4 µs/op 1% more time Not flagged
Evaluate a regex-filtered flag
Shard: flags-single
Process CPU time per operation 37.03 µs/op 37.39 µs/op 1% more time Not flagged
Evaluate a rollout flag
Shard: flags-single
Allocations per operation 31 count/op 31 count/op No observed change Not flagged
Evaluate a rollout flag
Shard: flags-single
Time per operation 10.32 µs/op 10.23 µs/op 0.8% less time Not flagged
Evaluate a rollout flag
Shard: flags-single
Process CPU time per operation 10.32 µs/op 10.23 µs/op 0.8% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Allocations per operation 37 count/op 37 count/op No observed change Not flagged
Evaluate a multivariate flag
Shard: flags-single
Time per operation 13.07 µs/op 13.04 µs/op 0.2% less time Not flagged
Evaluate a multivariate flag
Shard: flags-single
Process CPU time per operation 13.07 µs/op 13.04 µs/op 0.2% less time Not flagged

Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals.

Each shard uses its own runner; compare Before PR against With PR within a row, not across shards.

Compared 58f5335f895ebebc417bb4a48d22351ff96b5fb0 → b9ed2748de945908035453f1d25c3a29d3597440.

Full report and diagnostics

102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in comparison.json, including per-runner environments, resource limits, measurement methods, samples and checkpoints.

@marandaneto
marandaneto marked this pull request as ready for review November 6, 2026 14:50
@marandaneto
marandaneto requested a review from a team as a code owner November 6, 2026 14:50

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PostHog Review · Standard · reviewed b9ed274: 2 Should fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

base.around_perform :with_posthog_job_context, prepend: true if base.respond_to?(:around_perform)
return if @retry_subscription

@retry_subscription = ActiveSupport::Notifications.subscribe('enqueue_retry.active_job') do |*args|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 · Support retry reporting on Rails 5.2

On Rails 5.2, which the gemspec explicitly supports, retry_job calls enqueue without emitting enqueue_retry.active_job; that notification was introduced in Rails 6. Consequently, enabling both configuration options silently captures no retry failures on Rails 5.2. Add a compatible retry interception path for that supported version.

Comment on lines +155 to +156
return unless config&.auto_instrument_active_job && config.report_active_job_retries && exception
return unless PostHog.initialized? && PostHog.client.enabled?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 · Honor exception exclusions in the new retry capture path

With retry reporting enabled, an exception listed in excluded_exceptions still reaches capture_job_exception and uploads its message, stack and arguments. This new capture path violates the capture-exception spec's requirement to apply ignored types across every reporting path. Filter excluded types, including chained causes, before capture.

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues remain in the new retry-reporting path: configured exception exclusions are ignored, and Rails 5.2 never emits the subscribed notification. Consider honoring exclusions and either supporting that runtime or documenting an explicit capability restriction.

AI-assisted review.

Comment on lines +155 to +156
return unless config&.auto_instrument_active_job && config.report_active_job_retries && exception
return unless PostHog.initialized? && PostHog.client.enabled?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1 / IMPORTANT] Honor exclusions before capturing the new retry report

Relationship: New-path exposure/amplification of an existing job-exclusion bypass.

Location: posthog-rails/lib/posthog/rails/active_job.rb:155–161.

When retry reporting is enabled, a job raising a configured excluded exception—or wrapping an excluded cause—still queues an exception event. It should schedule the retry without admitting that report to capture.

PostHog::Rails.configure do |config|
  config.auto_instrument_active_job = true
  config.report_active_job_retries = true
  config.excluded_exceptions = ['ArgumentError']
end

class RetryingJob < ApplicationJob
  retry_on StandardError, wait: 0, attempts: 2

  def perform(nested = false)
    raise ArgumentError, 'excluded inner' unless nested

    begin
      raise ArgumentError, 'excluded inner'
    rescue ArgumentError
      raise RuntimeError, 'outer'
    end
  end
end

With the normal initialized Rails integration, both RetryingJob.perform_now(false) and RetryingJob.perform_now(true) currently produce a retry report on Rails 7.1.6.

The new helper checks configuration and client availability but never checks exclusions; neither its shared helper nor core capture_exception adds a later check. The pinned ignored-type contract requires filtering on every reporting path and across the serialized chain. The added test at active_job_retries_spec.rb:185–190 instead enshrines bypass.

Executed regression: Ruby 3.4.7 / Rails 7.1.6, real facade/extension and test-mode client. Two cases configure excluded_exceptions = ['ArgumentError'], run the direct or nested failure through public perform_now, assert one scheduled retry, then assert zero queued reports. An ordinary unexcluded retry is the positive control. Base: 3 examples / 0 failures, exit 0. Head: 3 examples / 2 failures, exit 1; both excluded cases get 1, expected 0. The positive control passes.

The base has no retry-reporting option: this proves newly exposed reporting, not prior support for retry filtering. Terminal capture already bypasses exclusions on both revisions and is outside this finding. Queueing—not actual external transmission—was demonstrated. The impact is unwanted event volume and admission of exception messages, stacks, and permitted job properties into normal delivery; parameter filtering and before_send are not bypassed.

Consider filtering only the new retry path before capture, checking the same cause chain the serializer retains with its cycle detection and 50-entry bound. Calling the current outer-only predicate once would miss the demonstrated cause case. Retain both regression cases and the unexcluded control. If divergence is accepted instead, document its consequences in public configuration guidance; PR disclosure alone does not establish that acceptance.

base.around_perform :with_posthog_job_context, prepend: true if base.respond_to?(:around_perform)
return if @retry_subscription

@retry_subscription = ActiveSupport::Notifications.subscribe('enqueue_retry.active_job') do |*args|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1 / IMPORTANT] Avoid silently unsupported retry reporting on Rails 5.2

Relationship: Introduced capability/support gap, not a regression in default or terminal behavior.

Location: posthog-rails/lib/posthog/rails/active_job.rb:18–21.

A Rails 5.2 application can enable both options and successfully schedule an ordinary retry, but receives no retry report:

config.auto_instrument_active_job = true
config.report_active_job_retries = true

class RetryVisibilityJob < ApplicationJob
  retry_on RuntimeError, wait: 0, attempts: 2
  def perform
    raise 'temporary failure'
  end
end

RetryVisibilityJob.perform_now

The gem explicitly supports Railties >= 5.2.0; the new README and templates state no capability restriction. However, Active Job 5.2.8.1's retry_job directly calls enqueue without emitting enqueue_retry.active_job. Its retry handler also does not pass the error. Official 6.0.6.1 and 7.1.6 sources do emit the notification this subscriber requires.

Executed lifecycle comparison: Ruby 3.4.7, matched real Active Job/ActiveSupport packages, real extension/facade and test-mode client:

Snapshot Active Job Retry reports Terminal reports Scheduled retries
Base 5.2.8.1 0 1 1
Head 5.2.8.1 0 1 1
Base 7.1.6 0 1 1
Head 7.1.6 1 1 1

The head 5.2 assertion fails with Expected 1 retry events, got 0, exit 1. The base prior-behavior control expects zero because this option does not exist there, and exits 0. Thus this is not a same-API regression claim. The harness executes public perform_now, JSON-round-tripped serialize, and ActiveJob::Base.execute; no retry implementation was patched.

The 5.2 probe is standalone Active Job with small Rails version/application/config-accessor shims, not a fully booted Rails 5.2 application. Official source absence, successful scheduling, and working terminal capture independently isolate the missing notification. The impact is limited to missing opted-in observability, not broken job execution.

Consider either adding compatible older-framework reporting, preserving scheduling/error behavior and newer-version deduplication, or explicitly restricting and documenting the capability's Rails range in the README and both templates. A documented, accepted restriction is a valid resolution; raising the whole gem's minimum Rails version is unnecessary. Add a lowest-supported-capability regression with default-off, scheduling, and terminal controls.

@dustinbyrne
dustinbyrne requested a review from a team November 6, 2026 17:50

This branch has not been deployed

No deployments
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.

2 participants