Skip to content

feat: add opentelemetry-instrumentation-aerospike#4154

Open
KimSoungRyoul wants to merge 17 commits intoopen-telemetry:mainfrom
KimSoungRyoul:feat/add-aerospike-instrumentation
Open

feat: add opentelemetry-instrumentation-aerospike#4154
KimSoungRyoul wants to merge 17 commits intoopen-telemetry:mainfrom
KimSoungRyoul:feat/add-aerospike-instrumentation

Conversation

@KimSoungRyoul
Copy link

@KimSoungRyoul KimSoungRyoul commented Jan 31, 2026

Description

I am the original author and maintainer of the standalone library opentelemetry-instrumentation-aerospike, which is currently published on PyPI. I am contributing this library to pypi: opentelemetry-python-contrib to integrate it into the official ecosystem.

To support this integration, I volunteer to serve as the Code Owner for this component. I currently hold the ownership of the PyPI package and am ready to transfer it (or grant publish permissions) to the OpenTelemetry maintainers to facilitate automated releases.

Features

Supported Operations


  • Single Record Operations: put, get, select, exists, remove, touch, operate, append, prepend, increment
  • Batch Operations: batch_read, batch_write, batch_operate, batch_remove, batch_apply
  • Query/Scan Operations: query, scan
  • UDF Operations: apply, scan_apply, query_apply
  • Admin Operations: truncate, info_all

Captured Telemetry Data


Standard Attributes:

  • db.system.name: Always "aerospike".
  • db.namespace: Aerospike namespace.
  • db.collection.name: Aerospike set name.
  • db.operation.name: The operation being performed (e.g., "GET", "PUT", "QUERY").
  • db.user: The user connected to the database (if configured).
  • server.address: The hostname or IP address of the Aerospike node.
  • server.port: The port of the Aerospike node.
  • db.operation.batch.size: Number of keys in batch operations.

Aerospike-Specific Attributes:

  • db.aerospike.key: The record key (only if capture_key=True is enabled).
  • db.aerospike.bins: List of bins being written or selected (for PUT/SELECT).
  • db.aerospike.generation: Record generation (from GET results).
  • db.aerospike.ttl: Record TTL (from GET results).
  • db.aerospike.udf.module: UDF module name.
  • db.aerospike.udf.function: UDF function name.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

I have added both unit tests and functional tests (using Docker) to verify the instrumentation.

  • Unit Tests (tox -e py311-test-instrumentation-aerospike): Verified span creation, attribute population (including new db.system.name, db.user, db.aerospike.bins), and context propagation for all supported operations.
  • Functional Tests (tox -e docker-tests -- tests/aerospike): Verified integration with a real Aerospike server running in Docker, ensuring correct span generation and attribute values in a real-world scenario.
  • Linting: Passed tox -e lint-instrumentation-aerospike (pylint score 10.00/10).

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

KimSoungRyoul and others added 14 commits January 29, 2026 01:05
Add OpenTelemetry instrumentation for Aerospike Python client (>= 17.0.0).

Supported operations:
- Single record: put, get, select, exists, remove, touch, operate, append, prepend, increment
- Batch: batch_read, batch_write, batch_operate, batch_remove, batch_apply
- Query/Scan: query, scan
- UDF: apply, scan_apply, query_apply
- Admin: truncate, info_all

Features:
- Request/response/error hooks for custom span attributes
- Optional key capture (disabled by default for security)
- Semantic conventions compliant span attributes
- Add ruff noqa comments for import-outside-toplevel
- Use tuple syntax for isinstance() for Python 3.9 compatibility
- Add pylint disable comment for import-outside-toplevel
- Register aerospike in bootstrap_gen.py and README
- Fix scan_apply/query_apply arg parsing with dedicated wrappers
- Cache wrapped methods in __getattr__ to avoid re-wrapping
- Add UDF attribute constants, remove duplicate code and dead code
- Restructure tests, add missing coverage for scan/query/admin ops
…rapper

- Replace 7 duplicate wrapper methods with single _create_traced_wrapper
- Fix IPv6 address parsing in _update_server_info_from_nodes
- Remove unused _original_client field and dead import
- Fix redundant condition in _set_result_attributes
- Change method lists from list to frozenset for O(1) lookup
- Add otaerospike service to docker-compose.yml
- Add aerospike connection check to check_availability.py
- Add aerospike>=17.0.0 to test-requirements.txt
- Add functional tests covering put/get, exists, remove, batch_read,
  query, scan, apply, scan_apply, truncate, error handling, and
  parent span propagation
- Add test_udf.lua for UDF test scenarios
- Reduce return statements in _parse_host_port from 8 to 3
- Suppress too-many-public-methods on test class
… calls

client.query() and client.scan() are factory methods that only create
configuration objects without any DB I/O. The actual database work happens
when .results(), .foreach(), or .execute_background() is called. Previously,
spans were created at factory call time, producing meaningless traces.

Add InstrumentedQueryScan proxy class that intercepts execution methods
and creates spans at the correct point when real DB communication occurs.

fix: address review findings for aerospike instrumentation

- Handle tuple return type from get_nodes() in addition to Node objects
  with .name attribute, preventing silent failure on some client versions
- Separate info_all from admin methods so its command string argument is
  not incorrectly captured as db.namespace
- Wrap non-execution methods in InstrumentedQueryScan to preserve method
  chaining (e.g. query.select().where().results() now correctly traces)
- Implemented instrumentation for Aerospike Python client methods (CRUD, batch, query/scan, UDF, admin).
- Added support for Python 3.9+ and Aerospike client >= 17.0.0.
- Refactored instrumentation logic to use a generic wrapper and configuration-based method mapping for maintainability.
- Included comprehensive unit tests and functional tests against a real Aerospike instance.
- Verified compatibility with context7 documentation (node info parsing, query chaining).

Fix pylint error in Aerospike instrumentation
@KimSoungRyoul KimSoungRyoul requested a review from a team as a code owner January 31, 2026 08:12
@KimSoungRyoul KimSoungRyoul changed the title Feat/add aerospike instrumentation feat: add opentelemetry-instrumentation-aerospike Jan 31, 2026
Wrap request_hook, response_hook, and error_hook calls in try-except
blocks so that user-provided hook exceptions do not break the
instrumented operation. Follows the same pattern used in pymongo
instrumentation. Adds 3 corresponding unit tests.
- Extract hook calling logic into _safe_call_hook helper to reduce
  branches in _traced_method (R0912: too-many-branches)
- Consolidate broad-exception-caught handling into one place (W0718)
- Add too-many-lines pylint disable for test module (C0302)
@KimSoungRyoul KimSoungRyoul force-pushed the feat/add-aerospike-instrumentation branch from 13d11d3 to a75032d Compare February 12, 2026 13:00
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.

1 participant

Comments