---
title: TimerDecorator
description: Records time to process filters, handlers, and access token resolvers.
component: pinggateway
version: 7.2
page_id: pinggateway:reference:TimerDecorator
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/TimerDecorator.html
llms_txt: https://docs.pingidentity.com/pinggateway/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2025-06-02T16:30:54Z
superseded_by: https://docs.pingidentity.com/pinggateway/2026/reference/TimerDecorator.html
section_ids:
  TimerDecorator-dec-usage: Decorator usage
  TimerDecorator-ob-usage: Decorated object usage
  timer-metrics-prom: Timer metrics at the Prometheus Scrape Endpoint
  timer-metrics-api: Timer metrics at the Common REST Monitoring Endpoint
  TimerDecorator-metrics-slf4j: Timer metrics in SLF4J logs
  TimerDecorator-examples: Examples
  TimerDecorator-moreinfo: More information
---

# TimerDecorator

Records time to process filters, handlers, and access token resolvers.

## Decorator usage

```json
{
    "name": string,
    "type": "TimerDecorator",
    "config": {
        "timeUnit": configuration expression<string>
    }
}
```

IG configures a default TimerDecorator named `timer`. Use `timer` as the decorator name without explicitly declaring a decorator named timer.

* `"timeUnit"`: *configuration expression<[string](preface.html#definition-string)>, optional*

  Unit of time used in the decorator output. The unit of time can be any unit allowed in the <[duration](preface.html#definition-duration)> field.

  Default: `ms`

## Decorated object usage

```json
{
    "name": string,
    "type": string,
    "config": object,
    decorator name: boolean
}
```

* `"name"`: *[string](preface.html#definition-string), required except for inline objects*

  The unique name of the object to decorate.

* `"type"`: *[string](preface.html#definition-string), required*

  The class name of the object to decorate, which must be a [Filter](Filters.html), [Handler](Handlers.html), or the `accessTokenResolver` property of [OAuth2ResourceServerFilter](OAuth2ResourceServerFilter.html).

* `"config"`: [object](preface.html#definition-object), optional

  The configuration of the object, just like an object that is not decorated.

  Default: Empty

* `decorator name`: *configuration expression<[boolean](preface.html#definition-boolean)>, required*

  IG looks for the presence of the decorator name field for the TimerDecorator:

  * `true`: Activate the timer

  * `false`: Deactivate the TimerDecorator

## Timer metrics at the Prometheus Scrape Endpoint

This section describes the timer metrics recorded at the Prometheus Scrape Endpoint. For more information about metrics, see [Monitoring Endpoints](Monitoring.html#monitoring-metrics).

When IG is set up as described in the documentation, the endpoint is <http://ig.example.com:8080/openig/metrics/prometheus>.

Each timer metric is labelled with the following fully qualified names:

* `decorated_object`

* `heap`

* `name` (decorator name)

* `route`

* `router`

**Timer metrics at the Prometheus Scrape Endpoint**

| Name                                          | [Monitoring type](MonitoringTypes.html) | Description                                                                                                   |
| --------------------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `ig_timerdecorator_handler_elapsed_seconds`   | `Summary`                               | Time to process the request and response in the decorated handler.                                            |
| `ig_timerdecorator_filter_elapsed_seconds`    | `Summary`                               | Time to process the request and response in the decorated filter **and** its downstream filters and handler.  |
| `ig_timerdecorator_filter_internal_seconds`   | `Summary`                               | Time to process the request and response in the decorated filter.                                             |
| `ig_timerdecorator_filter_downstream_seconds` | `Summary`                               | Time to process the request and response in filters and handlers that are downstream of the decorated filter. |

## Timer metrics at the Common REST Monitoring Endpoint

This section describes the metrics recorded at the the ForgeRock Common REST Monitoring Endpoint. For more information about metrics, see [Monitoring Endpoints](Monitoring.html#monitoring-metrics).

When IG is set up as described in the documentation, the endpoint is <http://ig.example.com:8080/openig/metrics/api?_queryFilter=true>.

Metrics are published with an `_id` in the following pattern:

`heap.router-name.route-name.decorator-name.object`

**Timer metrics at the Common REST Monitoring Endpoint**

| Name         | [Monitoring type](MonitoringTypes.html) | Description                                                                                                                               |
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `elapsed`    | `Timer`                                 | Time to process the request and response in the decorated handler, or in the decorated filter **and** its downstream filters and handler. |
| `internal`   | `Timer`                                 | Time to process the request and response in the decorated filter.                                                                         |
| `downstream` | `Timer`                                 | Time to process the request and response in filters and handlers that are downstream of the decorated filter.                             |

## Timer metrics in SLF4J logs

SLF4J logs are named in this format:

```none
<className>.<decoratorName>.<decoratedObjectName>
```

If the decorated object is not named, the object path is used in the log.

When a route's top-level handler is decorated, the timer decorator records the elapsed time for operations traversing the whole route:

```none
2018-09-04T12:16:08,994Z | INFO  | I/O dispatcher 17 | o.f.o.d.t.T.t.top-level-handler | @myroute | Elapsed time: 13 ms
```

When an individual handler in the route is decorated, the timer decorator records the elapsed time for operations traversing the handler:

```none
2018-09-04T12:44:02,161Z | INFO  | http-nio-8080-exec-8 | o.f.o.d.t.T.t.StaticResponseHandler-1 | @myroute | Elapsed time: 1 ms
```

## Examples

The following example uses the default timer decorator to record the time that TokenIntrospectionAccessTokenResolver takes to process a request:

```json
{
  "accessTokenResolver": {
    "name": "TokenIntrospectionAccessTokenResolver-1",
    "type": "TokenIntrospectionAccessTokenResolver",
    "config": {
      "amService": "AmService-1",
      ...
    },
    "timer": true
  }
}
```

The following example defines a customized timer decorator in the heap, and uses it to record the time that the SingleSignOnFilter takes to process a request:

```json
{
  "heap": [
    {
      "name": "mytimerdecorator",
      "type": "TimerDecorator",
      "config": {
        "timeUnit": "nano"
      }
    },
    ...
  ],
  "handler": {
    "type": "Chain",
    "config": {
      "filters": [
        {
          "type": "SingleSignOnFilter",
          "config": {
            ...
          },
          "mytimerdecorator": true
        }
      ],
      "handler": "ReverseProxyHandler"
    }
  }
}
```

## More information

[org.forgerock.openig.decoration.timer.TimerDecorator](../_attachments/apidocs/org/forgerock/openig/decoration/timer/TimerDecorator.html)
