Convert Figma logo to code with AI

kamon-io logoKamon

Distributed Tracing, Metrics and Context Propagation for applications running on the JVM

1,407
327
1,407
181

Top Related Projects

OpenTracing API for Java. 🛑 This library is DEPRECATED! https://github.com/opentracing/specification/issues/163

16,970

Zipkin is a distributed tracing system

Prometheus instrumentation library for JVM applications

An application observability facade for the most popular observability tools. Think SLF4J, but for observability.

Quick Overview

Kamon is an open-source toolkit for monitoring applications running on the JVM. It provides instrumentation for various aspects of application performance, including metrics, distributed tracing, and context propagation. Kamon is designed to be lightweight and easy to integrate with different JVM-based frameworks and libraries.

Pros

  • Comprehensive monitoring solution with support for metrics, tracing, and context propagation
  • Extensible architecture allowing for easy integration with various reporting backends
  • Low overhead and minimal impact on application performance
  • Strong support for Scala and Akka-based applications

Cons

  • Learning curve for users new to application monitoring concepts
  • Documentation can be sparse or outdated for some features
  • Limited built-in support for non-JVM languages and frameworks
  • Some advanced features may require additional configuration or setup

Code Examples

  1. Setting up Kamon in a Scala application:
import kamon.Kamon

object MyApp extends App {
  Kamon.init()
  
  // Your application code here
  
  Kamon.stop()
}
  1. Creating and recording a custom metric:
import kamon.Kamon
import kamon.metric.Metric

val myCounter: Metric.Counter = Kamon.counter("my_custom_counter")
myCounter.increment()
  1. Starting a new trace span:
import kamon.Kamon
import kamon.trace.Span

Kamon.runWithSpan(Kamon.spanBuilder("my-operation").start()) {
  // Code to be executed within the span
}
  1. Adding tags to the current span:
import kamon.Kamon

Kamon.currentSpan()
  .tag("user.id", userId)
  .tag("request.type", "GET")

Getting Started

To start using Kamon in your project, add the following dependencies to your build file (example for sbt):

libraryDependencies ++= Seq(
  "io.kamon" %% "kamon-core" % "2.5.8",
  "io.kamon" %% "kamon-system-metrics" % "2.5.8",
  "io.kamon" %% "kamon-prometheus" % "2.5.8"
)

Then, initialize Kamon in your application's main entry point:

import kamon.Kamon

object MyApp extends App {
  Kamon.init()
  
  // Your application code here
  
  Kamon.stop()
}

This setup will enable basic metrics collection and reporting to Prometheus. For more advanced configurations and features, refer to the Kamon documentation.

Competitor Comparisons

OpenTracing API for Java. 🛑 This library is DEPRECATED! https://github.com/opentracing/specification/issues/163

Pros of OpenTracing

  • Vendor-neutral API for distributed tracing
  • Wide industry adoption and support
  • Extensive language support beyond Java

Cons of OpenTracing

  • Less feature-rich compared to Kamon
  • Requires additional implementation for metrics and logging
  • Project is now in maintenance mode, with OpenTelemetry as the successor

Code Comparison

Kamon instrumentation:

val span = Kamon.spanBuilder("operation-name").start()
// ... perform operation ...
span.finish()

OpenTracing instrumentation:

Span span = tracer.buildSpan("operation-name").start();
// ... perform operation ...
span.finish();

Both libraries offer similar APIs for creating and managing spans. Kamon provides additional features like metrics and akka-specific instrumentation out of the box, while OpenTracing focuses solely on tracing with a more language-agnostic approach.

OpenTracing's simplicity and wide adoption make it a solid choice for basic distributed tracing needs. However, Kamon offers a more comprehensive toolkit for monitoring and instrumenting JVM applications, especially those using Akka. Consider your specific requirements and ecosystem when choosing between the two.

16,970

Zipkin is a distributed tracing system

Pros of Zipkin

  • Broader language support, including Java, Go, Python, and more
  • Extensive ecosystem with various integrators and plugins
  • Provides a dedicated UI for trace visualization and analysis

Cons of Zipkin

  • Steeper learning curve for initial setup and configuration
  • Requires additional infrastructure components (e.g., storage backend)
  • May have higher resource overhead for large-scale deployments

Code Comparison

Zipkin (Java):

Span span = tracer.newTrace().name("encode").start();
try {
    doSomethingExpensive();
} finally {
    span.finish();
}

Kamon (Scala):

Kamon.runWithSpan(Span("encode")) {
    doSomethingExpensive()
}

Both Zipkin and Kamon are distributed tracing systems, but they differ in their approach and target audience. Zipkin is a more comprehensive solution with broader language support and a dedicated UI, making it suitable for complex, polyglot environments. Kamon, on the other hand, is more focused on Scala and Akka ecosystems, offering a simpler setup and integration process for those specific use cases.

Zipkin's code example demonstrates manual span creation and management, while Kamon's example shows a more concise, functional approach to span creation and automatic management. This reflects the different design philosophies and target languages of the two projects.

Prometheus instrumentation library for JVM applications

Pros of client_java

  • Native Prometheus integration, offering seamless compatibility with the Prometheus ecosystem
  • Extensive documentation and examples, making it easier for developers to implement and use
  • Active development and maintenance by the Prometheus team, ensuring up-to-date features and bug fixes

Cons of client_java

  • Limited to Prometheus-specific metrics, potentially lacking flexibility for other monitoring systems
  • May require more setup and configuration compared to Kamon's all-in-one approach
  • Less focus on application-specific metrics and more on system-level monitoring

Code Comparison

Kamon example:

val counter = Kamon.counter("my_counter").withTag("tag", "value")
counter.increment()

client_java example:

Counter counter = Counter.build()
    .name("my_counter").help("My counter")
    .labelNames("tag").register();
counter.labels("value").inc();

Both libraries offer similar functionality for creating and incrementing counters, but Kamon's syntax is more concise. client_java provides more detailed configuration options, such as help text, which aligns with Prometheus conventions.

An application observability facade for the most popular observability tools. Think SLF4J, but for observability.

Pros of Micrometer

  • Wider adoption and integration with popular monitoring systems like Prometheus, Datadog, and InfluxDB
  • More extensive documentation and community support
  • Designed to be vendor-neutral, allowing for easier switching between different monitoring backends

Cons of Micrometer

  • Steeper learning curve for beginners due to its more complex API
  • Potentially higher overhead in some scenarios, especially when using multiple monitoring systems simultaneously

Code Comparison

Kamon example:

val counter = Kamon.counter("my-counter").withTag("tag", "value")
counter.increment()

Micrometer example:

Counter counter = Metrics.counter("my-counter", "tag", "value");
counter.increment();

Summary

Micrometer offers broader integration options and vendor-neutrality, making it suitable for larger, more complex projects. Kamon, while less widely adopted, provides a simpler API that may be easier for beginners to grasp. Both libraries offer similar core functionality, but Micrometer's extensive ecosystem and documentation give it an edge in terms of flexibility and long-term scalability.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Kamon Telemetry

Discord Maven Central

Kamon Telemetry is a set of libraries for instrumenting applications running on the JVM. With Kamon Telemetry you can collect metrics, propagate context across threads and services, and get distributed traces automatically. The best way to get started is following our installation guides and taking it from there. Have fun with Kamon!

License

This software is licensed under the Apache 2 license, quoted below.

Copyright © 2013-2022 the kamon project https://kamon.io/

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

[http://www.apache.org/licenses/LICENSE-2.0]

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.