mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 02:52:18 +08:00
elasticsearch: don't set body as db statement for bulk requests (#2355)
* elasticsearch: don't set body as db statement for bulk requests bulk requests can be too big and diverse to make sense as db statement. Other than that the sanitizer currently only handles dicts so it's crashing. Closes #2150 Co-authored-by: Jason Mobarak <git@jason.mobarak.name> Co-authored-by: Quentin Pradet <quentin.pradet@gmail.com> * Update CHANGELOG * Please the linter --------- Co-authored-by: Jason Mobarak <git@jason.mobarak.name> Co-authored-by: Quentin Pradet <quentin.pradet@gmail.com>
This commit is contained in:

committed by
GitHub

parent
ada27842bd
commit
ca082a7c52
@ -51,6 +51,8 @@ else:
|
||||
|
||||
Article = helpers.Article
|
||||
|
||||
# pylint: disable=too-many-public-methods
|
||||
|
||||
|
||||
@mock.patch(
|
||||
"elasticsearch.connection.http_urllib3.Urllib3HttpConnection.perform_request"
|
||||
@ -486,3 +488,35 @@ class TestElasticsearchIntegration(TestBase):
|
||||
sanitize_body(json.dumps(sanitization_queries.interval_query)),
|
||||
str(sanitization_queries.interval_query_sanitized),
|
||||
)
|
||||
|
||||
def test_bulk(self, request_mock):
|
||||
request_mock.return_value = (1, {}, "")
|
||||
|
||||
es = Elasticsearch()
|
||||
es.bulk(
|
||||
[
|
||||
{
|
||||
"_op_type": "index",
|
||||
"_index": "sw",
|
||||
"_doc_type": "_doc",
|
||||
"_id": 1,
|
||||
"doc": {"name": "adam"},
|
||||
},
|
||||
{
|
||||
"_op_type": "index",
|
||||
"_index": "sw",
|
||||
"_doc_type": "_doc",
|
||||
"_id": 1,
|
||||
"doc": {"name": "adam"},
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
spans_list = self.get_finished_spans()
|
||||
self.assertEqual(len(spans_list), 1)
|
||||
span = spans_list[0]
|
||||
|
||||
# Check version and name in span's instrumentation info
|
||||
self.assertEqualSpanInstrumentationInfo(
|
||||
span, opentelemetry.instrumentation.elasticsearch
|
||||
)
|
||||
|
Reference in New Issue
Block a user