Annotation Type SpanAttribute


@Target(PARAMETER) @Retention(RUNTIME) public @interface SpanAttribute
This annotation marks that a parameter of a method annotated by the WithSpan annotation should be added as an attribute to the newly created Span. Using this annotation is equivalent to calling Span.currentSpan().setAttribute(...) within the body of the method.

Application developers can use this annotation to signal OpenTelemetry auto-instrumentation that a new span attribute should be added to a span created when the parent method is executed.

If you are a library developer, then probably you should NOT use this annotation, because it is non-functional without some form of auto-instrumentation.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional name of the attribute.
  • Element Details

    • value

      String value
      Optional name of the attribute.

      If not specified and the code is compiled using the `-parameters` argument to `javac`, the parameter name will be used instead. If the parameter name is not available, e.g., because the code was not compiled with that flag, the attribute will be ignored.

      Default:
      ""