Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix elastic-search sanitization for bulk queries #1870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
)