Xuanwo opened a new pull request, #8742: URL: https://github.com/apache/opendal/pull/8742
# Which issue does this PR close? Closes #. # Rationale for this change `MetricsAccessor::compose` forwarded to the inner service and returned the raw `oio::Composer` unwrapped, unlike `write`/`delete`/`list`/`copy` which all return `MetricsWrapper` handles. As a result the `compose` operation emitted no operation metrics at all — no `opendal_operation_executing`, no `opendal_operation_duration_seconds`, no entry counts for accepted sources, and no `opendal_operation_errors_total` — across every layer built on `observe-metrics-common` (`metrics`, `fastmetrics`, `prometheus`, `prometheus-client`, `otelmetrics`). # What changes are included in this PR? - `MetricsAccessor::compose` now wraps the returned composer in `MetricsWrapper<oio::Composer, I>` with the same lifecycle as `write`/`copy`: `operation_executing` is incremented up front via `ExecutingGuard` (which covers cancellation and panic), and an init failure records `operation_errors_total` with the original error's kind before the guard decrements the gauge. - `MetricsWrapper` implements `oio::Compose`: each accepted source increments the entry count, per-call failures record `operation_errors_total` with the original `ErrorKind` and propagate the error unchanged, and `close` marks the wrapper completed. `Drop` records `operation_entries`/`operation_entries_rate`, `operation_duration_seconds`, and decrements `operation_executing` exactly once — including a composer dropped without `close()` (counted once as an `Unexpected` error, matching the writer/deleter contract). - Added unit tests with a mock `oio::Compose` and a mock `Service` covering: success (gauge 1→0, 2 entries, duration, 0 errors), source error (`PermissionDenied` preserved and recorded), close error (`ConditionNotMatch` preserved, single error count, no double decrement), init error (`NotFound` recorded, gauge returns to 0), and drop-without-close (no gauge leak). Downstream layers need no changes: they consume `MetricValue` variants and already use `operation = "compose"` as a plain label. # Are there any user-facing changes? `Operation::Compose` now emits operation metrics like every other wrapped operation; dashboards and alerts that expect `operation="compose"` series will start receiving data. # Breaking changes # AI Usage Statement - Harness: pi coding agent (T3 Code) - Model: devin/swe-2 - Effort: max - Role: AI authored the fix and tests under human direction; verified locally with `cargo test -p opendal-layer-observe-metrics-common` (26 passed), the five downstream metrics layer packages (20 passed), clippy `-D warnings`, and `cargo fmt --check`. Compose itself could not be exercised against a real storage service locally, so behavior-level verification relies on the mock-based unit tests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
