Skip to content

soklet/soklet-otel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Soklet

Soklet OpenTelemetry Integration (otel)

OpenTelemetry metrics integration for Soklet, implemented via MetricsCollector.

What Is It?

This Soklet add-on library provides OpenTelemetryMetricsCollector, a production-oriented implementation of Soklet's MetricsCollector interface.

It records HTTP + SSE lifecycle telemetry into OpenTelemetry Meter instruments (counters, up-down counters, and histograms), so your existing OTel pipeline/exporter stack can collect and ship metrics.

Its only dependency other than Soklet is opentelemetry-java (the Java implementation of the OpenTelemetry API).

Like Soklet, Java 17+ is required.

Installation

<dependency>
  <groupId>com.soklet</groupId>
  <artifactId>soklet-otel</artifactId>
  <version>1.1.0</version>
</dependency>

Usage

Create a collector and wire it into SokletConfig:

import com.soklet.SokletConfig;
import com.soklet.Server;
import com.soklet.otel.OpenTelemetryMetricsCollector;
import io.opentelemetry.api.OpenTelemetry;

// Acquire an OpenTelemetry instance from wherever you'd like...
OpenTelemetry openTelemetry = myOpenTelemetry();

// ...and use it to drive Soklet's OpenTelemetryMetricsCollector.
SokletConfig config = SokletConfig.withServer(
  Server.fromPort(8080)
).metricsCollector(
  OpenTelemetryMetricsCollector.withOpenTelemetry(openTelemetry)
    // Optional: SOKLET for fully-custom soklet.* HTTP metric names
    // .metricNamingStrategy(OpenTelemetryMetricsCollector.MetricNamingStrategy.SOKLET)
    .instrumentationName("com.mycompany.myapp.soklet")
    .instrumentationVersion("1.0.0")
    .build()
).build();

Related API references:

If you already have a Meter, wire directly:

OpenTelemetryMetricsCollector collector = 
  OpenTelemetryMetricsCollector.withMeter(myMeter).build();

Emitted Metrics

HTTP metrics (default strategy: SEMCONV):

  • http.server.active_requests
  • http.server.request.duration
  • http.server.request.body.size
  • http.server.response.body.size

Soklet-specific metrics (all strategies):

  • soklet.server.connections.accepted
  • soklet.server.connections.rejected
  • soklet.server.requests.accepted
  • soklet.server.requests.rejected
  • soklet.server.request.read.failures
  • soklet.server.response.write.duration
  • soklet.server.response.write.failures
  • soklet.sse.connections.active
  • soklet.sse.connections.established
  • soklet.sse.connections.handshake.failures
  • soklet.sse.connections.terminated
  • soklet.sse.connection.duration
  • soklet.sse.events.written
  • soklet.sse.events.write.failures
  • soklet.sse.events.write.duration
  • soklet.sse.events.delivery.lag
  • soklet.sse.events.payload.size
  • soklet.sse.events.queue.depth
  • soklet.sse.events.dropped
  • soklet.sse.comments.written
  • soklet.sse.comments.write.failures
  • soklet.sse.comments.write.duration
  • soklet.sse.comments.delivery.lag
  • soklet.sse.comments.payload.size
  • soklet.sse.comments.queue.depth
  • soklet.sse.comments.dropped
  • soklet.sse.broadcast.attempted
  • soklet.sse.broadcast.enqueued
  • soklet.sse.broadcast.dropped

Common attributes:

  • soklet.server.type (standard_http, server_sent_event)
  • soklet.failure.reason
  • error.type
  • http.request.method
  • url.scheme
  • http.route
  • http.response.status_code
  • soklet.sse.termination.reason
  • soklet.sse.drop.reason
  • soklet.sse.comment.type
  • soklet.sse.broadcast.payload.type

Cardinality Guidance

  • http.route uses Soklet route declarations when available (for example /widgets/{id}).
  • With SEMCONV, unmatched requests omit http.route (per OTel guidance).
  • With SOKLET, unmatched requests are grouped under _unmatched.
  • Request paths, remote addresses, and raw query values are intentionally not emitted as attributes by default.

Notes

  • The collector is thread-safe and designed for callback hot paths (no I/O or blocking operations in callback methods).
  • MetricNamingStrategy.SEMCONV is the default for HTTP metric names.
  • snapshot() / snapshotText() from MetricsCollector are not implemented here; use your OpenTelemetry backend/exporter to query metrics.

For Soklet documentation and lifecycle semantics, see https://www.soklet.com.

About

Soklet OpenTelemetry (OTel) Integration

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages