feat: add opentelemetry-instrumentation-aerospike#4154
Open
KimSoungRyoul wants to merge 17 commits intoopen-telemetry:mainfrom
Open
feat: add opentelemetry-instrumentation-aerospike#4154KimSoungRyoul wants to merge 17 commits intoopen-telemetry:mainfrom
KimSoungRyoul wants to merge 17 commits intoopen-telemetry:mainfrom
Conversation
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
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)
13d11d3 to
a75032d
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.
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-contribto 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
put,get,select,exists,remove,touch,operate,append,prepend,incrementbatch_read,batch_write,batch_operate,batch_remove,batch_applyquery,scanapply,scan_apply,query_applytruncate,info_allCaptured 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 ifcapture_key=Trueis 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
How Has This Been Tested?
I have added both unit tests and functional tests (using Docker) to verify the instrumentation.
tox -e py311-test-instrumentation-aerospike): Verified span creation, attribute population (including newdb.system.name,db.user,db.aerospike.bins), and context propagation for all supported operations.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.tox -e lint-instrumentation-aerospike(pylint score 10.00/10).Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.