Fix elastic-search sanitization for bulk queries (#1870)

* support sanitization for str body response

* add CHANGELOG entry

---------

Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
This commit is contained in:
Nimrod Shlagman
2023-06-25 07:44:57 +03:00
committed by GitHub
parent 256d8ce12d
commit c9004bd375
3 changed files with 10 additions and 0 deletions

View File

@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix elastic-search instrumentation sanitization to support bulk queries
([#1870](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1870))
- Update falcon instrumentation to follow semantic conventions
([#1824](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1824))

View File

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
sanitized_keys = (
"message",
@ -51,6 +52,9 @@ def _unflatten_dict(d):
def sanitize_body(body) -> str:
if isinstance(body, str):
body = json.loads(body)
flatten_body = _flatten_dict(body)
for key in flatten_body:

View File

@ -479,3 +479,7 @@ class TestElasticsearchIntegration(TestBase):
sanitize_body(sanitization_queries.filter_query),
str(sanitization_queries.filter_query_sanitized),
)
self.assertEqual(
sanitize_body(json.dumps(sanitization_queries.interval_query)),
str(sanitization_queries.interval_query_sanitized),
)