-
Notifications
You must be signed in to change notification settings - Fork 848
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
setStatus method conforms to the specified behavior regarding status … #6808
base: main
Are you sure you want to change the base?
Conversation
…code priorities and description handling Relate to open-telemetry#6797
this.status = StatusData.create(statusCode, description); | ||
} | ||
return this; | ||
synchronized (lock) { |
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.
We use spotless to ensure consist code formatting. Please run ./gradlew spotlessApply
.
@@ -418,22 +418,37 @@ private void addTimedEvent(EventData timedEvent) { | |||
|
|||
@Override | |||
public ReadWriteSpan setStatus(StatusCode statusCode, @Nullable String description) { | |||
if (statusCode == null) { | |||
return this; | |||
} |
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.
Why remove this?
|
||
// Prevent setting a lower priority status | ||
if (currentStatusCode == StatusCode.OK) { | ||
logger.log(Level.FINE, "Calling setStatus() on a Span that is already set to OK."); |
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.
Only log a warning the target status code is != StatusCode.OK
.
if (statusCode == StatusCode.ERROR) { | ||
this.status = StatusData.create(statusCode, description); // Allow description for ERROR | ||
} else { | ||
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses |
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.
#nit: Let's skip the extra allocation if the status code doesn't stand to change.
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses | |
if (currentStatusCode != statusCode) { | |
this.status = StatusData.create(statusCode, null); // Ignore description for non-ERROR statuses | |
} |
@jack-berg I have fix and added the suggestions as required, sorry for the delay and all the hassle i had so many mistake trying to fix and find a way to run ./gradlew spotlessApply which made me rewrite most of the time from scratch. I have spend hours with every trick there is trying to setup gradle and jdk on my console to run spotless but it keeps showing unable to detect jdk 17 and gradle. Please do let me know if there are still any corrections to be made from the new PR and if by chance there is another method i can go about to ensure the consist code formatting on my PR. thanks |
Yes the build requires jdk 17, and gradle detects jdk versions in a very specific way as documented here: https://docs.gradle.org/current/userguide/toolchains.html#sec:auto_detection My personal preference for installing / managing JDKs is to use sdkman!, which makes it super easy to install multiple versions and toggle between them as needed. Gradle will automatically look for jdks that match the project requirements where sdkman installs them. |
|
*Gradle build in build.gradle.kts had failed during spotless check because the plugin org.graalvm.buildtools.native was not found -Solution: I have applied a plugin and made it work *spotlessJavaCheck task failed because certain files did not conform to the formatting rules defined in the Spotless configuration -Solution: Initiated an auto fix using ./gradlew :sdk:trace:spotlessApply *Lastly as requested i initiated ./gradlew spotlessApply to ensure a consist code formating and the build was successful with no errors! Relate to open-telemetry#6797
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6808 +/- ##
============================================
+ Coverage 90.38% 90.47% +0.09%
- Complexity 6584 6602 +18
============================================
Files 731 731
Lines 19722 19742 +20
Branches 1931 1938 +7
============================================
+ Hits 17825 17862 +37
+ Misses 1300 1288 -12
+ Partials 597 592 -5 ☔ View full report in Codecov by Sentry. |
This PR seems to have a bunch of unrelated changes in it. And, it definitely needs unit tests for the new behavior. |
@jkwatson Is there anything i can do to fix this? I will be very much happy to help. Sorry for all the inconveniences, if there is a way i can run the required unit test so we can have everything back to normal again i will be happy to. |
You need to write unit tests for the new behavior. Note that the build checks aren't passing because of code coverage. And, please get the diff into a clean state. Look at the 'Files changed' in the PR and get it into a state where only the changes needed for this PR are there. |
.gitignore
Outdated
|
||
.fake |
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.
please revert this change
buildSrc/build.gradle.kts
Outdated
kotlinGradle { | ||
ktlint().editorConfigOverride(mapOf( | ||
"indent_size" to "2", | ||
"continuation_indent_size" to "2", | ||
"max_line_length" to "160", | ||
"insert_final_newline" to "true", | ||
"ktlint_standard_no-wildcard-imports" to "disabled", | ||
"ktlint_standard_max-line-length" to "disabled", | ||
"ktlint_standard_trailing-comma-on-call-site" to "disabled", | ||
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled", | ||
"ktlint_standard_wrapping" to "disabled" | ||
)) | ||
target("**/*.gradle.kts") | ||
} |
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.
the comments that were here before were important. Please restore this file to what it was before.
hs_err_pid13224.log
Outdated
|
||
vm_info: OpenJDK 64-Bit Server VM (17.0.13+11-LTS) for windows-amd64 JRE (17.0.13+11-LTS), built on Oct 9 2024 05:44:29 by "" with MS VC++ 16.10 / 16.11 (VS2019) | ||
|
||
END. |
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.
please remove this file
@jkwatson Seems like we still had a test failure in L437 and 438 in sdk and build should i try to remove them instead? |
buildSrc/build.gradle.kts
Outdated
} | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} |
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.
do you need changes to this file for some reason? If not, please revert.
??? The failure is that there is no test coverage. Please add a case to the unit tests for this. |
@jkwatson So i have been trying to add a case to the unit test , i also tried adding something like this too in the SdkSpanTest but it didn't even make it pass the build test. Just wanted to show some of the tries i did with a comment before tagging you for some pointers. check it out
}` |
buildSrc/build.gradle.kts
Outdated
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.0.0") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21") | ||
implementation("org.owasp:dependency-check-gradle:10.0.4") | ||
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.7.1") |
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.
please revert all changes to this file.
I don't care all that much about asserting the fact that things were logged. Much more important is making sure that the span status hasn't changed. Take a look at some of the other tests in the SdkSpanTest. I bet you'll find one that is testing the various status state changes that you could either add to, or base a new test case on. |
…ngChangedAfterEnd test Ref Fix Span#setStatus open-telemetry#6797
if (currentStatusCode == StatusCode.OK) { | ||
return this; // Do not allow lower priority status to override OK | ||
} else if (currentStatusCode == StatusCode.ERROR && statusCode == StatusCode.UNSET) { | ||
logger.log(Level.WARNING, "Cannot set status to UNSET when current status is ERROR."); |
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 don't think this should be a WARNING. Probably just FINE like we have for the other status changes.
|
||
// Prevent setting a lower priority status. | ||
if (currentStatusCode == StatusCode.OK) { | ||
return this; // Do not allow lower priority status to override OK |
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.
why remove the logging that was here before?
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
@@ -119,11 +119,25 @@ void setUp() { | |||
@Test | |||
void nothingChangedAfterEnd() { |
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.
The change you made doesn't only apply after the span has ended, does it? This test is testing the case of things not changing after span ending.
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.
take a look at the test called setStatusCannotOverrideStatusOK
. Write a new test that looks much like that one that tests the case(s) that you've introduced.
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.
Just added a new test for that ,though not sure if that is the required approach, still open for corrections. Also pardon some of my mistakes or modification , I'm still learning and improving on myself, and i always try to use different approach whenever needed , which if i knew how to perfectly run a test on my changes to know if they are okay it would have been much easier, so i have to check and get corrections here. Thanks for your time , let me know if the test i wrote is that which you need to be added.
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SdkSpan.java
Outdated
Show resolved
Hide resolved
// Prevent setting a lower priority status. | ||
if (currentStatusCode == StatusCode.OK) { | ||
return this; // Do not allow lower priority status to override OK | ||
} else if (currentStatusCode == StatusCode.ERROR && statusCode == StatusCode.UNSET) { |
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 else
is redundant, since the if
above it returns already.
Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: John Watson <jkwatson@gmail.com>
Co-authored-by: John Watson <jkwatson@gmail.com>
…ectly under the specified conditions, maintaining the integrity of the span's status. Ref Fix Span#setStatus open-telemetry#6797
…code priorities and description handling
Relate to #6797