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 json collector decorator and switch json parsing library to orjson #553

Merged
merged 15 commits into from
Dec 11, 2023

Conversation

aspacca
Copy link
Contributor

@aspacca aspacca commented Dec 8, 2023

Bug/Enhancement

What does this PR do?

Fix a bug related to event list from field expander where, if json content type was single and spanning more than 1000 lines the circuit breaker of the json decorator will kick in

It also switch orjson parsing library over ujson one

Why is it important?

A regression was introduced on json decorator while refactored with #544
Also switching from usjon to orjson improves performances

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.md

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@aspacca aspacca self-assigned this Dec 8, 2023
Andrea Spacca and others added 11 commits December 8, 2023 11:56
Bumps [boto3](https://github.com/boto/boto3) from 1.33.7 to 1.33.9.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](boto/boto3@1.33.7...1.33.9)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@aspacca aspacca force-pushed the pre-v1.11.0-release branch from 448411d to 80e19be Compare December 8, 2023 02:58
Copy link

github-actions bot commented Dec 8, 2023

File Coverage Lines Branches Missing
All files 100% 100% 100%
main_aws.py 100% 100% 100%
handlers/__init__.py 100% 100% 100%
handlers/aws/__init__.py 100% 100% 100%
handlers/aws/cloudwatch_logs_trigger.py 100% 100% 100%
handlers/aws/exceptions.py 100% 100% 100%
handlers/aws/handler.py 100% 100% 100%
handlers/aws/kinesis_trigger.py 100% 100% 100%
handlers/aws/replay_trigger.py 100% 100% 100%
handlers/aws/s3_sqs_trigger.py 100% 100% 100%
handlers/aws/sqs_trigger.py 100% 100% 100%
handlers/aws/utils.py 100% 100% 100%
share/__init__.py 100% 100% 100%
share/config.py 100% 100% 100%
share/environment.py 100% 100% 100%
share/events.py 100% 100% 100%
share/expand_event_list_from_field.py 100% 100% 100%
share/factory.py 100% 100% 100%
share/include_exlude.py 100% 100% 100%
share/json.py 100% 100% 100%
share/logger.py 100% 100% 100%
share/multiline.py 100% 100% 100%
share/secretsmanager.py 100% 100% 100%
share/utils.py 100% 100% 100%
share/version.py 100% 100% 100%
shippers/__init__.py 100% 100% 100%
shippers/composite.py 100% 100% 100%
shippers/es.py 100% 100% 100%
shippers/factory.py 100% 100% 100%
shippers/logstash.py 100% 100% 100%
shippers/shipper.py 100% 100% 100%
storage/__init__.py 100% 100% 100%
storage/decorator.py 100% 100% 100%
storage/factory.py 100% 100% 100%
storage/payload.py 100% 100% 100%
storage/s3.py 100% 100% 100%
storage/storage.py 100% 100% 100%

Minimum allowed coverage is 100%

Generated by 🐒 cobertura-action against 1dc42f3

Copy link
Contributor

@girodav girodav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I wonder if we should also make the PR title more descriptive. Pre-release sounds a bit generic.

@@ -313,8 +313,11 @@ def get_trigger_type_and_config_source(event: dict[str, Any]) -> tuple[str, str]
and "eventSource" in body["Records"][0]
):
event_source = body["Records"][0]["eventSource"]
if event_source not in _available_triggers:
raise Exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add an exception message of some kind here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a message only where the exceptions will bubble up to the function callar

Comment on lines +240 to +245
single: list[tuple[Union[StorageReader, bytes], int, int, bytes]] = list(
[
(data, starting_offset, ending_offset, newline)
for data, starting_offset, ending_offset, newline, _ in iterator
]
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this DS a bit hard to digest. Maybe a comment with an example entry could help

Comment on lines 283 to 284
# if it's not a json object we can just forward the content by lines
if not json_collector_state.has_an_object_start:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not seem to be consistent with the if statement below. Should this use json_collector_state.is_a_json_object instead?

@aspacca aspacca changed the title Pre v1.11.0 release Fix json collector decorator and switch json parsing library to orjson Dec 8, 2023
@aspacca
Copy link
Contributor Author

aspacca commented Dec 8, 2023

@girodav addressed your comment, please review :)

girodav
girodav previously approved these changes Dec 8, 2023
@aspacca
Copy link
Contributor Author

aspacca commented Dec 9, 2023

@girodav , I fixed a couple of comments and review status was dismissed

feel free to re-approve and merge, thanks :)

@girodav girodav merged commit bc661c2 into elastic:main Dec 11, 2023
4 checks passed
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.

2 participants