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

HeadersMapInjectAdapter wastes space in headers #88

Open
william-tran opened this issue Jun 15, 2021 · 0 comments
Open

HeadersMapInjectAdapter wastes space in headers #88

william-tran opened this issue Jun 15, 2021 · 0 comments

Comments

@william-tran
Copy link

william-tran commented Jun 15, 2021

https://github.com/opentracing-contrib/java-kafka-client/blob/release-0.1.15/opentracing-kafka-client/src/main/java/io/opentracing/contrib/kafka/HeadersMapInjectAdapter.java#L38

@Override
public void put(String key, String value) {    
    headers.add(key, value.getBytes(StandardCharsets.UTF_8));
}

This just appends headers to the end of the list, and inject can happen repeatedly in processing a message. With baggage, this can result it a lot of repeated data.

We could instead headers.remove(key).add(key, value.getBytes(StandardCharsets.UTF_8)); which trades an iteration over all headers and potential arraylist removals for each key.

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

No branches or pull requests

1 participant