Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gRPC Services Metrics using Prometheus #138

Merged
merged 2 commits into from
Jan 16, 2018

Conversation

juanpedromoreno
Copy link
Member

This PR adds some new optional artifacts that you might want to add to your build in order to monitor your gRPC services.

Concretely, adding:

libraryDependencies += "io.frees" %% "frees-rpc-prometheus-server" % "x.y.z"

Your RPC services will be able to intercept every RPC call on the server side and collect metrics that you could render in your dashboard, using Prometheus.

Adding services without intercepting calls:

lazy val grpcConfigs: List[GrpcConfig] = List(
  AddService(RPCService.bindService[ConcurrentMonad])
)

Intercepting calls with Prometheus:

import freestyle.rpc.interceptors.implicits._

lazy val cr: CollectorRegistry = new CollectorRegistry()
lazy val monitorInterceptor = MonitoringServerInterceptor(configuration.withCollectorRegistry(cr))

lazy val grpcConfigs: List[GrpcConfig] = List(
  AddService(RPCService.bindService[ConcurrentMonad].interceptWith(monitorInterceptor))
)

Next steps:

Inspired by:

lazy val `prometheus-server` = project
.in(file("modules/prometheus/server"))
.dependsOn(`prometheus-shared` % "compile->compile;test->test")
.dependsOn(server % "compile->compile;test->test")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prometheus-server only depends on server for testing, right? Or the idea is to include prometheus-server dependency instead of server?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only for tests, you need server to make it work with prometheus-server, that's why it should be added transitively. prometheus-server doesn't make sense without server.

private[this] val millisPerSecond = 1000L

private[this] val startInstant: Instant = clock.instant
reportStartMetrics()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this call to reportStartMetrics() intentional? in that case, I think we should add a blank line between the call and the private val

@juanpedromoreno juanpedromoreno merged commit e0a65a1 into master Jan 16, 2018
@juanpedromoreno juanpedromoreno deleted the jp-frees-rpc-server-metrics-prometheus branch January 16, 2018 14:51
@juanpedromoreno juanpedromoreno mentioned this pull request Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants