Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zipkin exporter support #411

Merged
merged 7 commits into from
May 19, 2020
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
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'