Created
July 9, 2020 15:51
-
-
Save ramesh-lingappan/939a2faed2ed22ce7582bc820ffe465b to your computer and use it in GitHub Desktop.
PushGateway HelloService
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.prometheuspushgateway; | |
import io.micrometer.core.annotation.Timed; | |
import io.micrometer.core.instrument.Counter; | |
import io.micrometer.core.instrument.MeterRegistry; | |
import org.springframework.stereotype.Service; | |
@Service | |
public class HelloService { | |
private final Counter counter; | |
public HelloService(MeterRegistry meterRegistry) { | |
this.counter = meterRegistry.counter("hello.counter", "type", "hello"); | |
} | |
@Timed(value = "hello-process", description = "Time spent processing hello", extraTags = {"type", "hello"}) | |
public String getHello() { | |
try { | |
Thread.sleep(500); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
counter.increment(); | |
return "Hello, counter = " + counter.count(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment