Skip to content

Otel integration#125

Merged
cb-alish merged 7 commits into
masterfrom
otel-integration
Jul 1, 2026
Merged

Otel integration#125
cb-alish merged 7 commits into
masterfrom
otel-integration

Conversation

@cb-karthikp

@cb-karthikp cb-karthikp commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

• Add optional OpenTelemetry telemetry via telemetry_adapter on ChargeBee.configure / Environment
• Emit one chargebee.{resource}.{operation} CLIENT span per API call (retries reuse the same span)
• Add ChargeBee::Telemetry::* types, helpers, and span attribute keys (OTel HTTP semconv + chargebee.*)
• Pass telemetry_resource / telemetry_operation from model Request.send call sites

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: f5a79ca5-cf17-40d4-8c46-bdad3090c207

📥 Commits

Reviewing files that changed from the base of the PR and between 27d9b21 and 790249d.

📒 Files selected for processing (2)
  • lib/chargebee/request.rb
  • spec/chargebee/request_telemetry_spec.rb
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/chargebee/request.rb

Walkthrough

Adds optional telemetry adapter support to Chargebee Ruby SDK v2.75.0. New telemetry classes build spans and request metadata, Request.send routes through telemetry execution, and model API calls now pass telemetry resource and operation names.

Changes

OpenTelemetry Telemetry Adapter

Layer / File(s) Summary
Telemetry contracts
lib/chargebee/telemetry/telemetry_attribute_keys.rb, lib/chargebee/telemetry/telemetry_adapter.rb, lib/chargebee/telemetry/request_telemetry_context.rb, lib/chargebee/telemetry/request_telemetry_error.rb, lib/chargebee/telemetry/request_telemetry_result.rb
Defines frozen telemetry attribute keys, the TelemetryAdapter hook interface, and the request telemetry context/error/result value objects passed into adapter callbacks.
Telemetry support and executor
lib/chargebee/telemetry/telemetry_support.rb, lib/chargebee/telemetry_executor.rb
Builds span names and attributes, promotes allowed chargebee-* headers, extracts telemetry errors, and wraps request execution with start/end telemetry callbacks and monotonic timing.
Environment and request wiring
lib/chargebee/environment.rb, lib/chargebee/request.rb, lib/chargebee.rb
Adds telemetry_adapter to the environment, loads telemetry modules during initialization, and routes request dispatch through telemetry-aware execution while preserving request result handling.
Model request telemetry
lib/chargebee/models/*.rb
Updates model request call sites to pass telemetry_resource and telemetry_operation, with a few request-shape adjustments in attached_item, feature, webhook_endpoint, and csv_tax_rule.
Tests, docs, and release metadata
spec/chargebee/telemetry_executor_spec.rb, spec/chargebee/telemetry_support_spec.rb, spec/chargebee/request_telemetry_spec.rb, README.md, CHANGELOG.md, VERSION, chargebee.gemspec
Adds telemetry specs, documents adapter usage and header promotion, and bumps release/version metadata to 2.75.0.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90 minutes


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/chargebee/request.rb`:
- Around line 29-33: The safe-navigation usage in Request#request is
incompatible with the currently declared Ruby support, since
`telemetry_headers&.each` will not parse on Ruby 1.9/2.0. Update this logic to
avoid `&.` in `lib/chargebee/request.rb` by using an older-Ruby-compatible nil
check before iterating over `telemetry_headers`, or alternatively raise the
gem’s minimum Ruby version in the gemspec if that syntax is intended to stay.
- Around line 20-30: Normalize headers in Request.send before telemetry merging
so nil callers don’t crash; in Request.request, replace the direct headers.dup
usage with a nil-safe fallback (for example, an empty hash) before merging
telemetry_headers, and keep the NativeRequest.request call using the normalized
headers path so the HTTP request still proceeds normally.

In `@lib/chargebee/telemetry/request_telemetry_context.rb`:
- Around line 13-14: The gem’s advertised Ruby floor is incompatible with the
keyword-argument signatures used in the telemetry classes and executor. Either
raise the minimum Ruby version in chargebee.gemspec to match Ruby 2.0+ or
rewrite the initialize/method signatures in RequestTelemetryContext,
RequestTelemetryError, RequestTelemetryResult, and TelemetryExecutor to avoid
required keyword args. Make sure the chosen fix is applied consistently across
all affected telemetry entry points so the gem loads on every supported Ruby
version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: d4669836-dee4-4b28-998e-7e2e0fb129a8

📥 Commits

Reviewing files that changed from the base of the PR and between 3787b8d and 3d80a88.

⛔ Files ignored due to path filters (1)
  • Gemfile.lock is excluded by !**/*.lock
📒 Files selected for processing (89)
  • CHANGELOG.md
  • README.md
  • VERSION
  • chargebee.gemspec
  • lib/chargebee.rb
  • lib/chargebee/environment.rb
  • lib/chargebee/models/addon.rb
  • lib/chargebee/models/address.rb
  • lib/chargebee/models/alert.rb
  • lib/chargebee/models/alert_status.rb
  • lib/chargebee/models/attached_item.rb
  • lib/chargebee/models/business_entity.rb
  • lib/chargebee/models/card.rb
  • lib/chargebee/models/comment.rb
  • lib/chargebee/models/configuration.rb
  • lib/chargebee/models/coupon.rb
  • lib/chargebee/models/coupon_code.rb
  • lib/chargebee/models/coupon_set.rb
  • lib/chargebee/models/credit_note.rb
  • lib/chargebee/models/csv_tax_rule.rb
  • lib/chargebee/models/currency.rb
  • lib/chargebee/models/customer.rb
  • lib/chargebee/models/customer_entitlement.rb
  • lib/chargebee/models/differential_price.rb
  • lib/chargebee/models/entitlement.rb
  • lib/chargebee/models/entitlement_override.rb
  • lib/chargebee/models/estimate.rb
  • lib/chargebee/models/event.rb
  • lib/chargebee/models/export.rb
  • lib/chargebee/models/feature.rb
  • lib/chargebee/models/gift.rb
  • lib/chargebee/models/grant_block.rb
  • lib/chargebee/models/hosted_page.rb
  • lib/chargebee/models/in_app_subscription.rb
  • lib/chargebee/models/invoice.rb
  • lib/chargebee/models/item.rb
  • lib/chargebee/models/item_entitlement.rb
  • lib/chargebee/models/item_family.rb
  • lib/chargebee/models/item_price.rb
  • lib/chargebee/models/ledger_account_balance.rb
  • lib/chargebee/models/ledger_operation.rb
  • lib/chargebee/models/non_subscription.rb
  • lib/chargebee/models/offer_event.rb
  • lib/chargebee/models/offer_fulfillment.rb
  • lib/chargebee/models/omnichannel_one_time_order.rb
  • lib/chargebee/models/omnichannel_subscription.rb
  • lib/chargebee/models/omnichannel_subscription_item.rb
  • lib/chargebee/models/order.rb
  • lib/chargebee/models/payment_intent.rb
  • lib/chargebee/models/payment_schedule_scheme.rb
  • lib/chargebee/models/payment_source.rb
  • lib/chargebee/models/payment_voucher.rb
  • lib/chargebee/models/personalized_offer.rb
  • lib/chargebee/models/plan.rb
  • lib/chargebee/models/portal_session.rb
  • lib/chargebee/models/price_variant.rb
  • lib/chargebee/models/pricing_page_session.rb
  • lib/chargebee/models/promotional_credit.rb
  • lib/chargebee/models/promotional_grant.rb
  • lib/chargebee/models/purchase.rb
  • lib/chargebee/models/quote.rb
  • lib/chargebee/models/ramp.rb
  • lib/chargebee/models/recorded_purchase.rb
  • lib/chargebee/models/resource_migration.rb
  • lib/chargebee/models/rule.rb
  • lib/chargebee/models/site_migration_detail.rb
  • lib/chargebee/models/subscription.rb
  • lib/chargebee/models/subscription_entitlement.rb
  • lib/chargebee/models/time_machine.rb
  • lib/chargebee/models/transaction.rb
  • lib/chargebee/models/unbilled_charge.rb
  • lib/chargebee/models/usage.rb
  • lib/chargebee/models/usage_charge.rb
  • lib/chargebee/models/usage_event.rb
  • lib/chargebee/models/usage_file.rb
  • lib/chargebee/models/usage_summary.rb
  • lib/chargebee/models/virtual_bank_account.rb
  • lib/chargebee/models/webhook_endpoint.rb
  • lib/chargebee/request.rb
  • lib/chargebee/telemetry/request_telemetry_context.rb
  • lib/chargebee/telemetry/request_telemetry_error.rb
  • lib/chargebee/telemetry/request_telemetry_result.rb
  • lib/chargebee/telemetry/telemetry_adapter.rb
  • lib/chargebee/telemetry/telemetry_attribute_keys.rb
  • lib/chargebee/telemetry/telemetry_support.rb
  • lib/chargebee/telemetry_executor.rb
  • spec/chargebee/request_telemetry_spec.rb
  • spec/chargebee/telemetry_executor_spec.rb
  • spec/chargebee/telemetry_support_spec.rb

Comment thread lib/chargebee/request.rb
Comment thread lib/chargebee/request.rb Outdated
Comment thread lib/chargebee/telemetry/request_telemetry_context.rb
@snyk-io

snyk-io Bot commented Jun 30, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cb-karthikp cb-karthikp marked this pull request as ready for review July 1, 2026 05:05
@cb-karthikp cb-karthikp requested a review from cb-alish July 1, 2026 05:05
@cb-alish cb-alish merged commit 869476d into master Jul 1, 2026
10 checks passed
@cb-alish cb-alish deleted the otel-integration branch July 1, 2026 07:19
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