Skip to content

Review suggestions #1

Merged
eyalkoren merged 3 commits intoeyalkoren:tracestate-implementationfrom
felixbarny:pull/1024
Feb 9, 2020
Merged

Review suggestions #1
eyalkoren merged 3 commits intoeyalkoren:tracestate-implementationfrom
felixbarny:pull/1024

Conversation

@felixbarny
Copy link

Review suggestions for elastic#1024

Improvements
- MethodHandles are not @nullable
- Both getFirstHeader and getAllHeaders method handles are used in HeadersExtractorBridge
Allows for internal iteration which can be more efficient
- No forced Iterator allocations
- No conversion from Header to String/byte[] necessary
- Consumer is stateless and can be re-used, due to state method argument
@eyalkoren eyalkoren merged commit 0433c7b into eyalkoren:tracestate-implementation Feb 9, 2020
Copy link
Owner

@eyalkoren eyalkoren 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 the suggestions!
The generics makes the APIs slightly more verbal for use, but I admit it's nicer they can enforce the relationships between the carrier and the HeaderGetter using it.
I also like the change of the HeaderGetter API for multiple header values- it indeed makes implementations simpler.


public abstract class AbstractHeaderGetter<T, C> implements HeaderGetter<T, C> {
@Override
public <S> void forEach(String headerName, C carrier, S state, HeaderConsumer<T, S> consumer) {
Copy link
Owner

Choose a reason for hiding this comment

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

Should we encourage hiding from the agent when multiple header values iteration is not supported?

transaction = tracer.startChildTransaction(headersExtractor, headersExtractorBridge, clazz.getClassLoader());
if (headersExtractor != null) {
HeadersExtractorBridge headersExtractorBridge = HeadersExtractorBridge.get(getFirstHeader, getAllHeaders);
transaction = tracer.startChildTransaction(new HeadersExtractorBridge.Extractor(headerExtractor, headersExtractor), headersExtractorBridge, clazz.getClassLoader());
Copy link
Owner

@eyalkoren eyalkoren Feb 9, 2020

Choose a reason for hiding this comment

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

Why not reusing the same instance? See how I changed in the pushed code, let me know if you see a problem with that.

<S> void forEach(String headerName, C carrier, S state, HeaderConsumer<T, S> consumer);

interface HeaderConsumer<T, S> {
void accept(T headerValue, S state);
Copy link
Owner

Choose a reason for hiding this comment

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

The consumer states I currently see are:

  1. before header iteration
  2. during header iteration
  3. after header iteration

Since the caller (i.e. agent) is aware of these states and can easily make the consumer aware of them, I currently don't see a user for the state. What did you have in mind? Can you provide an example?

Copy link
Owner

Choose a reason for hiding this comment

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

OK, implementing now and realized what you had in mind 👍

eyalkoren pushed a commit that referenced this pull request Aug 3, 2020
…rics

Suggested changes for cgroup metrics
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