Skip to content

Zipkin OTEL 0.2.0

Latest
Compare
Choose a tag to compare
@making making released this 16 Jan 06:06
· 4 commits to main since this release

What's Changed

  • Add OTLP log endpoint to convert log events to span annotations by @making in #26
  • Make the mapping from brave tags to otel attributes configurable by @making in #27
  • Support mapping brave info to otel server/client.address/port attributes by @making in #28
  • Apply Square Java Code Styles by @making in #30
  • Bump Zipkin from 3.4.3 to 3.4.4

Full Changelog: 0.1.2...0.2.0

Usage

Encoder

Add the dependency:

		<dependency>
			<groupId>io.zipkin.contrib.otel</groupId>
			<artifactId>encoder-brave</artifactId>
			<version>0.2.0</version>
		</dependency>

The following demonstrates using the encoder:

// 'sender' is directed at the OTLP tracing endpoint (e.g., http://localhost:4318/v1/traces)
spanHandler = AsyncZipkinSpanHandler.newBuilder(sender).build(OtlpProtoV1Encoder.create());

You can customize the encoder as follows:

OtlpProtoV1Encoder encoder = OtlpProtoV1Encoder.newBuilder()
    // OpenTelemetry Instrumentation scope
    .instrumentationScope(new InstrumentationScope("com.example.app", "1.0.0"))
    // OpenTelemetry Resource Attributes
    .resourceAttributes(Map.of("key", "value"))
    // Mapping from Brave Tags to OpenTelemetry Attributes
    .tagToAttributes(TagToAttributes.newBuilder()
        .withDefaults()
        .tagToAttribute("method", "http.request.method")
        .tagToAttribute("status", "http.response.status_code")
        .build())
    // Brave Error Tag
    .errorTag(Tags.ERROR)
    .build();

Collector

To start the Zipkin OTLP collector, use the following Docker command:

# The endpoint for OTLP/HTTP is http://localhost:9411/v1/traces
docker run --rm -p 9411:9411 -e UI_ENABLED=true ghcr.io/openzipkin-contrib/zipkin-otel:0.2.0

For a complete example, please refer to the sample repository.