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

W3c trace context #188

Merged
merged 6 commits into from
Jan 20, 2021
Merged

W3c trace context #188

merged 6 commits into from
Jan 20, 2021

Conversation

jack-berg
Copy link
Contributor

@jack-berg jack-berg commented Jan 13, 2021

A different take on the W3C trace context APIs using a newly introduced Headers interface. This is a unifying interface for InboundHeaders and OutboundHeaders, and makes up for a deficiency in InboundHeader that has necessitated ExtendedInboundHeaders.

If we like this approach, we could deprecate InboundHeaders and OutboundHeaders and slowly transition all usages to Headers. Because Headers extends both InboundHeaders and OutboundHeaders, this transition could be done in small steps.

I've also included a default implementation of the new headers interface called ConcurrentHashMapHeaders, which is thread safe and uses a ConcurrentHashMap as the backing data structure for the implementation. It seems necessary to provide users of the new APIs a reasonable default implementation for ease of use.

Closes #169.
Closes #170.

@jack-berg jack-berg marked this pull request as ready for review January 14, 2021 17:47
@jack-berg
Copy link
Contributor Author

I want to call out that my introduction of ConcurrentHashMapHeaders into the newrelic-api module seems to break convention a bit, since I'm not sure I see any other instantiatable objects defined in that module.

What's our stance on including classes in the newrelic-api module?

I can always move the class into some internal only module (it will be a useful tool for migrating away from InboundHeaders and OutboundHeaders internally), but I do think having it in published will ease the consumption of the APIs for our customers.

…d, and DistributedTracePayload. add test coverage insertDistributedTraceHeaders and acceptDistributedTraceHeaders
@jack-berg
Copy link
Contributor Author

I've added an additional PR to resurrect an updated version of a test class for the new distributed trace APIs.

I've also deprecated the old APIs.

Copy link
Contributor

@jasonjkeller jasonjkeller left a comment

Choose a reason for hiding this comment

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

Overall I like this approach better than the previous one. I think it results in a cleaner API and sets us up to deprecate/remove cruft going forward.

acceptDistributedTracePayload(payload);
}

void publicApiAcceptDistributedTracePayload(DistributedTracePayload payload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What the.... did these methods actually serve any purpose? Or am I seeing correctly that all they did was wrap another method call? Weird...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're seeing it correctly. I didn't understand either. Went back to the PR where the code was added and didn't find any context that indicated intent.

@jasonjkeller
Copy link
Contributor

jasonjkeller commented Jan 14, 2021

I want to call out that my introduction of ConcurrentHashMapHeaders into the newrelic-api module seems to break convention a bit, since I'm not sure I see any other instantiatable objects defined in that module.

What's our stance on including classes in the newrelic-api module?

I can always move the class into some internal only module (it will be a useful tool for migrating away from InboundHeaders and OutboundHeaders internally), but I do think having it in published will ease the consumption of the APIs for our customers.

@jack-berg I think that our approach has generally been that if any critical problem occurs a customer should always be able to quickly remove the agent jar and be confident that all API calls left in their code will simply default to a NoOp version. Because of this approach we can make the guarantee that there is zero impact on the customers environment when the agent jar is removed but API calls remain in their code.

While I'm having a hard time thinking of anything that might actually go wrong with the ConcurrentHashMapHeaders implementation included as is it might be best to take precautions and try our best to maintain such a guarantee. If we can make that guarantee with it in place (and I think we probably can) then I could be convinced to leave the implementation in place.

@jack-berg
Copy link
Contributor Author

@jasonjkeller that seems like a good guarantee to make. In this case, I believe the addition of ConcurrentHashMapHeaders should not jeopardize that. For both the insert and accept call, the client is responsible for providing a Headers instance. If the agent jar isn't on the classpath, I believe the no op implementation of Transaction will just receive the Headers instance and not do anything with them.

@jasonjkeller
Copy link
Contributor

@tspring @XiXiaPdx Based on the discussion above, can either of you think of any reasons to not include the ConcurrentHashMapHeaders implementation in the public API? If not, I say we call this PR good and merge it.

Here's a practical example of the new APIs being used to propagate DT headers via Kafka record headers:
https://github.com/jasonjkeller/kafka-examples

@jack-berg jack-berg merged commit f522baf into main Jan 20, 2021
@jack-berg jack-berg deleted the w3c-trace-context branch January 20, 2021 23: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
3 participants