title: Spring-boot micrometer timer() how does it work?
body: <p>I am new to using spring-boot metrics and started with micrometer. I couldn't find good examples(the fact that its new) for performing timer Metrics in my spring-boot app. I am using spring-boot-starter-web:2.0.2.RELEASE dependency .
  But running spring-boot server and starting jconsole, I didn't see it showing Metrics (MBeans),so I also explicitly included below dependency:</p>
  
  <pre><code>spring-boot-starter-actuator:2.0.2.RELEASE
  </code></pre>
  
  <p>Also micrometer dependency : <code>'io.micrometer:micrometer-registry-jmx:latest'</code>
  After adding actuator ,it does show Metrics folder but I do not see my timer(app.timer)attribute in the list. Am I doing something wrong? Any suggestions appreciated!</p>
  
  <p>Below code snippet:</p>
  
  <pre><code>MeterRegistry registry = new CompositeMeterRegistry();
  long start = System.currentTimeMillis();
  Timer timer = registry.timer("app.timer", "type", "ping");
  timer.record(System.currentTimeMillis() - start, TimeUnit.MILLISECONDS);
  </code></pre>
  
  <p>This works:</p>
  
  <pre><code>Metrics.timer("app.timer").record(()-&gt; {
  
   didSomeLogic;
   long t = timeOccurred - timeScheduled;
   LOG.info("recorded timer = {}", t);
  });
  </code></pre>