A gRPC server that keeps metrics of your services.
I built Seshat in an attempt to deapen my understanding of gRPC although it currently has the potential to be a library independent of gRPC. The idea of Seshat is to help you easily create metrics for your services. You can easily configure your gRPC server to send ping all your services and keep records of the latency for later analysis.
- Run the command
git clone https://github.com/quamejnr/seshat
- From the root directory, run the command
go run metrics-server/main.go
to start the server - Open another terminal and run the command
go run metrics-client/main.go
to start the client. You can provide your own url as a flag, it defaults tohttps://google.com
. Rungo run metrics-client/main.go
to see the flags available. - Make a couple of requests and then run
curl localhost:8000/metrics | json_pp
to see some metrics.
There are currently two categories of metrics: - CounterMetric
which can be
used to keep count or fixed value. - MapMetric
which can be used to keep track
of a key, value pair.
The below example has already been implemented in this code.
- You can create a
MapMetric
by creating an instance ofMapMetric
and providing the name of your metric. For example:
var l = NewMapMetric("LatencyMetrics")
- You can then write your own function and use this instance created.
Currently,
MapMetric
has only one methodSetLabelValue(label string, value any)
. For example;
var l = NewMapMetric("LatencyMetrics")
func recordLatency(url string, responseTime float32) {
l.SetLabelValue(url, responseTime)
}
- You can use your function to keep metrics of your requests latency. You
should see your created metric in your metrics when you run
curl localhost:8000/metrics | json_pp
.
The below example has already been implemented in this code.
- You can create a
CounterMetric
using the functionNewCounterMetric
.
var c = NewCounterMetric{"requestCounter"}
- You can write your own function leveraging the methods from the instance
created. Currently,
CounterMetric
has 3 methods;SetValue
,Increment
,Decrement
.
var c = NewCounterMetric{"requestCounter"}
func recordRequests() {
c.Increment()
}
- You can use your function to keep metrics of your requests latency. You
should see your created metric in your metrics when you run
curl localhost:8000/metrics | json_pp
.
- Add tests
- Make it a standalone library.
Contributions to Seshat are welcome! If you find a bug, have an idea for an improvement, or want to add a new feature, please open an issue or create a pull request on the Heimdall GitHub repository.
Seshat is open-source software licensed under the MIT License. You are free to use, modify, and distribute this tool according to the terms of the license.