Skip to content

Commit

Permalink
Add Zipkin exporter support (#411)
Browse files Browse the repository at this point in the history
* #375 Add Zipkin exporter support

Signed-off-by: Sergei Malafeev <[email protected]>

* #375 use OkHttpSender for Zipkin exporter

Signed-off-by: Sergei Malafeev <[email protected]>

* #375 add Zipkin exporter to README

Signed-off-by: Sergei Malafeev <[email protected]>

Co-authored-by: Trask Stalnaker <[email protected]>
  • Loading branch information
malafeev and trask authored May 19, 2020
1 parent 46c0c08 commit 7ea2da3
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- run:
name: Build Project
command: GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1G -Xms64M' -Dota.forkedMaxHeapSize=1G -Dota.forkedMinHeapSize=64M" ./gradlew clean compileTestGroovy compileLatestDepTestGroovy compileTestScala compileLatestDepTestScala compileTestJava compileLatestDepTestJava :opentelemetry-auto:shadowJar :auto-exporters:opentelemetry-auto-exporters-jaeger:shadowJar :auto-exporters:opentelemetry-auto-exporters-otlp:shadowJar :auto-exporters:opentelemetry-auto-exporters-logging:shadowJar --build-cache --parallel --stacktrace --no-daemon --max-workers=8
command: GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1G -Xms64M' -Dota.forkedMaxHeapSize=1G -Dota.forkedMinHeapSize=64M" ./gradlew clean compileTestGroovy compileLatestDepTestGroovy compileTestScala compileLatestDepTestScala compileTestJava compileLatestDepTestJava :opentelemetry-auto:shadowJar :auto-exporters:opentelemetry-auto-exporters-jaeger:shadowJar :auto-exporters:opentelemetry-auto-exporters-otlp:shadowJar :auto-exporters:opentelemetry-auto-exporters-logging:shadowJar :auto-exporters:opentelemetry-auto-exporters-zipkin:shadowJar --build-cache --parallel --stacktrace --no-daemon --max-workers=8

- run:
name: Collect Libs
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ only supports gRPC as its communications protocol.
| ota.exporter.jaeger.endpoint | OTA_EXPORTER_JAEGER_ENDPOINT | The Jaeger endpoint to connect to. Currently only gRPC is supported. |
| ota.exporter.jaeger.service.name | OTA_EXPORTER_JAEGER_SERVICE_NAME | The service name of this JVM instance |

#### Zipkin exporter
A simple wrapper for the Zipkin exporter of opentelemetry-java. It POSTs json in [Zipkin format](https://zipkin.io/zipkin-api/#/default/post_spans) to a specified HTTP URL.

| System property | Environment variable | Purpose |
|----------------------------------|----------------------------------|----------------------------------------------------------------------|
| ota.exporter.zipkin.endpoint | OTA_EXPORTER_ZIPKIN_ENDPOINT | The Zipkin endpoint to connect to. Currently only HTTP is supported. |
| ota.exporter.zipkin.service.name | OTA_EXPORTER_ZIPKIN_SERVICE_NAME | The service name of this JVM instance

#### OTLP exporter

A simple wrapper for the OTLP exporter of opentelemetry-java.
Expand Down
3 changes: 3 additions & 0 deletions auto-exporters/auto-exporters.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ dependencies {
testCompile project(':auto-exporters:opentelemetry-auto-exporters-otlp')
testCompile project(':auto-exporters:opentelemetry-auto-exporters-jaeger')
testCompile project(':auto-exporters:opentelemetry-auto-exporters-logging')
testCompile project(':auto-exporters:opentelemetry-auto-exporters-zipkin')
}

tasks.withType(Test).configureEach() {
dependsOn ':auto-exporters:opentelemetry-auto-exporters-otlp:shadowJar'
dependsOn ':auto-exporters:opentelemetry-auto-exporters-jaeger:shadowJar'
dependsOn ':auto-exporters:opentelemetry-auto-exporters-logging:shadowJar'
dependsOn ':auto-exporters:opentelemetry-auto-exporters-zipkin:shadowJar'
doFirst {
systemProperty 'projectVersion', allprojects.version[0]
systemProperty 'adapterRoot', "${rootDir}/auto-exporters"
systemProperty 'otlpExporterJar', project(':auto-exporters:opentelemetry-auto-exporters-otlp').tasks.shadowJar.archivePath
systemProperty 'jaegerExporterJar', project(':auto-exporters:opentelemetry-auto-exporters-jaeger').tasks.shadowJar.archivePath
systemProperty 'loggingExporterJar', project(':auto-exporters:opentelemetry-auto-exporters-logging').tasks.shadowJar.archivePath
systemProperty 'zipkinExporterJar', project(':auto-exporters:opentelemetry-auto-exporters-zipkin').tasks.shadowJar.archivePath
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class ExporterAdaptersTest extends Specification {
@Shared
def loggingExporterJar = System.getProperty("loggingExporterJar")

@Shared
def zipkinExporterJar = System.getProperty("zipkinExporterJar")

@Shared
def jaegerDir = new File("${adapterRoot}/jaeger-adapter/build/libs")

Expand All @@ -45,7 +48,7 @@ class ExporterAdaptersTest extends Specification {
file != null

where:
exporter << [otlpExporterJar, jaegerExporterJar, loggingExporterJar]
exporter << [otlpExporterJar, jaegerExporterJar, loggingExporterJar, zipkinExporterJar]
}

def "test exporter load"() {
Expand All @@ -70,5 +73,6 @@ class ExporterAdaptersTest extends Specification {
otlpExporterJar | 'io.opentelemetry.auto.exporters.otlp.OtlpSpanExporterFactory'
jaegerExporterJar | 'io.opentelemetry.auto.exporters.jaeger.JaegerExporterFactory'
loggingExporterJar | 'io.opentelemetry.auto.exporters.logging.LoggingExporterFactory'
zipkinExporterJar | 'io.opentelemetry.auto.exporters.zipkin.ZipkinExporterFactory'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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.
*/
package io.opentelemetry.auto.exporters.zipkin;

import io.opentelemetry.exporters.zipkin.ZipkinExporterConfiguration;
import io.opentelemetry.exporters.zipkin.ZipkinSpanExporter;
import io.opentelemetry.sdk.contrib.auto.config.Config;
import io.opentelemetry.sdk.contrib.auto.config.SpanExporterFactory;
import io.opentelemetry.sdk.trace.export.SpanExporter;
import zipkin2.reporter.okhttp3.OkHttpSender;

public class ZipkinExporterFactory implements SpanExporterFactory {
private static final String ZIPKIN_ENDPOINT = "zipkin.endpoint";
private static final String DEFAULT_ZIPKIN_ENDPOINT = "http://localhost:9411/api/v2/spans";

private static final String ZIPKIN_SERVICE_NAME = "zipkin.service.name";
private static final String DEFAULT_ZIPKIN_SERVICE_NAME = "(unknown service)";

@Override
public SpanExporter fromConfig(Config config) {
final String zipkinEndpoint = config.getString(ZIPKIN_ENDPOINT, DEFAULT_ZIPKIN_ENDPOINT);
final String serviceName = config.getString(ZIPKIN_SERVICE_NAME, DEFAULT_ZIPKIN_SERVICE_NAME);
return ZipkinSpanExporter.create(
ZipkinExporterConfiguration.builder()
.setSender(OkHttpSender.create(zipkinEndpoint))
.setServiceName(serviceName)
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
io.opentelemetry.auto.exporters.zipkin.ZipkinExporterFactory
17 changes: 17 additions & 0 deletions auto-exporters/zipkin/zipkin.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
id "com.github.johnrengelman.shadow"
}

apply from: "${rootDir}/gradle/java.gradle"

dependencies {
compile(deps.opentelemetryZipkin) {
exclude group: 'io.opentelemetry', module: 'opentelemetry-sdk'
}
compileOnly deps.opentelemetrySdkAutoConfig
compile group: 'io.zipkin.reporter2', name: 'zipkin-sender-okhttp3', version: '2.12.2'
}

shadowJar {
archiveClassifier = ''
}
1 change: 1 addition & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ext {
opentelemetrySdkAutoConfig : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-sdk-contrib-auto-config', version: versions.opentelemetry),
opentelemetryJaeger : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-jaeger', version: versions.opentelemetry),
opentelemetryOtlp : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-otlp', version: versions.opentelemetry),
opentelemetryZipkin : dependencies.create(group: 'io.opentelemetry', name: 'opentelemetry-exporters-zipkin', version: versions.opentelemetry),

// General
slf4j : "org.slf4j:slf4j-api:${versions.slf4j}",
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ include ":auto-exporters"
include ":auto-exporters:jaeger"
include ":auto-exporters:logging"
include ":auto-exporters:otlp"
include ":auto-exporters:zipkin"

// benchmark
include ':benchmark'
Expand All @@ -174,3 +175,4 @@ project(':java-agent').name = 'opentelemetry-auto'
project(':auto-exporters:jaeger').name = 'opentelemetry-auto-exporters-jaeger'
project(':auto-exporters:logging').name = 'opentelemetry-auto-exporters-logging'
project(':auto-exporters:otlp').name = 'opentelemetry-auto-exporters-otlp'
project(':auto-exporters:zipkin').name = 'opentelemetry-auto-exporters-zipkin'

0 comments on commit 7ea2da3

Please sign in to comment.