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

[exporter/chronicleexporter]: Optimize getRawField when field is "body" #1967

Conversation

jsirianni
Copy link
Member

@jsirianni jsirianni commented Nov 13, 2024

Proposed Change

getRawField is called three times for every log record. One of the calls is for reading the "field to send" value. Generally, "field to send" will be body. Body can be either a string or a map.

If field is body, we can read the underlying string or map and return it. No need to use an expensive OTTL expression.

Before

Benchmark_getRawField/String_body-32         	  522542	     21758 ns/op
Benchmark_getRawField/Empty_body-32          	  566030	     23555 ns/op
Benchmark_getRawField/Map_body-32            	  529818	     26545 ns/op
Benchmark_getRawField/Map_body_field-32      	  427791	     29865 ns/op
Benchmark_getRawField/Map_body_field_missing-32         	  477262	     26456 ns/op
Benchmark_getRawField/String_attribute-32               	  480273	     25780 ns/op
Benchmark_getRawField/String_attribute_missing-32       	  477435	     25497 ns/op

After

Benchmark_getRawField/String_body-32         	337642196	         3.273 ns/op
Benchmark_getRawField/Empty_body-32          	416621745	         2.768 ns/op
Benchmark_getRawField/Map_body-32            	 1249923	       947.6 ns/op
Benchmark_getRawField/Map_body_field-32      	   35430	     32555 ns/op
Benchmark_getRawField/Map_body_field_missing-32         	   38889	     34986 ns/op
Benchmark_getRawField/Attribute_log_type-32             	 5498604	       233.0 ns/op
Benchmark_getRawField/Attribute_log_type_missing-32     	 7433708	       164.2 ns/op
Benchmark_getRawField/Attribute_chronicle_log_type-32   	 7790766	       218.1 ns/op
Benchmark_getRawField/Attribute_chronicle_namespace-32  	 4046871	       284.6 ns/op

Benchmarks for string body and map body have almost no costs now.

The tests introduced in #1966 should prove that the output is the same.

Checklist
  • Changes are tested
  • CI has passed

@jsirianni jsirianni force-pushed the joesirianni/bpop-1239-secops-exporter-optimize-field-to-send-body branch from f689508 to 26e99da Compare November 14, 2024 18:01
@jsirianni jsirianni marked this pull request as ready for review November 14, 2024 19:21
@jsirianni jsirianni requested review from dpaasman00 and a team as code owners November 14, 2024 19:21
Base automatically changed from joesirianni/bpop-1240-secops-exporter-add-tests-and-benchmarks-for-getrawfield to release/v1.65.0 November 14, 2024 21:13
Copy link
Contributor

@dpaasman00 dpaasman00 left a comment

Choose a reason for hiding this comment

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

Looks great

@jsirianni jsirianni force-pushed the joesirianni/bpop-1239-secops-exporter-optimize-field-to-send-body branch from 558bf76 to 16e3ffc Compare November 18, 2024 16:21
@jsirianni jsirianni merged commit 8895796 into release/v1.65.0 Nov 18, 2024
15 checks passed
@jsirianni jsirianni deleted the joesirianni/bpop-1239-secops-exporter-optimize-field-to-send-body branch November 18, 2024 21:00
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