Annotation Type CaptureSpan


@Retention(RUNTIME) @Target(METHOD) public @interface CaptureSpan
Annotating a method with @CaptureSpan creates a Span as the child of the currently active span or transaction (ElasticApm.currentSpan()).

When there is no current span, no span will be created.

Note: it is required to configure the application_packages, otherwise this annotation will be ignored.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Sets the action of the captured span, used to group similar spans together, for example: `query`.
    boolean
    Makes the captured span an exit span.
    boolean
    By default, spans are discardable.
    Sets the subtype of the captured span, used to group similar spans together, for example: `mysql`.
    Sets the general type of the captured span, used to group similar spans together, for example: `db`.
    The name of the Span.
  • Element Details

    • value

      String value
      The name of the Span. Defaults to the ClassName#methodName
      Default:
      ""
    • type

      String type

      Sets the general type of the captured span, used to group similar spans together, for example: `db`. Though there are no naming restrictions for the general types, the following are standardized across all Elastic APM agents: `app`, `db`, `cache`, `template`, and `ext`.

      Prior to version 1.4, the typing system was hierarchical. For instance, all spans of MySQL queries were given the type `db.mysql.query`. This is deprecated now and '.' (dot) character will not be allowed starting version 2.0. To get better span aggregation capabilities, use the subtype() and action() in combination with type.

      Default:
      "app"
    • subtype

      String subtype

      Sets the subtype of the captured span, used to group similar spans together, for example: `mysql`. NOTE: current users of the hierarchical typing system are advised to use the second part of the type as subtype starting 1.4. For example, if used `external.http.okhttp` before 1.4, set `okhttp` as subtype.

      Default:
      ""
    • action

      String action

      Sets the action of the captured span, used to group similar spans together, for example: `query`. NOTE: current users of the hierarchical typing system are advised to use the third part of the type as action starting 1.4. For example, if used `template.jsf.render` before 1.4, set `render` as action.

      Default:
      ""
    • discardable

      boolean discardable

      By default, spans are discardable. In some cases, spans may be discarded, for example if span_min_duration config option is set and the span does not exceed the configured threshold. Set this attribute to false to make the current span non-discardable.

      NOTE: making a span non-discardable implicitly makes the entire stack of active spans non-discardable as well. Child spans can still be discarded.

      Default:
      true
    • asExit

      boolean asExit

      Makes the captured span an exit span. Exit spans are usually meant to represent outgoing calls to external systems, like databases. When an exit span is created no nested span is created. For example when creating exit spans for a database, it can hide the fact that calls to this database are made through an HTTP client.

      When set to true, it is recommended to also set values for type() and subtype()

      Default:
      false