Skip to content

Added export of connection basic metrics#3891

Merged
vladvildanov merged 7 commits intofeat/observabilityfrom
vv-connection-basic-metric-export
Jan 5, 2026
Merged

Added export of connection basic metrics#3891
vladvildanov merged 7 commits intofeat/observabilityfrom
vv-connection-basic-metric-export

Conversation

@vladvildanov
Copy link
Collaborator

Description of change

Please provide a description of the change here.

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Copy link
Contributor

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 pull request adds export of connection basic metrics to the Redis client by refactoring the connection count metric from an UpDownCounter to an Observable Gauge and implementing an event-based system for collecting connection lifecycle metrics.

Key Changes

  • Refactored connection count metric from UpDownCounter to Observable Gauge with callback-based collection
  • Added event dispatching for connection lifecycle events (created, timeout relaxed, handoff)
  • Integrated event listeners to export metrics for maintenance notifications and connection operations
  • Updated error type formatting to include "other:" prefix for better categorization

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
redis/observability/recorder.py Replaced record_connection_count with init_connection_count using callback pattern; updated parameter names
redis/observability/metrics.py Changed connection count from UpDownCounter to Observable Gauge; updated parameter names
redis/observability/attributes.py Added DB_CLIENT_CONNECTION_NAME attribute constant
redis/observability/providers.py Added optional import handling for OpenTelemetry SDK
redis/event.py Added new event classes and listener implementations for connection metrics
redis/connection.py Added get_connection_count method and event dispatching in connection pools
redis/maint_notifications.py Integrated event dispatcher and added event emission for maintenance operations
tests/test_observability/test_recorder.py Updated mocks from create_gauge and removed record_connection_count tests
tests/test_observability/test_config.py Removed unused telemetry option tests
tests/test_maint_notifications.py Added comprehensive tests for event emission
tests/test_connection_pool.py Added tests for connection creation event emission
tests/test_client.py Added tests for connection count initialization
Comments suppressed due to low confidence (1)

redis/observability/recorder.py:109

  • The docstring example on line 109 is outdated. It still shows a string pool name being passed, but the function signature has been changed to accept a connection_pool object. Update the example to reflect the new signature.
    Example:
        >>> start = time.monotonic()
        >>> # ... create connection ...
        >>> record_connection_create_time('ConnectionPool<localhost:6379>', time.monotonic() - start)

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

vladvildanov and others added 5 commits December 22, 2025 16:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@petyaslavova petyaslavova left a comment

Choose a reason for hiding this comment

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

LGTM.

@vladvildanov vladvildanov merged commit f46b1f5 into feat/observability Jan 5, 2026
4 checks passed
@vladvildanov vladvildanov deleted the vv-connection-basic-metric-export branch January 5, 2026 13:32
vladvildanov added a commit that referenced this pull request Feb 16, 2026
* Added intrastructure and integration point with OTel (#3864)

* Added intrastructure and integration point with OTel

* Added check for enabled metric groups

* Applied comments

* Added export of operation duration metric  (#3881)

* Added stadalone client metrics export

* Added support for cluster client

* Removed unused dispatchers and test

* Added export of resiliency metrics (#3888)

* Added stadalone client metrics export

* Added support for cluster client

* Added error metric export on fail commands for standalone client

* Removed unused dispatchers and test

* Added on error metrics export for cluster

* Added export of maint notification count metric

* Apply comments

* Remove redundant Union

* Added export of connection basic metrics (#3891)

* Added export of connection basic metrics

* Added new error category attribute

* Update tests/test_observability/test_recorder.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/test_observability/test_recorder.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply comments

* Applied comments

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Added pub/sub and stream lag metrics export (#3898)

* Added export of connection basic metrics

* Added new error category attribute

* Added pub/sub and stream lag metrics export

* Added metric export form XREAD

* Update redis/client.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update redis/event.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Applied comments

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Added OTel benchmark test (#3903)

* Added export of connection basic metrics

* Added new error category attribute

* Added pub/sub and stream lag metrics export

* Added metric export form XREAD

* Added benchmark tests

* Added error output

* Added env variable for otel host

* Fixed endpoint

* Added iterations and results averaging

* Use unsecured gRPC

* Added --with-command-metrics argument

* Removed incorrect identation

* Update benchmarks/otel_benchmark.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update benchmarks/otel_benchmark.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update benchmarks/otel_benchmark.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update benchmarks/otel_benchmark.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update benchmarks/otel_benchmark.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Added export of connection advanced metrics (#3910)

* Added export of connection advanced metrics

* Update tests/test_connection_pool.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update redis/observability/metrics.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactored kwargs instead of args

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Added CSC metrics export (#3911)

* Added export of connection advanced metrics

* Added CSC metrics export

* Revert changes

* Added observable gauge registry and refactored observables metric export

* Fixed case with trackin non-cachable cache tracking

* Added memory and CPU usage (#3933)

* Added full benchmark tests + fixes

* Added Memory and CPU usage calculation

* Removed events dispatching overhead, refactored metrics attributes (#3934)

* Removed events dispatching overhead, refactored metrics attributes

* Fixed incorrect retry attempts, changed indexes to named parameters

* Fixed issue with connection attribute and metric recording

* Added async recorders and registry (#3950)

* Added async recorders and registry

* Removed async registry

* Added more coverage

* Added bucket override configuration (#3952)

* Added async recorders and registry

* Added bucket override configuration

* Removed async registry

* Added more coverage

* Fixed version constraints, removed ubused imports

* Moved module desription on top of file

* Remove async instrumentations (#3953)

* Fix tests and codestyle

* Fixed missing parameters

* Fixed tests

* Fixed tests

* Fixed tests

* Marked argument as unused

* Fixed tests

* Added missing metric export

* Fixes units and pool name attribute

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Updated test for pool name attribute

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Updates more tests

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Linter

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Added try...except blocks for recorder functions

* Added documentation

* Updated wordlist

* Update redis/cluster.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update redis/connection.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update redis/connection.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update pyproject.toml

Co-authored-by: Elena Kolevska <elena-kolevska@users.noreply.github.com>

* Codestyle fixes

* Fixed metric export

* Fixed assertions

* Added geo failover metric export

* Codestyle fixes

---------

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Elena Kolevska <elena@kolevska.com>
Co-authored-by: Elena Kolevska <elena-kolevska@users.noreply.github.com>
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