Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ To build the all of examples, run:
- [Telemetry Testing](telemetry-testing)
- This module demonstrates how to test OpenTelemetry instrumentation with
MockServer.
- [Setting up the Zipkin exporter](zipkin)
- [Exporting to a Zipkin backend with OTLP](zipkin)
- This module contains a fully functional example of configuring the
OpenTelemetry SDK to use a Zipkin exporter and send spans to a
OpenTelemetry SDK to use an OTLP exporter and send spans to a
Zipkin backend using the OpenTelemetry API.
- Note: This example requires Docker to be installed.
- [Declarative Configuration with the OpenTelemetry Java Agent](javaagent-declarative-configuration)
Expand Down
1 change: 0 additions & 1 deletion doc-snippets/configuration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("io.opentelemetry:opentelemetry-exporter-logging")
implementation("io.opentelemetry:opentelemetry-exporter-logging-otlp")
implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
implementation("io.opentelemetry:opentelemetry-sdk-extension-jaeger-remote-sampler")

Expand Down
1 change: 0 additions & 1 deletion doc-snippets/exporters/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("io.opentelemetry:opentelemetry-sdk")
implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
}
23 changes: 0 additions & 23 deletions doc-snippets/exporters/src/main/java/otel/ZipkinExporter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static OpenTelemetry initializeOpenTelemetry(String ip, int port) {
Resource serviceNameResource =
Resource.create(Attributes.of(ServiceAttributes.SERVICE_NAME, SERVICE_NAME));

// Set to process the spans by the Zipkin Exporter
// Set to process the spans by the OTLP exporter
SdkTracerProvider tracerProvider =
SdkTracerProvider.builder()
.addSpanProcessor(SimpleSpanProcessor.create(spanExporter))
Expand Down
21 changes: 18 additions & 3 deletions zipkin/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Zipkin Example

This is a simple example that demonstrates how to use the OpenTelemetry SDK
to instrument a simple application using Zipkin as the trace exporter.
to instrument a simple application and send spans over OTLP to a Zipkin backend.

Note: the OpenTelemetry Java SDK no longer ships a Zipkin exporter
(`opentelemetry-exporter-zipkin` stopped being published in 1.65.0), so this
example exports OTLP and relies on Zipkin's own OTLP ingestion. Upstream
`openzipkin/zipkin` does not include an OTLP collector, so the
[zipkin-otel](https://github.com/openzipkin-contrib/zipkin-otel) distribution is
used below. It binds OTLP/HTTP endpoints to Zipkin's regular server port, 9411.

## How to Run

Expand All @@ -20,11 +27,19 @@ to instrument a simple application using Zipkin as the trace exporter.
## 2 - Run Zipkin

```shell script
docker run --rm -it --name zipkin \
docker run --rm -it --name zipkin-otel \
-p 9411:9411 \
openzipkin/zipkin:latest
ghcr.io/openzipkin-contrib/zipkin-otel:latest
```

Verify that the OTLP collector is running:

```shell script
curl -s localhost:9411/health
```

The response should include `"OpenTelemetryHttpCollector{}": {"status": "UP"}`.

## 3 - Start the Application

```shell script
Expand Down
4 changes: 2 additions & 2 deletions zipkin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("java")
}

description = "OpenTelemetry Examples for Zipkin Exporter"
description = "OpenTelemetry Example exporting OTLP to a Zipkin backend"
extra.set("moduleName", "io.opentelemetry.examples.zipkin")

java {
Expand All @@ -14,7 +14,7 @@ java {
dependencies {
implementation("io.opentelemetry:opentelemetry-api")
implementation("io.opentelemetry:opentelemetry-sdk")
implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
implementation("io.opentelemetry:opentelemetry-exporter-otlp")

//alpha module
implementation("io.opentelemetry.semconv:opentelemetry-semconv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@

package io.opentelemetry.example.zipkin;

import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;

import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.exporter.zipkin.ZipkinSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.resources.Resource;
import io.opentelemetry.sdk.trace.SdkTracerProvider;
import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import io.opentelemetry.semconv.ServiceAttributes;

/**
Expand All @@ -25,18 +24,19 @@ public final class ExampleConfiguration {
// Name of the service
private static final String SERVICE_NAME = "myExampleService";

/** Adds a SimpleSpanProcessor initialized with ZipkinSpanExporter to the TracerSdkProvider */
/** Adds a SimpleSpanProcessor initialized with OtlpHttpSpanExporter to the TracerSdkProvider */
static OpenTelemetry initializeOpenTelemetry(String ip, int port) {
String endpoint = String.format("http://%s:%s/api/v2/spans", ip, port);
ZipkinSpanExporter zipkinExporter = ZipkinSpanExporter.builder().setEndpoint(endpoint).build();
// Zipkin's OTLP endpoints are bound to its regular server port
String endpoint = String.format("http://%s:%s/v1/traces", ip, port);
SpanExporter spanExporter = OtlpHttpSpanExporter.builder().setEndpoint(endpoint).build();

Resource serviceNameResource =
Resource.create(Attributes.of(ServiceAttributes.SERVICE_NAME, SERVICE_NAME));

// Set to process the spans by the Zipkin Exporter
// Set to process the spans by the OTLP exporter
SdkTracerProvider tracerProvider =
SdkTracerProvider.builder()
.addSpanProcessor(SimpleSpanProcessor.create(zipkinExporter))
.addSpanProcessor(SimpleSpanProcessor.create(spanExporter))
.setResource(Resource.getDefault().merge(serviceNameResource))
.build();
OpenTelemetrySdk openTelemetry =
Expand Down
Loading