-
Notifications
You must be signed in to change notification settings - Fork 886
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
Add asynchronous tracing to Spring Boot Autoconfigure WithSpanAspect #2618
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
Refactor MethodSpanStrategies to instrumentation-api, update Spring a…
…spect
- Loading branch information
commit a4abac8fd977ca73d69cf9e94585a5582a40537b
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
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
80 changes: 80 additions & 0 deletions
80
...st/groovy/io/opentelemetry/instrumentation/api/tracer/async/Jdk8MethodStrategyTest.groovy
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,80 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.tracer.async | ||
|
||
import io.opentelemetry.context.Context | ||
import io.opentelemetry.instrumentation.api.tracer.BaseTracer | ||
import spock.lang.Specification | ||
|
||
import java.util.concurrent.CompletableFuture | ||
import java.util.concurrent.CompletionException | ||
|
||
class Jdk8MethodStrategyTest extends Specification { | ||
BaseTracer tracer | ||
|
||
Context context | ||
|
||
def underTest = Jdk8MethodStrategy.INSTANCE | ||
|
||
void setup() { | ||
tracer = Mock() | ||
context = Mock() | ||
} | ||
|
||
def "ends span on completed future"() { | ||
when: | ||
underTest.end(tracer, context, CompletableFuture.completedFuture("completed")) | ||
|
||
then: | ||
1 * tracer.end(context) | ||
} | ||
|
||
def "ends span exceptionally on failed future"() { | ||
given: | ||
def exception = new CompletionException() | ||
def future = new CompletableFuture<String>() | ||
future.completeExceptionally(exception) | ||
|
||
when: | ||
underTest.end(tracer, context, future) | ||
|
||
then: | ||
1 * tracer.endExceptionally(context, exception) | ||
} | ||
|
||
def "ends span on future when complete"() { | ||
def future = new CompletableFuture<String>() | ||
|
||
when: | ||
underTest.end(tracer, context, future) | ||
|
||
then: | ||
0 * tracer._ | ||
|
||
when: | ||
future.complete("completed") | ||
|
||
then: | ||
1 * tracer.end(context) | ||
} | ||
|
||
def "ends span exceptionally on future when completed exceptionally"() { | ||
def future = new CompletableFuture<String>() | ||
def exception = new Exception() | ||
|
||
when: | ||
underTest.end(tracer, context, future) | ||
|
||
then: | ||
0 * tracer._ | ||
|
||
when: | ||
future.completeExceptionally(exception) | ||
|
||
then: | ||
1 * tracer.endExceptionally(context, exception) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...o/opentelemetry/instrumentation/api/tracer/async/SynchronousMethodSpanStrategyTest.groovy
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,39 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.tracer.async | ||
|
||
import io.opentelemetry.context.Context | ||
import io.opentelemetry.instrumentation.api.tracer.BaseTracer | ||
import spock.lang.Specification | ||
|
||
class SynchronousMethodSpanStrategyTest extends Specification { | ||
BaseTracer tracer | ||
|
||
Context context | ||
|
||
def underTest = SynchronousMethodSpanStrategy.INSTANCE | ||
|
||
void setup() { | ||
tracer = Mock() | ||
context = Mock() | ||
} | ||
|
||
def "ends span on any result"() { | ||
when: | ||
underTest.end(tracer, context, "any result") | ||
|
||
then: | ||
1 * tracer.end(context) | ||
} | ||
|
||
def "ends span on null result"() { | ||
when: | ||
underTest.end(tracer, context, null) | ||
|
||
then: | ||
1 * tracer.end(context) | ||
} | ||
} |
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
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.
maybe
.async
->.future
or.promise
.async
feels a bit generalThere 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'd probably gravitate to
reactive
but that's probably as general asasync
is. Of your suggestions I thinkfuture
probably fits better in the Java ecosystem.