This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 231
Support for 128 bits trace ids #507
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...r-core/src/main/java/io/jaegertracing/internal/exceptions/TraceIdOutOfBoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2018, The Jaeger Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.jaegertracing.internal.exceptions; | ||
|
||
public class TraceIdOutOfBoundException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = 2332452744805504972L; | ||
|
||
public TraceIdOutOfBoundException(String message) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,10 @@ | |
|
||
package io.jaegertracing.internal.propagation; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
// copy/pasted from brave.internal.HexCodec 4.1.1 to avoid build complexity | ||
@Slf4j | ||
final class HexCodec { | ||
|
||
/** | ||
|
@@ -26,13 +29,30 @@ final class HexCodec { | |
static Long lowerHexToUnsignedLong(String lowerHex) { | ||
int length = lowerHex.length(); | ||
if (length < 1 || length > 32) { | ||
log.debug("token {} size is out of bounds [1, 32]", lowerHex); | ||
return null; | ||
} | ||
|
||
// trim off any high bits | ||
int beginIndex = length > 16 ? length - 16 : 0; | ||
|
||
return lowerHexToUnsignedLong(lowerHex, beginIndex); | ||
return hexToUnsignedLong(lowerHex, beginIndex, Math.min(beginIndex + 16, lowerHex.length())); | ||
} | ||
|
||
/** | ||
* Parses a 1 to 32 character higher-hex string with no prefix into an unsigned long, tossing any | ||
* bits lower than 64. | ||
* | ||
* @return a 64 bit long, meaning that negative values are the overflow of Java's 32 bit long | ||
*/ | ||
static Long higherHexToUnsignedLong(String higherHex) { | ||
int length = higherHex.length(); | ||
if (length > 32 || length < 1) { | ||
log.debug("token {} size is out of bounds [1, 32]", higherHex); | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be worth a log message somewhere about this... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done at debug Level. I though warn would be also good since it's a situation that should arrive rarely or that can cause tracing to malfunction. |
||
} | ||
|
||
return hexToUnsignedLong(higherHex, 0, Math.max(length - 16, 0)); | ||
} | ||
|
||
/** | ||
|
@@ -41,9 +61,9 @@ static Long lowerHexToUnsignedLong(String lowerHex) { | |
* | ||
* @return a 64 bit long, meaning that negative values are the overflow of Java's 32 bit long | ||
*/ | ||
static Long lowerHexToUnsignedLong(String lowerHex, int index) { | ||
static Long hexToUnsignedLong(String lowerHex, int index, int endIndex) { | ||
long result = 0; | ||
for (int endIndex = Math.min(index + 16, lowerHex.length()); index < endIndex; index++) { | ||
for (; index < endIndex; index++) { | ||
char c = lowerHex.charAt(index); | ||
result <<= 4; | ||
if (c >= '0' && c <= '9') { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be documented in readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is currently no structured documentation in the README for the env variable. The only thing the current documentation : jaegertracing/documentation#157
Do you want to create a place where all the env variable are listed and documented ?