-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix autoconfigure for spring boot 3 (#7784)
See #7312
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
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
32 changes: 32 additions & 0 deletions
32
...try/instrumentation/spring/autoconfigure/webmvc/WebMvcFilterAutoConfigurationSpring6.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,32 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.spring.autoconfigure.webmvc; | ||
|
||
import io.opentelemetry.api.OpenTelemetry; | ||
import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetry; | ||
import jakarta.servlet.Filter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.filter.OncePerRequestFilter; | ||
import org.springframework.web.servlet.DispatcherServlet; | ||
|
||
/** Configures {@link SpringWebMvcTelemetry} for tracing. */ | ||
@Configuration | ||
@EnableConfigurationProperties(WebMvcProperties.class) | ||
@ConditionalOnProperty(prefix = "otel.springboot.web", name = "enabled", matchIfMissing = true) | ||
@ConditionalOnClass({Filter.class, OncePerRequestFilter.class, DispatcherServlet.class}) | ||
@ConditionalOnBean(OpenTelemetry.class) | ||
public class WebMvcFilterAutoConfigurationSpring6 { | ||
|
||
@Bean | ||
public Filter otelWebMvcInstrumentationFilter(OpenTelemetry openTelemetry) { | ||
return SpringWebMvcTelemetry.create(openTelemetry).createServletFilter(); | ||
} | ||
} |