-
Notifications
You must be signed in to change notification settings - Fork 53
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
fix: httpjson callables to trace attempts (started, failed) #3300
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
6635019
add test to confirm tracer attempts failed
diegomarquezp 944e8d6
simplify test for retries
diegomarquezp 1edf557
Merge remote-tracking branch 'origin/main' into fix-httpjson-retry-me…
diegomarquezp 4db1d2b
extend tracer tests to every test
diegomarquezp 9ab23d5
fix test vars initialization
diegomarquezp 6364aab
add retrial exhaustion check
diegomarquezp ae1eb44
Merge branch 'main' into fix-httpjson-retry-metrics
diegomarquezp 1ebc3a2
restore ApiException expected in test
diegomarquezp 25e778f
Merge branch 'fix-httpjson-retry-metrics' of https://github.com/googl…
diegomarquezp b363a29
enable Disabled ITs
diegomarquezp 5c11e10
try fixing multipleattempts test
diegomarquezp 9b48dbe
Merge branch 'main' into fix-httpjson-retry-metrics
diegomarquezp c8e8a7d
fix multiple attempts httpjson test (thanks @lqiu96)
diegomarquezp af3adb5
Merge remote-tracking branch 'refs/remotes/origin/fix-httpjson-retry-…
diegomarquezp 035be17
extract tracer factory to its own method
diegomarquezp 8e2a58a
add comments
diegomarquezp 8f3331e
Merge branch 'fix-httpjson-retry-metrics' of https://github.com/googl…
diegomarquezp f647320
Merge remote-tracking branch 'origin/main' into fix-httpjson-retry-me…
diegomarquezp 2df2e9f
licence
diegomarquezp e7bc1c3
formalize tests
diegomarquezp e2385ad
rename vars, extend ApiTracer
diegomarquezp 58e874a
move initialization to contained class
diegomarquezp 87f807a
fix order of methods
diegomarquezp e57b4db
remove retries exhausted
diegomarquezp 58a0daa
Revert "remove retries exhausted"
diegomarquezp 325eba4
record attempt failed when retries are exhausted
diegomarquezp 2120960
adjust retries count in retryingtest
diegomarquezp 0630fdf
Merge branch 'main' into fix-httpjson-retry-metrics
diegomarquezp 9697e8a
empty commit to retry tests
diegomarquezp 065b01f
remove flaky tests
diegomarquezp 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
81 changes: 81 additions & 0 deletions
81
gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/testing/TestApiTracer.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,81 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following disclaimer | ||
* in the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name of Google LLC nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.google.api.gax.httpjson.testing; | ||
|
||
import com.google.api.gax.tracing.ApiTracer; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import org.threeten.bp.Duration; | ||
|
||
/** | ||
* Test tracer that keeps count of different events. See {@link TestApiTracerFactory} for more | ||
* details. | ||
*/ | ||
public class TestApiTracer implements ApiTracer { | ||
|
||
private final AtomicInteger attemptsStarted = new AtomicInteger(); | ||
private final AtomicInteger attemptsFailed = new AtomicInteger(); | ||
private final AtomicBoolean retriesExhausted = new AtomicBoolean(false); | ||
|
||
public TestApiTracer() {} | ||
|
||
public AtomicInteger getAttemptsStarted() { | ||
return attemptsStarted; | ||
} | ||
|
||
public AtomicInteger getAttemptsFailed() { | ||
return attemptsFailed; | ||
} | ||
|
||
public AtomicBoolean getRetriesExhausted() { | ||
return retriesExhausted; | ||
} | ||
|
||
@Override | ||
public void attemptStarted(int attemptNumber) { | ||
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. 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 |
||
attemptsStarted.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void attemptStarted(Object request, int attemptNumber) { | ||
attemptsStarted.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void attemptFailed(Throwable error, Duration delay) { | ||
attemptsFailed.incrementAndGet(); | ||
} | ||
|
||
@Override | ||
public void attemptFailedRetriesExhausted(Throwable error) { | ||
attemptsFailed.incrementAndGet(); | ||
retriesExhausted.set(true); | ||
} | ||
}; |
52 changes: 52 additions & 0 deletions
52
.../gax-httpjson/src/test/java/com/google/api/gax/httpjson/testing/TestApiTracerFactory.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,52 @@ | ||
/* | ||
* Copyright 2024 Google LLC | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are | ||
* met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions and the following disclaimer | ||
* in the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name of Google LLC nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.google.api.gax.httpjson.testing; | ||
|
||
import com.google.api.gax.tracing.ApiTracer; | ||
import com.google.api.gax.tracing.ApiTracerFactory; | ||
import com.google.api.gax.tracing.SpanName; | ||
|
||
/** | ||
* Produces a {@link TestApiTracer}, which keeps count of the attempts made and attempts | ||
* made-and-failed. It also keeps count of the operations failed and when the retries have been | ||
* exhausted. | ||
*/ | ||
public class TestApiTracerFactory implements ApiTracerFactory { | ||
private final TestApiTracer instance = new TestApiTracer(); | ||
|
||
public TestApiTracer getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public ApiTracer newTracer(ApiTracer parent, SpanName spanName, OperationType operationType) { | ||
return instance; | ||
} | ||
} |
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
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 like the idea of a test tracer in general. On the other hand, we should only implement what is needed for our use cases, so that we have lower chance to run into issues that are not related to our PR. For example, maybe we don't need to implement
attemptFailedRetriesExhausted
.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.
Done
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.
@lqiu96 figured that the retries exhausted event records the missing failed attempt in our tests:
I'll keep this implementation and its retries exhausted flag.