Repository navigation
To remove cross module internal utility usage from trace propagators #8955
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
Open
NithinU2802
wants to merge
10
commits into
open-telemetry:main
Choose a base branch
from
NithinU2802:fix/trace-propagator-internal-utilities
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+196
−25
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bc61372
fix: to remove trace propagators use of api internal utilities
NithinU2802 fd873d4
fix: to restore trace propagators in NoSharedInternalCodeTest as remo…
NithinU2802 50508cd
fix: to update inline null or empty string checks
NithinU2802 d285917
refactor: to move temporarybuffer to api.impl with imports update
NithinU2802 4323448
patch: update apidiffs as per the guidance
NithinU2802 9b956d8
Merge branch 'main' into fix/trace-propagator-internal-utilities
NithinU2802 a5ee03c
test: to cover stringutils and empty trace/span id for jaeger and b3 …
NithinU2802 8d1630e
Merge branch 'fix/trace-propagator-internal-utilities' of https://git…
NithinU2802 bd4b16d
fix: to revert the snapshot versions of apidiffs changes
NithinU2802 930e0a9
fix and test: jaegerpropagator remove split values null check and add…
NithinU2802 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| Comparing source compatibility of opentelemetry-api-1.68.0-SNAPSHOT.jar against opentelemetry-api-1.67.0.jar | ||
| No changes. | ||
| +++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.api.impl.TemporaryBuffers (not serializable) | ||
| +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. | ||
| +++ NEW SUPERCLASS: java.lang.Object | ||
| +++ NEW METHOD: PUBLIC(+) STATIC(+) char[] chars(int) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
69 changes: 69 additions & 0 deletions
69
...e-propagators/src/main/java/io/opentelemetry/extension/trace/propagation/StringUtils.java
This file contains hidden or 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,69 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.extension.trace.propagation; | ||
|
|
||
| import java.util.Objects; | ||
| import javax.annotation.concurrent.Immutable; | ||
|
|
||
| /** | ||
| * Utilities for working with strings. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| @Immutable | ||
| final class StringUtils { | ||
|
|
||
| /** | ||
| * Returns {@code value} left-padded with zeroes to at least {@code minLength} characters. | ||
| * | ||
| * <p>If {@code value} is already at least {@code minLength} characters long, it is returned | ||
| * unchanged. | ||
| * | ||
| * @param value the string to pad | ||
| * @param minLength the minimum length of the returned string | ||
| * @return the padded string, or {@code value} if it already meets the minimum length | ||
| */ | ||
| static String padLeft(String value, int minLength) { | ||
| return padStart(value, minLength, '0'); | ||
| } | ||
|
|
||
| /** | ||
| * Returns a string, of length at least {@code minLength}, consisting of {@code string} prepended | ||
| * with as many copies of {@code padChar} as are necessary to reach that length. For example, | ||
| * | ||
| * <ul> | ||
| * <li>{@code padStart("7", 3, '0')} returns {@code "007"} | ||
| * <li>{@code padStart("2010", 3, '0')} returns {@code "2010"} | ||
| * </ul> | ||
| * | ||
| * <p>See {@link java.util.Formatter} for a richer set of formatting capabilities. | ||
| * | ||
| * <p>This method was copied almost verbatim from Guava library method | ||
| * com.google.common.base.Strings#padStart(java.lang.String, int, char). | ||
| * | ||
| * @param string the string which should appear at the end of the result | ||
| * @param minLength the minimum length the resulting string must have. Can be zero or negative, in | ||
| * which case the input string is always returned. | ||
| * @param padChar the character to insert at the beginning of the result until the minimum length | ||
| * is reached | ||
| * @return the padded string | ||
| */ | ||
| private static String padStart(String string, int minLength, char padChar) { | ||
| Objects.requireNonNull(string); | ||
| if (string.length() >= minLength) { | ||
| return string; | ||
| } | ||
| StringBuilder sb = new StringBuilder(minLength); | ||
| for (int i = string.length(); i < minLength; i++) { | ||
| sb.append(padChar); | ||
| } | ||
| sb.append(string); | ||
| return sb.toString(); | ||
| } | ||
|
|
||
| private StringUtils() {} | ||
| } | ||
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
...ce-propagators/src/test/java/io/opentelemetry/extension/trace/propagation/CommonTest.java
This file contains hidden or 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,31 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.extension.trace.propagation; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class CommonTest { | ||
|
|
||
| @Test | ||
| void isTraceIdValid() { | ||
| assertThat(Common.isTraceIdValid(null)).isFalse(); | ||
| assertThat(Common.isTraceIdValid("")).isFalse(); | ||
| assertThat(Common.isTraceIdValid("0000000000000001")).isTrue(); | ||
| assertThat(Common.isTraceIdValid("00000000000000000000000000000001")).isTrue(); | ||
| assertThat(Common.isTraceIdValid("000000000000000")).isFalse(); | ||
| assertThat(Common.isTraceIdValid("0000000000000000")).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| void isSpanIdValid() { | ||
| assertThat(Common.isSpanIdValid(null)).isFalse(); | ||
| assertThat(Common.isSpanIdValid("")).isFalse(); | ||
| assertThat(Common.isSpanIdValid("0000000000000001")).isTrue(); | ||
| assertThat(Common.isSpanIdValid("0000000000000000")).isFalse(); | ||
| } | ||
| } |
This file contains hidden or 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
32 changes: 32 additions & 0 deletions
32
...opagators/src/test/java/io/opentelemetry/extension/trace/propagation/StringUtilsTest.java
This file contains hidden or 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,32 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.extension.trace.propagation; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class StringUtilsTest { | ||
|
|
||
| @Test | ||
| void padLeft() { | ||
| assertThat(StringUtils.padLeft("value", 10)).isEqualTo("00000value"); | ||
| } | ||
|
|
||
| @Test | ||
| void padLeft_length_does_not_exceed_minimum() { | ||
| assertThat(StringUtils.padLeft("value", 3)).isEqualTo("value"); | ||
| assertThat(StringUtils.padLeft("value", -10)).isEqualTo("value"); | ||
| assertThat(StringUtils.padLeft("value", 0)).isEqualTo("value"); | ||
| } | ||
|
|
||
| @Test | ||
| void padLeft_throws_for_null_value() { | ||
| assertThatThrownBy(() -> StringUtils.padLeft(null, 10)) | ||
| .isInstanceOf(NullPointerException.class); | ||
| } | ||
| } |
This file contains hidden or 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
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.
I think this is only used in the
opentelemetry-extension-trace-propagatorsmodule and tests, so let's go ahead and remove it fromio.opentelemetry.api.internal.StringUtils.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.
This method is also used here in SdkLoggerTest.java, Line 79