Skip to content

feat(elasticsearch): Add Elasticsearch integration#1

Open
dmkoch wants to merge 3 commits intomasterfrom
dkoch/add-elasticsearch-integration
Open

feat(elasticsearch): Add Elasticsearch integration#1
dmkoch wants to merge 3 commits intomasterfrom
dkoch/add-elasticsearch-integration

Conversation

@dmkoch
Copy link
Copy Markdown
Owner

@dmkoch dmkoch commented Feb 26, 2026

Summary

  • Adds a new ElasticsearchIntegration for the elasticsearch Python client library
  • Instruments search, index, delete, and update operations with spans and breadcrumbs
  • Supports both elasticsearch 7.x (bundled transport) and 8.x/9.x (elastic-transport) APIs
  • Adds CI test configuration with Elasticsearch service container

Test plan

  • CI passes for the new elasticsearch test suite in test-integrations-dbs.yml
  • Verify tox environments are correctly generated for elasticsearch
  • Check that the integration auto-enables when the elasticsearch package is installed

🤖 Generated with Claude Code

Add a new integration for the `elasticsearch` Python client that
instruments search, index, delete, and update operations with spans
and breadcrumbs. Supports both elasticsearch 7.x and 8.x/9.x APIs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 26, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (elasticsearch) Add Elasticsearch integration by dmkoch in #1

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 26, 2026

Codecov Results 📊

32 passed | Total: 32 | Pass Rate: 100% | Execution Time: 260ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +25
Passed Tests 📈 +26
Failed Tests
Skipped Tests 📉 -1

All tests are passing successfully.

❌ Patch coverage is 7.19%. Project has 15042 uncovered lines.
✅ Project coverage is 24.67%. Comparing base (base) to head (head).

Files with missing lines (182)
File Patch % Lines
langchain.py 3.28% ⚠️ 590 Missing
utils.py 48.90% ⚠️ 466 Missing and 73 partials
openai.py 5.38% ⚠️ 510 Missing
utils.py 0.00% ⚠️ 479 Missing
tracing_utils.py 29.73% ⚠️ 416 Missing and 21 partials
__init__.py 5.08% ⚠️ 374 Missing
scope.py 64.80% ⚠️ 289 Missing and 73 partials
starlette.py 5.34% ⚠️ 337 Missing
transport.py 23.54% ⚠️ 302 Missing and 2 partials
client.py 56.57% ⚠️ 218 Missing and 67 partials
mcp.py 5.24% ⚠️ 253 Missing
anthropic.py 9.06% ⚠️ 251 Missing
transaction_profiler.py 35.52% ⚠️ 216 Missing and 10 partials
__init__.py 3.91% ⚠️ 221 Missing
tracing.py 63.79% ⚠️ 172 Missing and 46 partials
langgraph.py 5.29% ⚠️ 215 Missing
utils.py 16.08% ⚠️ 214 Missing
span_processor.py 0.00% ⚠️ 205 Missing
continuous_profiler.py 43.45% ⚠️ 177 Missing and 17 partials
strawberry.py 8.54% ⚠️ 182 Missing
__init__.py 6.01% ⚠️ 172 Missing
spark_driver.py 0.00% ⚠️ 166 Missing
huggingface_hub.py 8.89% ⚠️ 164 Missing
sanic.py 9.60% ⚠️ 160 Missing
aiohttp.py 10.84% ⚠️ 148 Missing
ai_client.py 0.00% ⚠️ 145 Missing
rust_tracing.py 0.00% ⚠️ 143 Missing
aws_lambda.py 31.50% ⚠️ 137 Missing and 5 partials
litellm.py 0.00% ⚠️ 138 Missing
litestar.py 9.59% ⚠️ 132 Missing
starlite.py 8.33% ⚠️ 132 Missing
elasticsearch.py 7.19% ⚠️ 129 Missing
envelope.py 40.82% ⚠️ 116 Missing and 10 partials
falcon.py 8.94% ⚠️ 112 Missing
flask.py 12.50% ⚠️ 112 Missing
spotlight.py 28.47% ⚠️ 103 Missing and 8 partials
asgi.py 20.71% ⚠️ 111 Missing
cohere.py 12.70% ⚠️ 110 Missing
dramatiq.py 0.00% ⚠️ 110 Missing
arq.py 9.92% ⚠️ 109 Missing
asgi.py 0.00% ⚠️ 109 Missing
hub.py 45.60% ⚠️ 105 Missing and 3 partials
pymongo.py 10.17% ⚠️ 106 Missing
beat.py 8.62% ⚠️ 106 Missing
caching.py 0.00% ⚠️ 106 Missing
utils.py 0.00% ⚠️ 103 Missing
templates.py 0.00% ⚠️ 100 Missing
asyncpg.py 11.61% ⚠️ 99 Missing
quart.py 16.10% ⚠️ 99 Missing
wsgi.py 22.66% ⚠️ 99 Missing
gcp.py 0.00% ⚠️ 98 Missing
otlp.py 0.00% ⚠️ 97 Missing
utils.py 13.39% ⚠️ 97 Missing
agent_run.py 0.00% ⚠️ 97 Missing
models.py 4.95% ⚠️ 96 Missing
pyramid.py 13.76% ⚠️ 94 Missing
tornado.py 14.55% ⚠️ 94 Missing
__init__.py 0.00% ⚠️ 93 Missing
bottle.py 11.65% ⚠️ 91 Missing
sessions.py 34.59% ⚠️ 87 Missing and 3 partials
_wsgi_common.py 29.92% ⚠️ 89 Missing and 1 partials
middleware.py 0.00% ⚠️ 90 Missing
agent_run.py 0.00% ⚠️ 90 Missing
stdlib.py 35.82% ⚠️ 86 Missing and 2 partials
tools.py 0.00% ⚠️ 88 Missing
runner.py 0.00% ⚠️ 87 Missing
beam.py 0.00% ⚠️ 84 Missing
loguru.py 11.58% ⚠️ 84 Missing
ray.py 0.00% ⚠️ 84 Missing
__init__.py 4.65% ⚠️ 82 Missing
asyncio.py 0.00% ⚠️ 80 Missing
invoke_agent.py 0.00% ⚠️ 79 Missing
session.py 15.56% ⚠️ 76 Missing
clickhouse_driver.py 17.58% ⚠️ 75 Missing
pure_eval.py 0.00% ⚠️ 73 Missing
rq.py 14.12% ⚠️ 73 Missing
worker.py 22.58% ⚠️ 72 Missing
ariadne.py 14.46% ⚠️ 71 Missing
gql.py 10.13% ⚠️ 71 Missing
sqlalchemy.py 10.26% ⚠️ 70 Missing
fastapi.py 15.85% ⚠️ 69 Missing
monitoring.py 17.07% ⚠️ 68 Missing
graphene.py 12.82% ⚠️ 68 Missing
logging.py 66.01% ⚠️ 52 Missing and 16 partials
transactions.py 0.00% ⚠️ 67 Missing
_queue.py 26.67% ⚠️ 66 Missing
huey.py 17.72% ⚠️ 65 Missing
utils.py 16.00% ⚠️ 63 Missing
streaming.py 0.00% ⚠️ 62 Missing
serializer.py 75.81% ⚠️ 45 Missing and 16 partials
httpx.py 16.44% ⚠️ 61 Missing
api.py 59.73% ⚠️ 60 Missing
propagator.py 0.00% ⚠️ 57 Missing
server.py 0.00% ⚠️ 56 Missing
spark_worker.py 0.00% ⚠️ 56 Missing
graph_nodes.py 0.00% ⚠️ 52 Missing
gnu_backtrace.py 0.00% ⚠️ 51 Missing
_async_common.py 0.00% ⚠️ 51 Missing
socket.py 0.00% ⚠️ 50 Missing
views.py 0.00% ⚠️ 50 Missing
caches.py 16.95% ⚠️ 49 Missing
invoke_agent.py 0.00% ⚠️ 46 Missing
traces.py 47.06% ⚠️ 45 Missing
_asgi_common.py 16.67% ⚠️ 45 Missing
signals_handlers.py 0.00% ⚠️ 44 Missing
_batcher.py 47.50% ⚠️ 42 Missing and 1 partials
utils.py 22.22% ⚠️ 42 Missing and 1 partials
threading.py 62.11% ⚠️ 36 Missing and 6 partials
client.py 0.00% ⚠️ 40 Missing
_sync_common.py 22.00% ⚠️ 39 Missing
executing.py 0.00% ⚠️ 38 Missing
client.py 0.00% ⚠️ 38 Missing
_span_batcher.py 35.71% ⚠️ 36 Missing
serverless.py 0.00% ⚠️ 36 Missing
server.py 0.00% ⚠️ 34 Missing
sys_exit.py 0.00% ⚠️ 32 Missing
launchdarkly.py 0.00% ⚠️ 31 Missing
trytond.py 0.00% ⚠️ 30 Missing
integration.py 0.00% ⚠️ 30 Missing
error_tracing.py 0.00% ⚠️ 29 Missing
tools.py 0.00% ⚠️ 27 Missing
scrubber.py 79.71% ⚠️ 14 Missing and 12 partials
ai_client.py 13.33% ⚠️ 26 Missing
execute_tool.py 0.00% ⚠️ 26 Missing
_openai_completions_api.py 19.35% ⚠️ 25 Missing
redis_cluster.py 26.47% ⚠️ 25 Missing
_werkzeug.py 11.11% ⚠️ 24 Missing
typer.py 0.00% ⚠️ 24 Missing
tasks.py 0.00% ⚠️ 24 Missing
_compat.py 41.03% ⚠️ 23 Missing
monitor.py 67.21% ⚠️ 20 Missing and 3 partials
__init__.py 84.78% ⚠️ 14 Missing and 9 partials
statsig.py 0.00% ⚠️ 23 Missing
queries.py 25.81% ⚠️ 23 Missing
logger.py 43.59% ⚠️ 22 Missing
decorator.py 37.14% ⚠️ 22 Missing
_log_batcher.py 0.00% ⚠️ 21 Missing
attachments.py 27.59% ⚠️ 21 Missing
unraisablehook.py 0.00% ⚠️ 21 Missing
openfeature.py 0.00% ⚠️ 20 Missing
execute_tool.py 0.00% ⚠️ 20 Missing
unleash.py 0.00% ⚠️ 19 Missing
_lru_cache.py 43.33% ⚠️ 17 Missing and 1 partials
model_request.py 0.00% ⚠️ 18 Missing
utils.py 0.00% ⚠️ 16 Missing
atexit.py 56.25% ⚠️ 14 Missing and 1 partials
excepthook.py 56.25% ⚠️ 14 Missing and 1 partials
redis.py 25.00% ⚠️ 15 Missing
feature_flags.py 56.25% ⚠️ 14 Missing
_init_implementation.py 45.83% ⚠️ 13 Missing
cloud_resource_context.py 91.03% ⚠️ 13 Missing
__init__.py 27.78% ⚠️ 13 Missing
_types.py 60.00% ⚠️ 12 Missing
types.py 0.00% ⚠️ 12 Missing
boto3.py 86.49% ⚠️ 10 Missing and 1 partials
redis_py_cluster_legacy.py 26.67% ⚠️ 11 Missing
api.py 37.50% ⚠️ 10 Missing
utils.py 41.18% ⚠️ 10 Missing
handoff.py 0.00% ⚠️ 10 Missing
metrics.py 47.06% ⚠️ 9 Missing
__init__.py 72.41% ⚠️ 8 Missing and 1 partials
dedupe.py 85.00% ⚠️ 6 Missing and 2 partials
_metrics_batcher.py 65.00% ⚠️ 7 Missing
consts.py 0.00% ⚠️ 7 Missing
rb.py 30.00% ⚠️ 7 Missing
_openai_responses_api.py 33.33% ⚠️ 6 Missing
chalice.py 95.59% ⚠️ 3 Missing and 3 partials
debug.py 91.30% ⚠️ 2 Missing and 2 partials
consts.py 0.00% ⚠️ 4 Missing
__init__.py 20.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 4 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 40.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
__init__.py 0.00% ⚠️ 3 Missing
consts.py 99.43% ⚠️ 2 Missing
argv.py 100.00% ⚠️ 2 partials
modules.py 94.12% ⚠️ 1 Missing and 1 partials
agent_workflow.py 71.43% ⚠️ 2 Missing
consts.py 0.00% ⚠️ 1 Missing
consts.py 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    23.67%    24.67%       +1%
==========================================
  Files          189       190        +1
  Lines        19705     19969      +264
  Branches      6420      6476       +56
==========================================
+ Hits          4664      4927      +263
- Misses       15041     15042        +1
- Partials       420       420         —

Generated by Codecov Action

dmkoch and others added 2 commits February 26, 2026 12:20
`start_span()` without `__enter__()` never sets `scope.span = self`,
so the span is not pushed onto the scope's span stack. This means
child spans won't be parented correctly and the span won't be properly
nested in the trace tree. Use `with start_span(...) as span:` to
properly manage the span lifecycle, matching the pattern used by
other integrations like socket, boto3, and pymongo.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ction_info

The function duck-types both v7 and v8/v9 approaches via try/except,
so the major_version parameter was never referenced.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.

1 participant