Added support for customization of HttpTracing

with this change you can define beans that will get added / set to the `HttpTracing` bean

    fixes gh-886
This commit is contained in:
Marcin Grzejszczak
2018-03-07 06:41:47 -05:00
parent 1e33d6e76e
commit 375f244279
8 changed files with 343 additions and 21 deletions

View File

@@ -762,11 +762,31 @@ Running the preceding method with a value of `15` leads to setting a tag with a
//=== Spring Integration
// TODO: Update this
=== HTTP
// === HTTP
If a customization of client / server parsing of the HTTP related spans is required,
just register a bean of type `brave.http.HttpClientParser` or
`brave.http.HttpServerParser`. If client /server sampling is required, just
register a bean of type `brave.http.HttpSampler` and name the bean
`sleuthClientSampler` for client sampler and `sleuthServerSampler` for server sampler.
For your convenience the `@ClientSampler` and `@ServerSampler`
annotations can be used to inject the proper beans or to
reference the bean names via their static String `NAME` fields.
// TODO: Update this
Check out Brave's code to see an example of how to make a path-based sampler
https://github.com/openzipkin/brave/tree/master/instrumentation/http#sampling-policy
If you want to completely rewrite the `HttpTracing` bean you can use the `SkipPatternProvider`
interface to retrieve the URL `Pattern` for spans that should be not sampled. Below you can see
an example of usage of `SkipPatternProvider` inside a server side, `HttpSampler`.
[source,java]
----
@Configuration
class Config {
include::../../../../spring-cloud-sleuth-core/src/test/java/org/springframework/cloud/sleuth/instrument/web/TraceFilterWebIntegrationTests.java[tags=custom_server_sampler,indent=2]
}
----
=== `TraceFilter`