chore: subs tracing by GAlexIHU · Pull Request #3897 · openmeterio/openmeter

📝 Walkthrough

Walkthrough

This PR adds comprehensive OpenTelemetry instrumentation across subscription and workflow services, capturing span attributes and events for subscription operations, syncs, addon workflows, and patch applications without altering control flow or business logic.

Changes

Cohort / File(s) Summary
Subscription Service Instrumentation
openmeter/subscription/service/service.go, openmeter/subscription/service/sync.go
Added span attributes for subscription operations (Create, Update, spec_sync), including namespace, IDs, and operation names. Introduced counters for phase and item changes, plus span events for deletions with context. Post-sync reporting now fetches updated subscription and emits summary telemetry.
Subscription Service Trace Helpers
openmeter/subscription/service/trace.go
New internal helpers for setting span attributes and events. Includes builders for SubscriptionSpec and SubscriptionView attributes with customer IDs, phase/item details, and billable flags, with sorted keys for stable ordering.
Addon Workflow Instrumentation
openmeter/subscription/workflow/service/addon.go
Heavy span attribute instrumentation across addon workflow entry points and processing stages. Added new emitAddonApplyPlanEvents helper for detailed per-addon event emission. Refactored asDiffs to return filtered non-nil diffs. Enhanced sync with before/after addon state tracking.
Subscription Workflow Instrumentation
openmeter/subscription/workflow/service/subscription.go
Systematic span attribute setup in CreateFromPlan, EditRunning, and ChangeToPlan with timing and operation context. Added per-patch event attributes, cadence override logging, and apply-time state tracking during patch application with error context marshaling.
Subscription Workflow Trace Helpers
openmeter/subscription/workflow/service/trace.go
New internal helpers for subscription and addon tracing attributes. Builders for SubscriptionSpec, SubscriptionView, and addon-related attributes with proper nil-span guards and context-aware attribute generation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

release-note/misc

Suggested reviewers

  • tothandras
  • turip
  • chrisgacsal
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: subs tracing' directly reflects the main changes across the PR, which add comprehensive OpenTelemetry tracing instrumentation to subscription services.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/subs-tracing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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