Skip to content

feat: add support for disabling built-in metrics - #539

Closed
enocom wants to merge 1 commit into
mainfrom
telemetry
Closed

enocom wants to merge 1 commit into
mainfrom
telemetry

Conversation

@enocom

@enocom enocom commented Mar 30, 2026 •

Copy link
Copy Markdown
Member

This commit adds the OpenTelemetry-based wiring to report on internal operations to improve connectivity. To disable this internal metric collection, set enable_builtin_telemetry to False when creating a Connector or AsyncConnector.

Note: the synchronous connector provides a full port of system metrics. The asynchronous connector by comparison cannot support bytes sent and bytes received because asyncpg doesn't provide a handle on the
underlying socket. If asyncpg accepts MagicStack/asyncpg#1313, we'll be able to
improve this situation.

Fixes #449.

@enocom
enocom force-pushed the telemetry branch 4 times, most recently from 5ac6cf3 to c5b9ab5 Compare March 31, 2026 01:52
@enocom
enocom marked this pull request as ready for review April 7, 2026 21:01
@enocom
enocom requested a review from a team as a code owner April 7, 2026 21:01
@enocom

enocom commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

I'll resolve these conflicts shortly here.

@enocom
enocom marked this pull request as draft April 8, 2026 15:49
@enocom

enocom commented Apr 8, 2026 •

Copy link
Copy Markdown
Member Author

Putting back in draft while I sort out the build errors. This is ready for review now.

@enocom enocom assigned rhatgadkar-goog and unassigned nancynh Apr 9, 2026
@enocom
enocom force-pushed the telemetry branch 4 times, most recently from b85e31f to a862a83 Compare April 9, 2026 02:56
@enocom
enocom marked this pull request as ready for review April 9, 2026 03:00
This commit adds the OpenTelemetry-based wiring to report on internal
operations to improve connectivity. To disable this internal metric
collection, set enable_builtin_telemetry to False when creating a
Connetor or AsyncConnector.

Fixes #449
attrs.dial_status = DIAL_SUCCESS
latency_ms = (time.monotonic() - start_time) * 1000
mr.record_dial_count(attrs)
mr.record_dial_latency(latency_ms)

@rhatgadkar-goog rhatgadkar-goog Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are you missing record_open_connections here? The sync connector records this

expires.
enable_builtin_telemetry (bool): Enable built-in telemetry that
reports connector metrics to the
alloydb.googleapis.com/client/connector metric prefix in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this a public Cloud Monitoring metric? Can customers view this metric? I don't see it in this list: https://docs.cloud.google.com/monitoring/api/metrics_gcp_a_b.

Or is this an internal Monarch metric?


def __del__(self) -> None:
try:
if getattr(self, "_closed", True) is False:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: To simplify this, I think you can just call if not self._closed

@enocom

enocom commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Superseded by a 9-PR stack that splits this work into reviewable pieces, starting at #566.

The content is the same feature with two deliberate changes: InstrumentedSocket is now installed only when telemetry is enabled, so callers who opt out do not carry its makefile()/close() semantics; and enable_builtin_telemetry defaults to False until the last PR (#574) flips it, so the moment telemetry starts running for everyone is one line to revert.

Splitting it also turned up an unrelated bug that was hiding in the restructuring — _remove_cached raised KeyError over the top of the real error on a failed dial against static connection info. That is #567.

Closing in favour of the stack.

@enocom enocom closed this Sep 18, 2026
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.

Add support for system metrics

3 participants