PCBC-1039: Add LoggingMeter implementation#246
Merged
DemetrisChr merged 1 commit intocouchbase:mainfrom Mar 11, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a PHP LoggingMeter implementation and wires it to the C++ core meter via new PHP/C++ bindings so the SDK can default to logging-based metrics when no external meter is configured.
Changes:
- Implement
LoggingMeter/LoggingValueRecorderin PHP and default to it when no meter is provided. - Add a new PHP extension binding
coreMeterRecordOperationDurationand plumb it throughconnection_handle. - Update the embedded C++ client submodule to include the underlying meter support.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/wrapper/core_span_resource.cxx | Minor cleanup of span resource implementation/includes. |
| src/wrapper/connection_handle.hxx | Exposes a new method to record operation duration into the core meter. |
| src/wrapper/connection_handle.cxx | Implements PHP-array-to-tag-map conversion and forwards duration to the core meter wrapper. |
| src/php_couchbase.cxx | Adds the new PHP function + arginfo and registers it. |
| src/deps/couchbase-cxx-client | Updates C++ core dependency to a revision that supports meter wrapper usage. |
| Couchbase/LoggingValueRecorder.php | Implements a PHP ValueRecorder that calls into the extension binding. |
| Couchbase/LoggingMeter.php | Implements the PHP Meter that returns either a logging recorder or a noop recorder. |
| Couchbase/ClusterOptions.php | Changes meter retrieval to return nullable to enable defaulting to LoggingMeter. |
| Couchbase/Cluster.php | Defaults to LoggingMeter when user didn’t configure a meter. |
Comments suppressed due to low confidence (3)
src/wrapper/connection_handle.hxx:119
tagsis only read/converted and not mutated; consider takingconst zval* tagshere (and in the.cxx) to better document intent and prevent accidental modification.
COUCHBASE_API
void record_core_meter_operation_duration(std::int64_t duration_us, zval* tags);
Couchbase/LoggingMeter.php:45
- With
strict_types=1, prefer!==for string comparisons to avoid unintended type coercion ($name !== ...). Also, explicitly declare method visibility (public function close(): void) for consistency and clarity.
if ($name != ObservabilityConstants::METER_NAME_OPERATION_DURATION) {
// The logging meter only uses the db.client.operation.duration metric
return new NoopValueRecorder();
}
Couchbase/LoggingMeter.php:51
- With
strict_types=1, prefer!==for string comparisons to avoid unintended type coercion ($name !== ...). Also, explicitly declare method visibility (public function close(): void) for consistency and clarity.
function close(): void
{
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
47b1c9b to
b0de5bd
Compare
avsej
reviewed
Mar 3, 2026
avsej
reviewed
Mar 3, 2026
avsej
previously approved these changes
Mar 3, 2026
b0de5bd to
0e3a848
Compare
Matt-Woz
approved these changes
Mar 10, 2026
0e3a848 to
71a3e58
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When no external meter is configured, the SDK must default to the LoggingMeter. Now that metrics are created on the PHP-side, we need to implement the LoggingMeter PHP class.
Changes
coreMeterRecordOperationDurationin the C++ bindings.recordValueis called in theLoggingValueRecorderthe metric is recorded to the core's logging meter via the C++ core API.