diff --git a/1.3.x/multi/multi__managing_spans_with_annotations.html b/1.3.x/multi/multi__managing_spans_with_annotations.html index 4820f37f8..7f7996ef4 100644 --- a/1.3.x/multi/multi__managing_spans_with_annotations.html +++ b/1.3.x/multi/multi__managing_spans_with_annotations.html @@ -32,14 +32,16 @@ with the @NewSpan annotation you can also add logs // method execution this.testBean.testMethod11("test");

That way the span will get continued and:

8.4 More advanced tag setting

There are 3 different ways to add tags to a span. All of them are controlled by the SpanTag annotation. Precedence is:

8.4.1 Custom extractor

The value of the tag for following method will be computed by an implementation of TagValueResolver interface. +The default implementation uses SPEL expression resolution. If we do not find any expression to evaluate, return the toString() +value of the parameter. +IMPORTANT You can only reference properties from the SPEL expression. Method execution is not allowed due to security constraints.

  • if one hasn’t provided any expression to evaluate just return a toString() value of the parameter
  • 8.4.1 Custom extractor

    The value of the tag for following method will be computed by an implementation of TagValueResolver interface. Its class name has to be passed as the value of the resolver attribute.

    Having such an annotated method:

    @NewSpan
     public void getAnnotationForTagValueResolver(@SpanTag(key = "test", resolver = TagValueResolver.class) String test) {
     }

    and such a TagValueResolver bean implementation

    @Bean(name = "myCustomTagValueResolver")
     public TagValueResolver tagValueResolver() {
     	return parameter -> "Value from myCustomTagValueResolver";
     }

    Will lead to setting of a tag value equal to Value from myCustomTagValueResolver.

    8.4.2 Resolving expressions for value

    Having such an annotated method:

    @NewSpan
    -public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "length() + ' characters'") String test) {
    +public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "'hello' + ' characters'") String test) {
     }

    and no custom implementation of a TagValueExpressionResolver will lead to evaluation of the SPEL expression and a tag with value 4 characters will be set on the span. If you want to use some other expression resolution mechanism you can create your own implementation of the bean.

    8.4.3 Using toString method

    Having such an annotated method:

    @NewSpan
    diff --git a/1.3.x/single/spring-cloud-sleuth.html b/1.3.x/single/spring-cloud-sleuth.html
    index 7924c4d33..4555fa7f3 100644
    --- a/1.3.x/single/spring-cloud-sleuth.html
    +++ b/1.3.x/single/spring-cloud-sleuth.html
    @@ -405,14 +405,16 @@ with the @NewSpan annotation you can also add logs
     // method execution
     this.testBean.testMethod11("test");

    That way the span will get continued and:

    • logs with name testMethod11.before and testMethod11.after will be created
    • if an exception will be thrown a log testMethod11.afterFailure will also be created
    • tag with key testTag11 and value test will be created

    8.4 More advanced tag setting

    There are 3 different ways to add tags to a span. All of them are controlled by the SpanTag annotation. Precedence is:

    • try with the bean of TagValueResolver type and provided name
    • if one hasn’t provided the bean name, try to evaluate an expression. We’re searching for a TagValueExpressionResolver bean. -The default implementation uses SPEL expression resolution.
    • if one hasn’t provided any expression to evaluate just return a toString() value of the parameter

    8.4.1 Custom extractor

    The value of the tag for following method will be computed by an implementation of TagValueResolver interface. +The default implementation uses SPEL expression resolution. If we do not find any expression to evaluate, return the toString() +value of the parameter. +IMPORTANT You can only reference properties from the SPEL expression. Method execution is not allowed due to security constraints.

  • if one hasn’t provided any expression to evaluate just return a toString() value of the parameter
  • 8.4.1 Custom extractor

    The value of the tag for following method will be computed by an implementation of TagValueResolver interface. Its class name has to be passed as the value of the resolver attribute.

    Having such an annotated method:

    @NewSpan
     public void getAnnotationForTagValueResolver(@SpanTag(key = "test", resolver = TagValueResolver.class) String test) {
     }

    and such a TagValueResolver bean implementation

    @Bean(name = "myCustomTagValueResolver")
     public TagValueResolver tagValueResolver() {
     	return parameter -> "Value from myCustomTagValueResolver";
     }

    Will lead to setting of a tag value equal to Value from myCustomTagValueResolver.

    8.4.2 Resolving expressions for value

    Having such an annotated method:

    @NewSpan
    -public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "length() + ' characters'") String test) {
    +public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "'hello' + ' characters'") String test) {
     }

    and no custom implementation of a TagValueExpressionResolver will lead to evaluation of the SPEL expression and a tag with value 4 characters will be set on the span. If you want to use some other expression resolution mechanism you can create your own implementation of the bean.

    8.4.3 Using toString method

    Having such an annotated method:

    @NewSpan
    diff --git a/1.3.x/spring-cloud-sleuth.xml b/1.3.x/spring-cloud-sleuth.xml
    index 045b98fc0..d022f28aa 100644
    --- a/1.3.x/spring-cloud-sleuth.xml
    +++ b/1.3.x/spring-cloud-sleuth.xml
    @@ -4,7 +4,7 @@
     
     
     Spring Cloud Sleuth
    -2018-04-06
    +2018-04-07
     
     
     Adrian Cole, Spencer Gibb, Marcin Grzejszczak, Dave Syer
    @@ -1004,7 +1004,9 @@ Precedence is:
     
     
     if one hasn’t provided the bean name, try to evaluate an expression. We’re searching for a TagValueExpressionResolver bean.
    -The default implementation uses SPEL expression resolution.
    +The default implementation uses SPEL expression resolution. If we do not find any expression to evaluate, return the toString()
    +value of the parameter.
    +IMPORTANT You can only reference properties from the SPEL expression. Method execution is not allowed due to security constraints.
     
     
     if one hasn’t provided any expression to evaluate just return a toString() value of the parameter
    @@ -1029,7 +1031,7 @@ public TagValueResolver tagValueResolver() {
     Resolving expressions for value
     Having such an annotated method:
     @NewSpan
    -public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "length() + ' characters'") String test) {
    +public void getAnnotationForTagValueExpression(@SpanTag(key = "test", expression = "'hello' + ' characters'") String test) {
     }
     and no custom implementation of a TagValueExpressionResolver will lead to evaluation of the SPEL expression and a tag with value 4 characters will be set on the span.
     If you want to use some other expression resolution mechanism you can create your own implementation