Skip to content

Need option for actuator+dropwizard timers for short timings #8770

Closed
@tdalsing-pivotal

Description

@tdalsing-pivotal

When using dropwizard with spring boot actuator the timers are in milliseconds. For timings that are less than 1 ms the values are always 0 since the output is an integer and the value is truncated. Please change the output to a floating point value.

Test code:

@RestController
public class DWController {

    private MetricRegistry registry;

    @Autowired
    public DWController(MetricRegistry registry) {
        this.registry = registry;
    }

    @RequestMapping("/foo/{count}")
    public String foo(@PathVariable("count") int count) {
        Timer timer = registry.timer("fooTimer");
        Timer.Context ctx = timer.time();

        // do something that will take < 1 millisecond
        for (int i = 0; i < count; ++i) {
            double d = Math.pow(i, 10);
        }

        long t = ctx.stop();
        return "" + t;
    }
}

Exercising the code:

curl http://localhost:8080/foo/10

several times results in:

{
  "mem": 362154,
  "mem.free": 279813,
  "processors": 4,
  "instance.uptime": 30543,
  "uptime": 35343,
  "systemload.average": 3.80029296875,
  "heap.committed": 314368,
  "heap.init": 262144,
  "heap.used": 34554,
  "heap": 3728384,
  "nonheap.committed": 50048,
  "nonheap.init": 2496,
  "nonheap.used": 47743,
  "nonheap": 0,
  "threads.peak": 22,
  "threads.daemon": 20,
  "threads.totalStarted": 26,
  "threads": 22,
  "classes": 5977,
  "classes.loaded": 5977,
  "classes.unloaded": 0,
  "gc.ps_scavenge.count": 6,
  "gc.ps_scavenge.time": 83,
  "gc.ps_marksweep.count": 1,
  "gc.ps_marksweep.time": 46,
  "fooTimer.snapshot.median": 0,
  "gauge.response.foo.count": 3.0,
  "fooTimer.fiveMinuteRate": 0.605644105347075,
  "fooTimer.count": 17,
  "fooTimer.snapshot.75thPercentile": 0,
  "fooTimer.snapshot.999thPercentile": 0,
  "fooTimer.snapshot.max": 0,
  "fooTimer.snapshot.98thPercentile": 0,
  "fooTimer.fifteenMinuteRate": 0.6021061761967533,
  "counter.status.200.foo.count": 17,
  "fooTimer.snapshot.95thPercentile": 0,
  "fooTimer.snapshot.99thPercentile": 0,
  "fooTimer.snapshot.stdDev": 0,
  "fooTimer.meanRate": 0.6349273410338819,
  "fooTimer.oneMinuteRate": 0.6107670725235096,
  "fooTimer.snapshot.min": 0,
  "fooTimer.snapshot.mean": 0,
  "httpsessions.max": -1,
  "httpsessions.active": 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions