-
Notifications
You must be signed in to change notification settings - Fork 1k
Spring starter thread details #14449
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
Merged
trask
merged 8 commits into
open-telemetry:main
from
zeitlinger:spring-starter-thread-details
Aug 22, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
759bae8
add thread details to spring starter
zeitlinger 3920f1e
add thread details to spring starter
zeitlinger 2d5fc13
fix
zeitlinger 989ddc8
prefer lambda
zeitlinger c74e86a
pr feedback
zeitlinger e4e5d70
pr feedback
zeitlinger 2b94507
fix
zeitlinger 7b58ee9
Update instrumentation/spring/spring-boot-autoconfigure/src/main/java…
zeitlinger 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
32 changes: 32 additions & 0 deletions
32
.../spring/autoconfigure/internal/instrumentation/thread/ThreadDetailsAutoConfiguration.java
This file contains hidden or 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,32 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.thread; | ||
|
|
||
| import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation; | ||
| import io.opentelemetry.instrumentation.thread.internal.AddThreadDetailsSpanProcessor; | ||
| import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| /** | ||
| * This class is internal and is hence not for public use. Its APIs are unstable and can change at | ||
| * any time. | ||
| */ | ||
| @ConditionalOnEnabledInstrumentation(module = "common.thread-details", enabledByDefault = false) | ||
| @Configuration | ||
| @SuppressWarnings("OtelPrivateConstructorForUtilityClass") | ||
| public class ThreadDetailsAutoConfiguration { | ||
|
|
||
| @Bean | ||
| public AutoConfigurationCustomizerProvider threadDetailOtelCustomizer() { | ||
| return p -> | ||
| p.addTracerProviderCustomizer( | ||
| (builder, config) -> { | ||
| builder.addSpanProcessor(new AddThreadDetailsSpanProcessor()); | ||
| return builder; | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
35 changes: 0 additions & 35 deletions
35
...c/test/groovy/io/opentelemetry/javaagent/tooling/AddThreadDetailsSpanProcessorTest.groovy
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...A-INF/services/io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| io.opentelemetry.instrumentation.resources.ResourceProviderPropertiesCustomizer | ||
| io.opentelemetry.instrumentation.resources.internal.ResourceProviderPropertiesCustomizer |
This file contains hidden or 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
39 changes: 39 additions & 0 deletions
39
...a/io/opentelemetry/instrumentation/thread/internal/AddThreadDetailsSpanProcessorTest.java
This file contains hidden or 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.thread.internal; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
|
||
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.sdk.trace.ReadWriteSpan; | ||
| import io.opentelemetry.sdk.trace.SpanProcessor; | ||
| import io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class AddThreadDetailsSpanProcessorTest { | ||
|
|
||
| private final ReadWriteSpan span = mock(ReadWriteSpan.class); | ||
|
|
||
| private final SpanProcessor spanProcessor = new AddThreadDetailsSpanProcessor(); | ||
|
|
||
| @Test | ||
| void onStart() { | ||
| assertThat(spanProcessor.isStartRequired()).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| void setThreadAttributes() { | ||
| Thread thread = Thread.currentThread(); | ||
| spanProcessor.onStart(Context.root(), span); | ||
|
|
||
| verify(span).setAttribute(ThreadIncubatingAttributes.THREAD_ID, thread.getId()); | ||
| verify(span).setAttribute(ThreadIncubatingAttributes.THREAD_NAME, thread.getName()); | ||
| verifyNoMoreInteractions(span); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../test/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| io.opentelemetry.instrumentation.resources.ResourceProviderPropertiesCustomizerTest$Provider | ||
| io.opentelemetry.instrumentation.resources.internal.ResourceProviderPropertiesCustomizerTest$Provider |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.