Skip to content

Commit

Permalink
Fix elastic-search sanitization for bulk queries (#1870)
Browse files Browse the repository at this point in the history
* support sanitization for str body response

* add CHANGELOG entry

---------

Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
  • Loading branch information
nemoshlag and shalevr authored Jun 25, 2023
1 parent 256d8ce commit c9004bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,3 +479,7 @@ def test_body_sanitization(self, _):
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),
)

0 comments on commit c9004bd

Please sign in to comment.