All Projects → kamon-io → kamon-http4s

kamon-io / kamon-http4s

Licence: Apache-2.0 license
Kamon Integration for http4s

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to kamon-http4s

Molten
php probe for zipkin and opentracing
Stars: ✭ 740 (+1474.47%)
Mutual labels:  instrumentation, tracing
Brave Opentracing
Bridge between OpenTracing and Brave
Stars: ✭ 64 (+36.17%)
Mutual labels:  instrumentation, tracing
Aws Xray Ts Decorator
Instrument your Typescript code with AWS X-Ray using elegant decorators
Stars: ✭ 17 (-63.83%)
Mutual labels:  instrumentation, tracing
Sqlhooks
Attach hooks to any database/sql driver
Stars: ✭ 397 (+744.68%)
Mutual labels:  instrumentation, tracing
Java Specialagent
Automatic instrumentation for 3rd-party libraries in Java applications with OpenTracing.
Stars: ✭ 156 (+231.91%)
Mutual labels:  instrumentation, tracing
Zipkin Go
Zipkin tracer library for go
Stars: ✭ 435 (+825.53%)
Mutual labels:  instrumentation, tracing
Scalopus
A tracing framework for C++ and Python.
Stars: ✭ 41 (-12.77%)
Mutual labels:  instrumentation, tracing
splunk-otel-java
Splunk Distribution of OpenTelemetry Java
Stars: ✭ 39 (-17.02%)
Mutual labels:  instrumentation, tracing
Spring Cloud Sleuth
Distributed tracing for spring cloud
Stars: ✭ 1,531 (+3157.45%)
Mutual labels:  instrumentation, tracing
Capture Thread
Lock-free framework for loggers, tracers, and mockers in multithreaded C++ programs.
Stars: ✭ 93 (+97.87%)
Mutual labels:  instrumentation, tracing
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+593.62%)
Mutual labels:  instrumentation, tracing
Opencensus Node
A stats collection and distributed tracing framework
Stars: ✭ 249 (+429.79%)
Mutual labels:  instrumentation, tracing
thundra-agent-nodejs
Thundra Lambda Node.js Agent
Stars: ✭ 31 (-34.04%)
Mutual labels:  instrumentation, tracing
Zipkin Go Opentracing
OpenTracing Bridge for Zipkin Go
Stars: ✭ 472 (+904.26%)
Mutual labels:  instrumentation, tracing
java-okhttp
OpenTracing Okhttp client instrumentation
Stars: ✭ 21 (-55.32%)
Mutual labels:  instrumentation, tracing
Microservices Observability
This project is a demonstration on how to instrument, monitor and trace applications using java frameworks and open-source tools like prometheus, grafana and jaeger.
Stars: ✭ 23 (-51.06%)
Mutual labels:  instrumentation, tracing
zipkin-cpp-opentracing
OpenTracing Tracer implementation for Zipkin in C++
Stars: ✭ 46 (-2.13%)
Mutual labels:  instrumentation, tracing
probes-api
Software Activity Metering - Probes Open API
Stars: ✭ 31 (-34.04%)
Mutual labels:  instrumentation, tracing
Jplusone
Tool for automatic detection and asserting "N+1 SELECT problem" occurences in JPA based Spring Boot Java applications and finding origin of JPA issued SQL statements in general
Stars: ✭ 91 (+93.62%)
Mutual labels:  instrumentation, tracing
Opencensus Web
A stats collection and distributed tracing framework
Stars: ✭ 168 (+257.45%)
Mutual labels:  instrumentation, tracing

Kamon http4s

Discord Maven Central

Getting Started

The kamon-http4s-<version> module brings traces and metrics to your http4s based applications.

It is currently available for Scala 2.12 and 2.13. The current version supports Kamon 2.2 and is published for http4s 0.22, 0.23 and 1.0.

kamon kamon-http4s status jdk scala http4s
2.2.x 2.2.2 stable 8+ 2.12, 2.13 0.22.x
2.2.x 2.2.2 stable 8+ 2.12, 2.13 0.23.x
2.2.x 2.2.2 stable 8+ 2.12, 2.13 1.0.x

To get started with sbt, simply add the following to your build.sbt file, for instance for http4s 0.23:

libraryDependencies += "io.kamon" %% "kamon-http4s-0.23" % "2.2.2"

The releases and dependencies for the legacy module kamon-http4s (without http4s version) are shown below.

kamon-http4s status jdk scala http4s
1.0.8-1.0.10 stable 8+ 2.11, 2.12 0.18.x
1.0.13 stable 8+ 2.11, 2.12 0.20.x
2.0.0 stable 8+ 2.11, 2.12 0.20.x
2.0.1 stable 8+ 2.12, 2.13 0.21.x

Metrics and Tracing for http4s in 2 steps

The Server

def serve[F[_]](implicit Effect: Effect[F], EC: ExecutionContext) : Stream[F, StreamApp.ExitCode] =
    for {
      _ <- Stream.eval(Sync[F].delay(println("Starting Google Service with Client")))
      client <- Http1Client.stream[F]()
      service = GoogleService.service[F](middleware.client.KamonSupport(client)) (1)
      exitCode <- BlazeBuilder[F]
        .bindHttp(Config.server.port, Config.server.interface)
        .mountService(middleware.server.KamonSupport(service)) (2)
        .serve
    } yield exitCode

The Service

object GoogleService {
  def service[F[_]: Effect](c: Client[F]): HttpService[F] = {
    val dsl = new Http4sDsl[F]{}
    import dsl._

    HttpService[F] {
      case GET -> Root / "call-google" =>
        Ok(c.expect[String]("https://www.google.com.ar"))
    }
  }
}

Step 1: Add the Kamon Libraries

libraryDependencies ++= Seq(
  "io.kamon" %% "kamon-core" % "2.2.3",
  "io.kamon" %% "kamon-http4s-0.23" % "2.2.1",
  "io.kamon" %% "kamon-prometheus" % "2.2.3",
  "io.kamon" %% "kamon-zipkin" % "2.2.3",
  "io.kamon" %% "kamon-jaeger" % "2.2.3"
)

Step 2: Start Reporting your Data

Since version 2.0, Kamon reporters are started automatically through their default configuration. Now you can simply sbt run the application and after a few seconds you will get the Prometheus metrics exposed on http://localhost:9095/ and message traces sent to Zipkin! The default configuration publishes the Prometheus endpoint on port 9095 and assumes that you have a Zipkin instance running locally on port 9411 but you can change these values under the kamon.prometheus and kamon.zipkin configuration keys, respectively.

Metrics

All you need to do is configure a scrape configuration in Prometheus. The following snippet is a minimal example that should work with the minimal server from the previous section.

A minimal Prometheus configuration snippet
------------------------------------------------------------------------------
scrape_configs:
  - job_name: 'kamon-prometheus'
    static_configs:
      - targets: ['localhost:9095']
------------------------------------------------------------------------------

Once you configure this target in Prometheus you are ready to run some queries like this:

Those are the Server Metrics metrics that we are gathering by default:

  • active-requests: The the number active requests.
  • http-responses: Response time by status code.
  • abnormal-termination: The number of abnormal requests termination.
  • service-errors: The number of service errors.
  • headers-times: The number of abnormal requests termination.
  • http-request: Request time by status code.

Now you can go ahead, make your custom metrics and create your own dashboards!

Traces

Assuming that you have a Zipkin instance running locally with the default ports, you can go to http://localhost:9411 and start investigating traces for this application. Once you find a trace you are interested in you will see something like this:

Clicking on a span will bring up a details view where you can see all tags for the selected span:

Enjoy!

That's it, you are now collecting metrics and tracing information from a http4s application.

Useful links:

Example of how to correctly configure the execution context by @cmcmteixeira

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].