forked from cloudfoundry/uaa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cloudfoundry:develop' into develop
- Loading branch information
Showing
13 changed files
with
125 additions
and
50 deletions.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
67 changes: 67 additions & 0 deletions
67
uaa/src/main/java/org/cloudfoundry/identity/uaa/TracingAutoConfiguration.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,67 @@ | ||
package org.cloudfoundry.identity.uaa; | ||
|
||
import javax.servlet.Filter; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
|
||
import brave.CurrentSpanCustomizer; | ||
import brave.SpanCustomizer; | ||
import brave.Tracing; | ||
import brave.context.slf4j.MDCScopeDecorator; | ||
import brave.http.HttpTracing; | ||
import brave.propagation.CurrentTraceContext; | ||
import brave.propagation.CurrentTraceContext.ScopeDecorator; | ||
import brave.propagation.ThreadLocalCurrentTraceContext; | ||
import brave.servlet.TracingFilter; | ||
import brave.spring.webmvc.SpanCustomizingAsyncHandlerInterceptor; | ||
|
||
/** This adds tracing configuration to any web mvc controllers or rest template clients. */ | ||
@Configuration | ||
// Importing a class is effectively the same as declaring bean methods | ||
@Import(SpanCustomizingAsyncHandlerInterceptor.class) | ||
public class TracingAutoConfiguration { | ||
|
||
/** Allows log patterns to use {@code %{traceId}} {@code %{spanId}} and {@code %{userName}} */ | ||
@Bean ScopeDecorator correlationScopeDecorator() { | ||
return MDCScopeDecorator.newBuilder() | ||
.build(); | ||
} | ||
|
||
/** Propagates trace context between threads. */ | ||
@Bean CurrentTraceContext currentTraceContext(ScopeDecorator correlationScopeDecorator) { | ||
return ThreadLocalCurrentTraceContext.newBuilder() | ||
.addScopeDecorator(correlationScopeDecorator) | ||
.build(); | ||
} | ||
|
||
/** Controls aspects of tracing such as the service name that shows up in the UI */ | ||
@Bean Tracing tracing( | ||
@Value("${brave.localServiceName:uaa}") String serviceName, | ||
@Value("${brave.supportsJoin:true}") boolean supportsJoin, | ||
@Value("${brave.traceId128Bit:false}") boolean traceId128Bit, | ||
CurrentTraceContext currentTraceContext) { | ||
return Tracing.newBuilder() | ||
.localServiceName(serviceName) | ||
.supportsJoin(supportsJoin) | ||
.traceId128Bit(traceId128Bit) | ||
.currentTraceContext(currentTraceContext) | ||
.build(); | ||
} | ||
|
||
/** Decides how to name and tag spans. By default they are named the same as the http method. */ | ||
@Bean HttpTracing httpTracing(Tracing tracing) { | ||
return HttpTracing.create(tracing); | ||
} | ||
|
||
/** Creates server spans for HTTP requests */ | ||
@Bean Filter tracingFilter(HttpTracing httpTracing) { | ||
return TracingFilter.create(httpTracing); | ||
} | ||
} | ||
|
Oops, something went wrong.