Kora фреймворк для написания Java / Kotlin приложений с упором на производительность, эффективность, прозрачность сделанный разработчиками Т-Банк / Тинькофф

Kora is a framework for writing Java / Kotlin applications with a focus on performance, efficiency, transparency made by T-Bank / Tinkoff developers

Skip to content

Tracing

Module for collecting application trace according to [OpenTelemetry] standard(https://opentelemetry.io/docs/what-is-opentelemetry/) and export trace by gRPC in OTLP format.

gRPC

Module allows trace collection using gRPC protocol by means of GrpcSender.

Зависимость build.gradle:

implementation "ru.tinkoff.kora:opentelemetry-tracing-exporter-grpc"

Модуль:

@KoraApp
public interface Application extends OpentelemetryGrpcExporterModule { }

Зависимость build.gradle.kts:

implementation("ru.tinkoff.kora:opentelemetry-tracing-exporter-grpc")

Модуль:

@KoraApp
interface Application : OpentelemetryGrpcExporterModule

HTTP

Module allows to collect trace using HTTP protocol by means of HttpSender.

Зависимость build.gradle:

implementation "ru.tinkoff.kora:opentelemetry-tracing-exporter-http"

Модуль:

@KoraApp
public interface Application extends OpentelemetryHttpExporterModule { }

Зависимость build.gradle.kts:

implementation("ru.tinkoff.kora:opentelemetry-tracing-exporter-http")

Модуль:

@KoraApp
interface Application : OpentelemetryHttpExporterModule

Configuration

endpoint is the only a required field, attributes from the attributes field will be sent with each span.

Parameters described in the OpentelemetryGrpcExporterConfig/OpentelemetryHttpExporterConfig and OpentelemetryResourceConfig classes:

tracing {
  exporter {
    endpoint = "http://localhost:4317" // (1)!
    exportTimeout = "2s" // (2)!
    scheduleDelay = "2s" // (3)!
    maxExportBatchSize = 512 // (4)!
    maxQueueSize = 1024 // (5)!
  }
  attributes { // (6)!
    "service.name" = "example-service"
    "service.namespace" = "kora"
  }
}
  1. URL from OpenTelemetry service collector (required)
  2. Maximum time to wait for the collector to process telemetry
  3. Time between exporting telemetry to the collector
  4. Maximum number of telemetry within one export
  5. Maximum queue size of unsent telemetry
  6. Additional telemetry attributes
tracing:
  exporter:
    endpoint: http://localhost:4317 # (1)!
    exportTimeout: 2s # (2)!
    scheduleDelay: 2s # (3)!
    maxExportBatchSize: 512 # (4)!
    maxQueueSize: 1024 # (6)!
  attributes: # (6)!
    service.name: example-service
    service.namespace: kora
  1. URL from OpenTelemetry service collector (required)
  2. Maximum time to wait for the collector to process telemetry
  3. Time between exporting telemetry to the collector
  4. Maximum number of telemetry within one export
  5. Maximum queue size of unsent telemetry
  6. Additional telemetry attributes

Trace collection configuration parameters are described in modules that include trace collection, e.g. HTTP server, HTTP client, etc.

Imperative tracing

In addition to automatically created spans, you can use the Tracer object from the dependency container. You can create a span with the current one in parent as follows:

var context = Context.current();
var telemetryContext = OpentelemetryContext.get(context);
var newSpan = this.tracer.spanBuilder("some-span")
    .setParent(telemetryContext.getContext())
    .build();
val context = Context.current();
val telemetryContext = OpentelemetryContext.get(context);
val newSpan = this.tracer.spanBuilder("some-span")
    .setParent(telemetryContext.getContext())
    .build();