Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Support OpenTracing 0.32.0 and 0.33.0 (#623)
Browse files Browse the repository at this point in the history
* Support opentracing 0.32.0 and 0.33.0

Signed-off-by: Pavol Loffay <[email protected]>

* unify messages

Signed-off-by: Pavol Loffay <[email protected]>

* Test 0.32.0

Signed-off-by: Pavol Loffay <[email protected]>

* Simplify gradle

Signed-off-by: Pavol Loffay <[email protected]>

* remove line

Signed-off-by: Pavol Loffay <[email protected]>

* Add one more test

Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay authored Jul 31, 2019
1 parent 0d4c675 commit cf9f993
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 80 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ local.properties
# IntelliJ
/out/
/jaeger-core/out/
/jaeger-core-ot-0.32.0-itest/out/

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ plugins {
id 'net.researchgate.release' version '2.6.0'
}

ext.opentracingVersion = getProperty('opentracingVersion','0.32.0')
ext.opentracingVersion = getProperty('opentracingVersion','0.33.0')
ext.guavaVersion = getProperty('guavaVersion','18.0')
ext.apacheThriftVersion = getProperty('apacheThriftVersion','0.12.0')
ext.jerseyVersion = getProperty('jerseyVersion','2.22.2')
ext.slf4jVersion = getProperty('slf4jVersion','1.7.25')
ext.gsonVersion = getProperty('gsonVersion','2.8.2')
ext.tracerResolverVersion = getProperty('tracerResolverVersion','0.1.6')
ext.tracerResolverVersion = getProperty('tracerResolverVersion','0.1.8')
ext.micrometerVersion = getProperty('micrometerVersion','1.0.0')
ext.okhttpVersion = getProperty('okhttpVersion','3.9.0')

Expand Down
16 changes: 16 additions & 0 deletions jaeger-core-ot-0.32.0-itest/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description = 'Test module for compatibility with opentracing-api:0.32.0'

dependencies {
testCompile group: 'io.opentracing', name: 'opentracing-api', version: "0.32.0"
testCompile group: 'io.opentracing', name: 'opentracing-util', version: "0.32.0"
testCompile group: 'com.google.code.gson', name: 'gson', version: gsonVersion
testCompile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion

testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'org.mockito', name: 'mockito-core', version: mockitoVersion

testCompile files(this.project(':jaeger-core').sourceSets.test.output)
testCompile files(this.project(':jaeger-core').sourceSets.main.output)
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* 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.jaegertracing.internal;

public class ActiveSpan032Test extends ActiveSpanTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* 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.jaegertracing.internal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import io.jaegertracing.internal.reporters.InMemoryReporter;
import io.jaegertracing.internal.samplers.ConstSampler;
import io.opentracing.Scope;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.util.AutoFinishScopeManager;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;

/**
* Tests for removed deprecated APIs from 0.32.0 to 0.33.0.
*/
@SuppressWarnings("deprecation")
public class RemovedFrom032Test {
private static final String SPAN_NAME = "foo";

private InMemoryReporter reporter;
private Tracer tracer;

@Before
public void setUp() {
reporter = new InMemoryReporter();
tracer =
new JaegerTracer.Builder("TracerTestService")
.withReporter(reporter)
.withSampler(new ConstSampler(true))
.build();
}

@Test
public void testScopeManager_active() {
Span span = tracer.buildSpan(SPAN_NAME).start();
Scope scope = tracer.activateSpan(span);
try {
assertEquals(scope, tracer.scopeManager().active());
} finally {
scope.close();
}
}

@Test
public void testScopeManager_activate_and_not_finish() {
Span span = tracer.buildSpan(SPAN_NAME).start();
Scope scope = tracer.scopeManager().activate(span, false);
try {
assertEquals(scope, tracer.scopeManager().active());
} finally {
scope.close();
}
assertEquals(0, reporter.getSpans().size());
}

@Test
public void testScopeManager_activate_and_finish() {
Span span = tracer.buildSpan(SPAN_NAME).start();
Scope scope = tracer.scopeManager().activate(span, true);
try {
assertEquals(scope, tracer.scopeManager().active());
} finally {
scope.close();
}
assertEquals(Collections.singletonList(span), reporter.getSpans());
}

@Test
public void testScope_span() {
Span span = tracer.buildSpan(SPAN_NAME).start();
Scope scope = tracer.scopeManager().activate(span);
try {
assertEquals(span, scope.span());
} finally {
scope.close();
}
}

@Test
public void testSpanBuilder_startActive() {
Scope scope = tracer.buildSpan(SPAN_NAME).startActive(true);
try {
assertEquals(scope.span(), tracer.activeSpan());
} finally {
scope.close();
}
assertEquals(Collections.singletonList(scope.span()), reporter.getSpans());
}

@Test
public void testTracer_startManual() {
Span span = tracer.buildSpan(SPAN_NAME).startManual();
assertEquals(null, tracer.activeSpan());
span.finish();
assertEquals(Collections.singletonList(span), reporter.getSpans());
}

@Test
public void testAutoFinishScopeManager() {
assertNotNull(new AutoFinishScopeManager());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* 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.jaegertracing.internal;

public class Tracer032Test extends JaegerTracerTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* 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.jaegertracing.internal;

import static org.junit.Assert.assertNotNull;

import io.opentracing.ScopeManager;
import io.opentracing.Span;
import org.junit.Test;

public class Version032Test {

@Test
public void testVersion_0_32() throws NoSuchMethodException {
assertNotNull(ScopeManager.class.getMethod("activate", Span.class, boolean.class)
.getAnnotation(Deprecated.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,26 @@ public JaegerSpan start() {
return jaegerSpan;
}

@Override
public Scope startActive(boolean finishSpanOnClose) {
return scopeManager.activate(start(), finishSpanOnClose);
@Deprecated
// @Override keep compatibility with 0.32.0
public Scope startActive(final boolean finishSpanOnClose) {
if (!finishSpanOnClose) {
return scopeManager.activate(start());
}
return new Scope() {
Span span = start();
Scope wrapped = scopeManager.activate(span);
@Override
public void close() {
wrapped.close();
span.finish();
}

// @Override keep compatibility with 0.32.0
public Span span() {
return span;
}
};
}

@Override
Expand All @@ -486,9 +503,9 @@ public JaegerTracer.SpanBuilder ignoreActiveSpan() {
return this;
}

@Override
@Deprecated
public JaegerSpan startManual() {
// @Override keep compatibility with 0.32.0
public Span startManual() {
return start();
}

Expand Down
Loading

0 comments on commit cf9f993

Please sign in to comment.