This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
- Loading branch information
1 parent
5050c73
commit 431a558
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
jaeger-zipkin/src/main/java/io/jaegertracing/senders/zipkin/ZipkinReporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.jaegertracing.senders.zipkin; | ||
|
||
import static io.jaegertracing.senders.zipkin.V2SpanConverter.convertSpan; | ||
|
||
import io.jaegertracing.Span; | ||
import io.jaegertracing.reporters.Reporter; | ||
|
||
/** | ||
* @author Pavol Loffay | ||
*/ | ||
public class ZipkinReporter implements Reporter { | ||
|
||
private zipkin2.reporter.Reporter<zipkin2.Span> delegateV2; | ||
|
||
public ZipkinReporter(zipkin2.reporter.Reporter<zipkin2.Span> reporterV2) { | ||
this.delegateV2 = reporterV2; | ||
} | ||
|
||
@Override | ||
public void report(Span span) { | ||
delegateV2.report(convertSpan(span)); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
// noop zipkin cannot be closed | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
jaeger-zipkin/src/test/java/io/jaegertracing/senders/zipkin/ZipkinReporterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.jaegertracing.senders.zipkin; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import io.jaegertracing.Tracer; | ||
import io.jaegertracing.samplers.ConstSampler; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import zipkin.junit.ZipkinRule; | ||
import zipkin2.Span; | ||
import zipkin2.codec.SpanBytesEncoder; | ||
import zipkin2.reporter.AsyncReporter; | ||
import zipkin2.reporter.urlconnection.URLConnectionSender; | ||
|
||
/** | ||
* @author Pavol Loffay | ||
*/ | ||
public class ZipkinReporterTest { | ||
|
||
@Rule | ||
public ZipkinRule zipkinRule = new ZipkinRule(); | ||
|
||
@Test | ||
public void testV1() { | ||
AsyncReporter<Span> zipkinReporter = AsyncReporter | ||
.builder(URLConnectionSender.create(zipkinRule.httpUrl() + "/api/v1/spans")) | ||
.build(SpanBytesEncoder.JSON_V1); | ||
|
||
ZipkinReporter reporterAdapter = new ZipkinReporter(zipkinReporter); | ||
|
||
Tracer tracer = new Tracer.Builder("test") | ||
.withReporter(reporterAdapter) | ||
.withSampler(new ConstSampler(true)) | ||
.build(); | ||
|
||
tracer.buildSpan("foo").start().finish(); | ||
zipkinReporter.flush(); | ||
|
||
assertEquals("foo", zipkinRule.getTraces().get(0).get(0).name); | ||
} | ||
|
||
@Test | ||
public void testV2() { | ||
AsyncReporter<Span> zipkinReporter = AsyncReporter | ||
.builder(URLConnectionSender.create(zipkinRule.httpUrl() + "/api/v2/spans")) | ||
.build(); | ||
|
||
ZipkinReporter reporterAdapter = new ZipkinReporter(zipkinReporter); | ||
|
||
Tracer tracer = new Tracer.Builder("test") | ||
.withReporter(reporterAdapter) | ||
.withSampler(new ConstSampler(true)) | ||
.build(); | ||
|
||
|
||
tracer.buildSpan("foo").start().finish(); | ||
zipkinReporter.flush(); | ||
|
||
assertEquals("foo", zipkinRule.getTraces().get(0).get(0).name); | ||
} | ||
} |