Skip to content

Conversation

@DemetrisChr
Copy link
Contributor

@DemetrisChr DemetrisChr commented Nov 21, 2025

Motivation

Operation-level spans are now in the Public API. The corresponding metrics should be moved at the same level, so our implementation is consistent with the RFC and to ensure we are measuring the entire duration of the high-level operation.

Changes

  • Add observability_recorder that wraps the meter and tracer and creates the necessary spans & metrics for a given operation.
  • Replace all uses of the tracer's create_span in the Public API with the observability recorder, to create the metrics in addition to the existing spans.
  • Remove metric instrumentation points from the core (can be enabled via a preprocessor flag).
  • Updated the histogram name to db.client.operation.duration as per RFC and the Otel semantic conventions
  • Added db.system.name attribute to metrics
  • Renamed outcome to error.type. If an error code is not one of the known Couchbase error categories, the value for error.type is now _OTHER.
  • Bug fix: Always include couchbase.retries span attribute, even if it's 0, as per RFC

@DemetrisChr DemetrisChr requested a review from Copilot November 21, 2025 13:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR moves metric instrumentation points from the core layer to the Public API layer, standardizing observability handling across the codebase. The changes align metric attributes with OpenTelemetry conventions by renaming the "outcome" field to "error.type" and updating the meter name from "db.couchbase.operations" to "db.client.operation.duration".

Key Changes:

  • Introduced a new observability_recorder abstraction that encapsulates both tracing and metrics recording
  • Updated metric attribute field names to follow OpenTelemetry conventions
  • Moved metric instrumentation from core HTTP/KV command handlers to Public API operation handlers

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core/impl/observability_recorder.{hxx,cxx} New abstraction unifying span and metric recording for operations
core/metrics/meter_wrapper.cxx Updated to use new error_type attribute and added db.system.name tag
core/metrics/constants.hxx Added new meter_name constant for standardized metric naming
test/test_unit_metrics.cxx Updated tests to reflect new error.type attribute and db.system.name tag
test/test_integration_meter.cxx Refactored to use Public API instead of core operations for testing
core/impl/*.cxx Migrated from span-only tracking to observability_recorder for unified observability
core/io/{mcbp,http}_command.hxx Wrapped existing core-level metric recording in preprocessor guard

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

avsej and others added 2 commits November 25, 2025 15:36
test/test_integration_tracer.cxx:255:3: note: Same iterator is used with containers 'span->int_tags()' that are temporaries or defined in different scopes.
  REQUIRE(span->int_tags().find("couchbase.retries") != span->int_tags().end());
  ^
test/test_integration_tracer.cxx:342:3: error: Same iterator is used with containers 'span->int_tags()' that are temporaries or defined in different scopes. [iterators3]
  REQUIRE(span->int_tags().find("couchbase.retries") != span->int_tags().end());
@avsej avsej merged commit 3a38349 into couchbase:main Nov 30, 2025
40 of 45 checks passed
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