title: Micrometer Timer and Spring Boot 2.0.4
body: <p>I'm trying to send metrics to InfluxDB using Spring Boot 2.0.4 + Micrometer, but only Counter works, the Timer didn't. </p>
  
  <p>So, this is my dependencies:</p>
  
  <pre><code>...
  &lt;dependency&gt;
              &lt;groupId&gt;io.micrometer&lt;/groupId&gt;
              &lt;artifactId&gt;micrometer-registry-influx&lt;/artifactId&gt;
          &lt;/dependency
  &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
          &lt;/dependency&gt;
  &lt;dependency&gt;
              &lt;groupId&gt;org.influxdb&lt;/groupId&gt;
              &lt;artifactId&gt;influxdb-java&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
          &lt;/dependency&gt;
  ...
  </code></pre>
  
  <p>Using Counter, as i said, everything works, see:</p>
  
  <pre><code>private final Counter counter = Metrics.counter("my.counter", "my.extra.tag", this.getClass().getCanonicalName());
  counter.increment();
  </code></pre>
  
  <p>But Timer don't work, i tried @Timed and Timer.sample, both don't send any metrics to influxDB. I annoted by method inside a @Service class with it:</p>
  
  <pre><code>@Timed(value = "my.timer", extraTags = { "my.extra.tag", "TimerSomething" })
  </code></pre>
  
  <p>So, i tried change to Timer.sample like this: <a href="https://micrometer.io/docs/concepts#_storing_start_state_in_code_timer_sample_code" rel="nofollow noreferrer">https://micrometer.io/docs/concepts#_storing_start_state_in_code_timer_sample_code</a>, but nothing is sent to influxDB.</p>
  
  <p>This is my properties to configure influx:</p>
  
  <pre><code>management.endpoints.web.exposure.include: info, health, metrics
  management.metrics.export.influx.enabled=true
  management.metrics.export.influx.auto-create-db=false
  management.metrics.export.influx.batch-size=10000
  management.metrics.export.influx.db=my.metrics.db
  management.metrics.export.influx.uri=http://xxxxx:8086
  </code></pre>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>I tried create a simple test, see:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class MicrometerTest {
  
      private final InfluxConfig config = new InfluxConfig() {
  
          @Override
          public String get(String s) {
              return null;
          }
  
          @Override
          public Duration step() {
              return Duration.ofSeconds(5);
          }
  
          @Override
          public boolean autoCreateDb() {
              return false;
          }
  
          @Override
          public String db() {
              return "mydb";
          }
  
          @Override
          public String uri() {
              return "http://xxxx:8086";
          }
  
      };
  
      private final InfluxMeterRegistry registry = new InfluxMeterRegistry(this.config, Clock.SYSTEM);
  
  
      @Test
      public void counter() throws InterruptedException {
          Counter counter = this.registry.counter("my.counter", Tags.of("key", "value"));
  
          counter.increment();
          TimeUnit.SECONDS.sleep(5);
          TimeUnit.SECONDS.sleep(5);
      }
  
      @Test
      public void verifica_se_timer_funciona() throws InterruptedException {
          Timer.Sample sample = Timer.start(this.registry);
  
          TimeUnit.SECONDS.sleep(1);
  
          Timer timer = this.registry.timer("my.timer", "response", "200");
          sample.stop(timer);
          TimeUnit.SECONDS.sleep(5);
      }
  }
  </code></pre>
  
  <p>The counter works fine but timer don't. </p>