Coder Social home page Coder Social logo

seshat's Introduction

Seshat

A gRPC server that keeps metrics of your services.

Motivation

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.

Usage

  1. Run the command git clone https://github.com/quamejnr/seshat
  2. From the root directory, run the command go run metrics-server/main.go to start the server
  3. 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 to https://google.com. Run go run metrics-client/main.go to see the flags available.
  4. Make a couple of requests and then run curl localhost:8000/metrics | json_pp to see some metrics.

Create 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.

MapMetric

The below example has already been implemented in this code.

  1. You can create a MapMetric by creating an instance of MapMetric and providing the name of your metric. For example:
var l = NewMapMetric("LatencyMetrics")
  1. You can then write your own function and use this instance created. Currently, MapMetric has only one method SetLabelValue(label string, value any). For example;
var l = NewMapMetric("LatencyMetrics")

func recordLatency(url string, responseTime float32) {
    l.SetLabelValue(url, responseTime)
}
  1. 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.

CounterMetric

The below example has already been implemented in this code.

  1. You can create a CounterMetric using the function NewCounterMetric.
var c = NewCounterMetric{"requestCounter"}
  1. 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()
}
  1. 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.

Future Plans

  • Add tests
  • Make it a standalone library.

Contributing

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.

License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.