-
Notifications
You must be signed in to change notification settings - Fork 871
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
Remove validations for noop instrument names and units #5146
Merged
jack-berg
merged 7 commits into
open-telemetry:main
from
breedx-splk:remove_noop_validations
Mar 8, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e80836f
remove validations for noop implementation
breedx-splk 17bf153
remove unwanted tests
breedx-splk 97dae08
remove unused
breedx-splk 5237c6a
remove instrument unit checks from ValidationUtil and move temporaril…
breedx-splk c983d43
move tests
breedx-splk e8c871b
rename ValidationUtil to ApiUsageLogger
breedx-splk 3d6a84a
fix tests by removing logs check (not important here)
breedx-splk 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
44 changes: 44 additions & 0 deletions
44
api/all/src/main/java/io/opentelemetry/api/internal/ApiUsageLogger.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,44 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.api.internal; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Helper for API misuse logging. | ||
* | ||
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public final class ApiUsageLogger { | ||
|
||
public static final String LOGGER_NAME = "io.opentelemetry.ApiUsageLogger"; | ||
|
||
private static final Logger API_USAGE_LOGGER = Logger.getLogger(LOGGER_NAME); | ||
|
||
/** | ||
* Log the {@code message} to the {@link #LOGGER_NAME API Usage Logger}. | ||
* | ||
* <p>Log at {@link Level#FINEST} and include a stack trace. | ||
*/ | ||
public static void log(String message) { | ||
log(message, Level.FINEST); | ||
} | ||
|
||
/** | ||
* Log the {@code message} to the {@link #LOGGER_NAME API Usage Logger}. | ||
* | ||
* <p>Log includes a stack trace. | ||
*/ | ||
public static void log(String message, Level level) { | ||
if (API_USAGE_LOGGER.isLoggable(level)) { | ||
API_USAGE_LOGGER.log(level, message, new AssertionError()); | ||
} | ||
} | ||
|
||
private ApiUsageLogger() {} | ||
} |
107 changes: 0 additions & 107 deletions
107
api/all/src/main/java/io/opentelemetry/api/internal/ValidationUtil.java
This file was deleted.
Oops, something went wrong.
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
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
api/all/src/test/java/io/opentelemetry/api/internal/ApiUsageLoggerTest.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 The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.api.internal; | ||
|
||
import static java.util.logging.Level.WARNING; | ||
|
||
import io.github.netmikey.logunit.api.LogCapturer; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
class ApiUsageLoggerTest { | ||
|
||
@RegisterExtension | ||
LogCapturer apiUsageLogs = LogCapturer.create().captureForLogger(ApiUsageLogger.LOGGER_NAME); | ||
|
||
@Test | ||
void log() { | ||
ApiUsageLogger.log("thing", WARNING); | ||
apiUsageLogs.assertContains("thing"); | ||
} | ||
} |
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.
These validation utils can be moved to the SDK now.
checkInstrumentName
probably makes most sense inSdkMeter
.checkValidInstrumentUnit
should be removed given that the spec has clarified that SDKs aren't supposed to do any validation on unit. You can do that removal in this PR if you want, or just move the method toAbstractInstrumentBuilder
.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.
Bumping this @breedx-splk.
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.
Ok, I moved
checkValidInstrumentName()
to a new internal utility class in the sdk, rather thanSdkMeter
. This seemed a little more SRPy to me.I did move the unit check over to the
AbstractInstrumentBuilder
class, and I think removal of that should be tackled in a separate PR.Once those were moved out of the validator, the only things that were left in
ValidationUtil
were the logging methods, so I renamed it toApiUsageLogger
.