Annotation Type Trace


  • @Target(METHOD)
    @Retention(RUNTIME)
    public @interface Trace
    If you annotate a method with the Trace annotation it will be automatically timed by the New Relic agent with the following measurements:
    • call count
    • calls per minute
    • total call time
    • standard deviation call time
    • min call time
    • max call time
    A metric representing these measurements will be reporting inside the call scope of the current transaction (e.g., "/servlets/myservlet") so that New Relic can "break out" the response time of a given transaction by specific called methods. A rollup summary metric (all invocations of the method for every transaction) will also be reported. Be mindful when using this annotation. When placed on relatively heavyweight operations such as database access or webservice invocation, its overhead will be negligible. On the other hand, if placed on a tight, frequently called method (e.g., an accessor that is called thousands of times per second), then the tracer will introduce higher overhead to your application.
    See Also:
    TracedMethod
    • Field Summary

      Fields 
      Modifier and Type Fields Description
      static java.lang.String NULL
      Deprecated.
      No replacement.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean async
      Tells the agent that this method is asynchronous and that it should be traced if the method is linked to an existing transaction.
      boolean dispatcher
      If true, this method will be considered the start of a transaction.
      boolean excludeFromTransactionTrace
      Excludes this traced method from transaction traces.
      boolean leaf
      A leaf tracer will not have any child tracers.
      java.lang.String metricName
      Sets the metric name for this tracer.
      boolean nameTransaction
      Names the current transaction using this tracer's metric name.
      java.lang.String[] rollupMetricName
      Specifies one or more rollup metrics names.
      boolean skipTransactionTrace
      Deprecated.
      java.lang.String tracerFactoryName
      Deprecated.
      Do not use.
    • Field Detail

      • NULL

        @Deprecated
        static final java.lang.String NULL
        Deprecated.
        No replacement. Do not use this.
    • Element Detail

      • metricName

        java.lang.String metricName
        Sets the metric name for this tracer. If unspecified, the class / method name will be used. When using both nameTransaction and metricName, nameTransaction will take precedence and the transaction will use the name from the underlying tracer (typically class/method), rather than the custom name set by metricName. It is recommended to use one or the other depending on naming preferences.
        Returns:
        The metric name for this tracer.
        Since:
        1.3.0
        Default:
        ""
      • rollupMetricName

        java.lang.String[] rollupMetricName
        Specifies one or more rollup metrics names. When the tracer finishes, an unscoped metric (a metric which is not scoped to a specific transaction) will be recorded with the given metric name. This is useful when you want to record a summary value across multiple methods or transaction names.
        Returns:
        One or more rollup metric names.
        Since:
        3.5.0
        Default:
        {""}
      • dispatcher

        boolean dispatcher
        If true, this method will be considered the start of a transaction. When this method is invoked within the context of an existing transaction this has no effect. If false and this method is invoked outside a transaction, then this tracer will not be reported.
        Returns:
        True if this method should start a transaction if one has not already been started.
        Since:
        1.3.0
        Default:
        false
      • nameTransaction

        boolean nameTransaction
        Names the current transaction using this tracer's metric name. When using both nameTransaction and metricName, nameTransaction will take precedence and the transaction will use the name from the underlying tracer (typically class/method), rather than the custom name set by metricName. It is recommended to use one or the other depending on naming preferences.
        Returns:
        True if this traced method should be used to name the transaction, else false.
        Since:
        3.1.0
        Default:
        false
      • tracerFactoryName

        java.lang.String tracerFactoryName
        Deprecated.
        Do not use.
        Returns:
        Do not use.
        Since:
        1.3.0
        Default:
        ""
      • skipTransactionTrace

        boolean skipTransactionTrace
        Deprecated.
        Ignores the entire current transaction.
        Returns:
        True if this transaction should be ignored, else false.
        Since:
        2.21.0
        Default:
        false
      • excludeFromTransactionTrace

        boolean excludeFromTransactionTrace
        Excludes this traced method from transaction traces. Metric data is still generated.
        Returns:
        True if this traced method should be excluded from transaction traces, else false.
        Since:
        3.1.0
        Default:
        false
      • leaf

        boolean leaf
        A leaf tracer will not have any child tracers. This is useful when all time should be attributed to the tracer even if other trace points are encountered during its execution. For example, database tracers often act as leaf so that all time is attributed to database activity even if instrumented external calls are made. If a leaf tracer does not participate in transaction traces (excludeFromTransactionTrace()) the agent can create a tracer with lower overhead.
        Returns:
        True if this traced method should be a leaf, else false.
        Since:
        3.1.0
        Default:
        false
      • async

        boolean async
        Tells the agent that this method is asynchronous and that it should be traced if the method is linked to an existing transaction.
        Returns:
        true if this method is asynchronous and it should be traced in the current transaction.
        Since:
        3.37.0
        Default:
        false