-
Notifications
You must be signed in to change notification settings - Fork 829
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
log tracing #2446
Merged
Merged
log tracing #2446
Changes from all commits
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
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
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); | ||
} | ||
} | ||
|
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
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.
I'm curious why these changed.
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.
The diff is not very helpful. We just inserted one line and changed the position numbers on the rest.