Skip to content

Conversation

richardstartin
Copy link
Contributor

@richardstartin richardstartin commented Jul 6, 2020

This one comes from a support issue where Kafka Mirrormaker was reportedly base64 encoding Kafka headers, and the user was complaining that we wouldn't parse the trace IDs. I've investigated and there is no way to detect that this has happened, except trying to base64 decode the headers. Doing this "just in case" in the Kafka instrumentation would give other users a significant performance regression so we don't want to do this unless absolutely necessary. This isn't really the tracer's fault and the user needs to prevent infrastructure from mangling header data, but attempting to base64 decode in a catch block in DDId.from helps the user diagnose and fix their problem, avoids breaking trace lineage if they can't fix it right away, whilst preventing other users from paying for it.

@richardstartin richardstartin requested a review from a team as a code owner July 6, 2020 11:07
…s with their infrastructure and avoid breaking the trace lineage
@richardstartin richardstartin force-pushed the rgs/base64-ddid branch 2 times, most recently from 0479918 to 20f65b4 Compare July 6, 2020 13:10
Comment on lines +65 to +80
} catch (NumberFormatException e) {
// we have reports of Kakfa mirror maker base64 encoding record headers
// attempting to base64 decode the ids here rather than in the Kafka instrumentation
// helps users understand they have a problem without making other users pay for it
if (null != s) {
try {
String decoded = new String(BASE64.decode(s), StandardCharsets.ISO_8859_1);
log.debug(
"id {} was base 64 encoded to {}, it was decoded but this indicates there is a problem elsewhere in your system",
decoded,
s);
return DDId.create(parseUnsignedLong(decoded), decoded);
} catch (Exception ignored) {

}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just wondering if considering this is a special case, we should add this catch block to the place that extracts the headers into a context, perhaps by creating a second TextMapExtractAdapter to handle the failure case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I addressed that in the description of the PR.

@richardstartin richardstartin merged commit 1033f9b into master Jul 6, 2020
@richardstartin richardstartin deleted the rgs/base64-ddid branch July 6, 2020 18:28
@github-actions github-actions bot added this to the 0.57.0 milestone Jul 6, 2020
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.

3 participants