Skip to main content

Elasticsearch Python client tracing

Trace calls made through the elasticsearch Python client with the maintained traceAI-elasticsearch package. It supports elasticsearch 8.x and 9.x, sync (Elasticsearch) and async (AsyncElasticsearch).

pip install traceAI-elasticsearch
from elasticsearch import Elasticsearch
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_elasticsearch import ElasticsearchInstrumentor

provider = register(project_type=ProjectType.OBSERVE, project_name="es-demo")
ElasticsearchInstrumentor().instrument(tracer_provider=provider)
client = Elasticsearch("http://localhost:9200")
hits = client.search(index="products", query={"match": {"title": "shoes"}}, size=3)["hits"]["hits"]
provider.force_flush()

With the fi-instrument launcher or FI_INSTRUMENTATIONS, no code is needed: importing elasticsearch turns this integration on.

Span Kind Records
elasticsearch.search RETRIEVER index, query and filters, size or kNN k as top-k, kNN field, num_candidates and query-vector dimension count, result count, ids, scores, total hits, documents (id, score, content)
elasticsearch.knn_search RETRIEVER the same, on client releases that still have the call
elasticsearch.index / elasticsearch.bulk / elasticsearch.delete VECTOR_DB index, document id or write count, the documents written, bulk error and failure counts, result and version

Every span has gen_ai.provider.name and db.system set to elasticsearch, the operation, and the index name (db.vector.index.name, db.namespace). Only the outermost client call is traced. Exceptions set the span status to ERROR, error.type and the HTTP status code, and are re-raised unchanged; server error messages are never exported.

Embedding vectors are never exported: query_vector is dropped from requests, and numeric arrays in documents are replaced by a placeholder. Raw request and response bodies are not recorded, and no span carries a whole response: only the fields listed above. Query text, filters, written documents and result content are captured by default, capped, and removed by the standard hide settings (TraceConfig(hide_inputs=True, hide_outputs=True) passed to instrument(config=...), or the FI_HIDE_* variables); the directional hide_input_* and hide_output_* flags suppress the corresponding content. Numeric and boolean content values follow the same rules as text. Result ids, scores and top score are result content: any output hide setting removes them along with the documents, while counts and total hits stay. Array-likes (numpy arrays and scalars) are treated as vectors, and values of unknown types are reduced to a type note, never to their text. The package does not send requests to Elasticsearch on its own.

The client also has a built-in OpenTelemetry integration of its own (OTEL_PYTHON_INSTRUMENTATION_ELASTICSEARCH_ENABLED). If both are active a call produces two spans; set that variable to false when you use this package.

Metadata

Release files for traceAI-elasticsearch 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceAI-elasticsearch 0.1.0
File Size Uploaded Provenance Actions
traceai_elasticsearch-0.1.0.tar.gz 7.2 kB Without provenance Details for traceai_elasticsearch-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-elasticsearch 0.1.0
File Interpreter ABI Platform Actions
traceai_elasticsearch-0.1.0-py3-none-any.whl Python 3 none any Details for traceai_elasticsearch-0.1.0-py3-none-any.whl

Total release size: 15.5 kB

Release files / traceai_elasticsearch-0.1.0.tar.gz

Download URL traceai_elasticsearch-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
de907246d2e66bd406dec5384a02049ef195ba62dab1b7f699e7e2fc3c7f87a2
BLAKE2b-256 checksum
How to use checksums
2b4367a953fef356487ad3fc47ea182ee8b6195428c51884e45a298c752d2c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / traceai_elasticsearch-0.1.0-py3-none-any.whl

Download URL traceai_elasticsearch-0.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f45f3950abd1532e69573c9b626bcc1ff9ff4c2123e0ce381f1efa281a96eb9d
BLAKE2b-256 checksum
How to use checksums
f19a4f2a88d22f0250951298bc32d89f7ec825d2cb4b41d1bcd6628d60313064
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for traceAI-elasticsearch 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page