-
Notifications
You must be signed in to change notification settings - Fork 872
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
Instrument spring-kafka batch message listeners #3922
Merged
trask
merged 4 commits into
open-telemetry:main
from
mateuszrzeszutek:spring-kafka-batch
Aug 27, 2021
Merged
Changes from all commits
Commits
Show all changes
4 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
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
30 changes: 0 additions & 30 deletions
30
...pi/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinkExtractor.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
...api/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilder.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,33 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.SpanBuilder; | ||
import io.opentelemetry.api.trace.SpanContext; | ||
|
||
/** A builder that exposes methods for adding links to a span. */ | ||
public interface SpanLinksBuilder { | ||
|
||
/** | ||
* Adds a link to the newly created {@code Span}. Invalid {@link SpanContext}s will be skipped. | ||
* | ||
* @param spanContext the context of the linked {@code Span}. | ||
* @return this. | ||
* @see SpanBuilder#addLink(SpanContext) | ||
*/ | ||
SpanLinksBuilder addLink(SpanContext spanContext); | ||
|
||
/** | ||
* Adds a link to the newly created {@code Span}. Invalid {@link SpanContext}s will be skipped. | ||
* | ||
* @param spanContext the context of the linked {@code Span}. | ||
* @param attributes the attributes of the {@code Link}. | ||
* @return this. | ||
* @see SpanBuilder#addLink(SpanContext) | ||
*/ | ||
SpanLinksBuilder addLink(SpanContext spanContext, Attributes attributes); | ||
} |
30 changes: 30 additions & 0 deletions
30
...src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksBuilderImpl.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,30 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.trace.SpanBuilder; | ||
import io.opentelemetry.api.trace.SpanContext; | ||
|
||
final class SpanLinksBuilderImpl implements SpanLinksBuilder { | ||
private final SpanBuilder spanBuilder; | ||
|
||
SpanLinksBuilderImpl(SpanBuilder spanBuilder) { | ||
this.spanBuilder = spanBuilder; | ||
} | ||
|
||
@Override | ||
public SpanLinksBuilder addLink(SpanContext spanContext) { | ||
spanBuilder.addLink(spanContext); | ||
return this; | ||
} | ||
|
||
@Override | ||
public SpanLinksBuilder addLink(SpanContext spanContext, Attributes attributes) { | ||
spanBuilder.addLink(spanContext, attributes); | ||
return this; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...i/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/SpanLinksExtractor.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,31 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.api.instrumenter; | ||
|
||
import io.opentelemetry.api.trace.SpanContext; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.context.propagation.ContextPropagators; | ||
import io.opentelemetry.context.propagation.TextMapGetter; | ||
|
||
/** Extractor of span links for a request. */ | ||
@FunctionalInterface | ||
public interface SpanLinksExtractor<REQUEST> { | ||
|
||
/** | ||
* Extracts {@link SpanContext}s that should be linked to the newly created span and adds them to | ||
* {@code spanLinks}. | ||
*/ | ||
void extract(SpanLinksBuilder spanLinks, Context parentContext, REQUEST request); | ||
|
||
/** | ||
* Returns a new {@link SpanLinksExtractor} that will extract a {@link SpanContext} from the | ||
* request using configured {@code propagators}. | ||
*/ | ||
static <REQUEST> SpanLinksExtractor<REQUEST> fromUpstreamRequest( | ||
ContextPropagators propagators, TextMapGetter<REQUEST> getter) { | ||
return new PropagatorBasedSpanLinksExtractor<>(propagators, getter); | ||
} | ||
} | ||
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
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.
cc: @anuraaga new Instrumenter API addition