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

[target-allocator] use json iterator to marshal in server #1410

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

kristinapathak
Copy link
Contributor

@kristinapathak kristinapathak commented Jan 31, 2023

fixes #1336

This time, server functionality is covered by unit tests. Below are the results of the benchmarks, showing using the standard json library (std) vs jsoniter.

test_results.txt

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

after this change goes out, should we upstream a change to the collector that uses a json unmarshal?

Comment on lines 188 to 190
w.Header().Set("Content-Type", "application/json")
err := s.jsonMarshaller.NewEncoder(w).Encode(data)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

do our tests already cover this case? i.e. is this change just going to work with what we do in the collector? using specifically the yaml unmarshal function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That yaml unmarshal function is for a response from the scrape config handler, which doesn't use the jsonHandler function. Here is the marshaling logic for the scrape config endpoint.

The jsonHandler() function is used for the job and targets handlers, both of which have test cases which ensure that this marshaling is still compatible with json.Unmarshal():

@kristinapathak
Copy link
Contributor Author

kristinapathak commented Mar 20, 2023

Latest benchmarks
test_results.txt

@jaronoff97 jaronoff97 merged commit 5534576 into open-telemetry:main Mar 20, 2023
@kristinapathak kristinapathak deleted the json-iterator branch March 20, 2023 23:57
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
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.

[target-allocator] Use json-iter to marshal json
2 participants