Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
V0.33.0 (#348)
Browse files Browse the repository at this point in the history
* Remove Deprecated members. (#339)
* Set version to 0.33.1-SNAPSHOT. (#345)
* Update CHANGELOG to include v0.33.0 (#347)
  • Loading branch information
carlosalberto committed May 6, 2019
1 parent 6b2998d commit 5ed6a47
Show file tree
Hide file tree
Showing 29 changed files with 57 additions and 516 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changes by Version

## v0.33.0 (2019-05-06)

* Deprecated members removed:
- `ScopeManager.active()`
- `ScopeManager.activate(Span, boolean)`
- `Scope.span()`
- `SpanBuilder.startActive()`
- `Tracer.startManual()`
- `AutoFinishScopeManager`

## v0.32.0 (2019-03-20)

* Trace Identifiers added to `SpanContext`.
Expand Down
2 changes: 1 addition & 1 deletion opentracing-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.opentracing</groupId>
<artifactId>parent</artifactId>
<version>0.32.1-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-api</artifactId>
Expand Down
9 changes: 0 additions & 9 deletions opentracing-api/src/main/java/io/opentracing/Scope.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,4 @@ public interface Scope extends Closeable {
*/
@Override
void close();

/**
* @deprecated use {@link Span} directly or access it through {@link ScopeManager#activeSpan()}
* Return the corresponding active {@link Span} for this instance.
*
* @return the {@link Span} that's been scoped by this {@link Scope}
*/
@Deprecated
Span span();
}
42 changes: 0 additions & 42 deletions opentracing-api/src/main/java/io/opentracing/ScopeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,6 @@ public interface ScopeManager {
*/
Scope activate(Span span);

/**
* @deprecated use {@link #activeSpan()} instead.
* Return the currently active {@link Scope} which can be used to deactivate the currently active
* {@link Span}.
*
* <p>
* Observe that {@link Scope} is expected to be used only in the same thread where it was
* created, and thus should not be passed across threads.
*
* <p>
* Because both {@link #active()} and {@link #activeSpan()} reference the current
* active state, they both will be either null or non-null.
*
* @return the {@link Scope active scope}, or null if none could be found.
*/
@Deprecated
Scope active();

/**
* Return the currently active {@link Span}.
*
Expand All @@ -89,28 +71,4 @@ public interface ScopeManager {
* @return the {@link Span active span}, or null if none could be found.
*/
Span activeSpan();

/**
* @deprecated use {@link #activate(Span)} instead.
* Set the specified {@link Span} as the active instance for the current
* context (usually a thread).
*
* <p>
* Finishing the {@link Span} upon {@link Scope#close()} is discouraged,
* as reporting errors becomes impossible:
* <pre><code>
* try (Scope scope = tracer.scopeManager().activate(span, true)) {
* } catch (Exception e) {
* // Not possible to report errors, as
* // the span has been already finished.
* }
* </code></pre>
*
* @param span the {@link Span} that should become the {@link #activeSpan()}
* @param finishSpanOnClose whether span should automatically be finished when {@link Scope#close()} is called
* @return a {@link Scope} instance to control the end of the active period for the {@link Span}. It is a
* programming error to neglect to call {@link Scope#close()} on the returned instance.
*/
@Deprecated
Scope activate(Span span, boolean finishSpanOnClose);
}
48 changes: 0 additions & 48 deletions opentracing-api/src/main/java/io/opentracing/Tracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ interface SpanBuilder {
/** Specify a timestamp of when the Span was started, represented in microseconds since epoch. */
SpanBuilder withStartTimestamp(long microseconds);

/**
* @deprecated use {@link #start} instead.
*/
@Deprecated
Span startManual();

/**
* Returns a newly-started {@link Span}.
*
Expand All @@ -219,47 +213,5 @@ interface SpanBuilder {
* via the {@link ScopeManager}
*/
Span start();

/**
* @deprecated use {@link #start()} and {@link ScopeManager#activate(Span span)} instead.
* Returns a newly started and activated {@link Scope}.
*
* <p>
* {@link SpanBuilder#startActive()} is a shorthand for
* {@code tracer.scopeManager().activate(spanBuilder.start())}.
* The returned {@link Scope} supports try-with-resources, but using this method is
* discouraged as the {@link Span} reference could be easily lost, and reporting
* errors on {@link Span} through this method becomes impossible:
* <pre><code>
* try (Scope scope = tracer.buildSpan("...").startActive(true)) {
* // (Do work)
* scope.span().setTag( ... ); // etc, etc
* } catch (Exception e) {
* // Not possible to report errors, as
* // the span reference has been lost,
* // and span has been already finished too.
* }
* </code></pre>
*
* <p>
* It is recommended to use {@link #start()} with a subsequent call to
* {@link ScopeManager#activate(Span)}
* <pre><code>
* Span span = tracer.buildSpan("...").start();
* try (Scope scope = tracer.activateSpan(span)) {
* } catch (Exception e) {
* span.log(...); // Report any errors properly.
* } finally {
* span.finish(); // Optionally close the Span.
* }
* </code></pre>
*
* @return a {@link Scope}, already registered via the {@link ScopeManager}
*
* @see ScopeManager
* @see Scope
*/
@Deprecated
Scope startActive(boolean finishSpanOnClose);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ public StringTag(String key) {
public void set(Span span, String tagValue) {
span.setTag(super.key, tagValue);
}

/**
* @deprecated as using the tag *key* as tag value is not usually required.
*/
@Deprecated
public void set(Span span, StringTag tag) {
span.setTag(super.key, tag.key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,4 @@ public void testSetString() {

verify(span).setTag(key, value);
}

@Test
public void testSetOtherTag() {
String key = "expected.key";

Span span = mock(Span.class);
StringTag tag = new StringTag(key);
tag.set(span, new StringTag(key));

verify(span).setTag(key, key);
}
}
2 changes: 1 addition & 1 deletion opentracing-mock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.opentracing</groupId>
<artifactId>parent</artifactId>
<version>0.32.1-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-mock</artifactId>
Expand Down
10 changes: 0 additions & 10 deletions opentracing-mock/src/main/java/io/opentracing/mock/MockTracer.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,18 +372,8 @@ public SpanBuilder withStartTimestamp(long microseconds) {
return this;
}

@Override
public Scope startActive(boolean finishOnClose) {
return MockTracer.this.scopeManager().activate(this.startManual(), finishOnClose);
}

@Override
public MockSpan start() {
return startManual();
}

@Override
public MockSpan startManual() {
if (this.startMicros == 0) {
this.startMicros = MockSpan.nowMicros();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,29 +264,12 @@ public void testActiveSpan() {
Assert.assertTrue(mockTracer.finishedSpans().isEmpty());
}

@Test
public void testActiveSpanFinish() {
MockTracer mockTracer = new MockTracer();
Assert.assertNull(mockTracer.activeSpan());

Scope scope = null;
try {
scope = mockTracer.buildSpan("foo").startActive(true);
Assert.assertEquals(mockTracer.scopeManager().activeSpan(), mockTracer.activeSpan());
} finally {
scope.close();
}

Assert.assertNull(mockTracer.activeSpan());
Assert.assertFalse(mockTracer.finishedSpans().isEmpty());
}

@Test
public void testReset() {
MockTracer mockTracer = new MockTracer();

mockTracer.buildSpan("foo")
.startManual()
.start()
.finish();

assertEquals(1, mockTracer.finishedSpans().size());
Expand All @@ -297,11 +280,11 @@ public void testReset() {
@Test
public void testFollowFromReference() {
MockTracer tracer = new MockTracer(MockTracer.Propagator.TEXT_MAP);
final MockSpan precedent = tracer.buildSpan("precedent").startManual();
final MockSpan precedent = tracer.buildSpan("precedent").start();

final MockSpan followingSpan = tracer.buildSpan("follows")
.addReference(References.FOLLOWS_FROM, precedent.context())
.startManual();
.start();

assertEquals(precedent.context().spanId(), followingSpan.parentId());
assertEquals(1, followingSpan.references().size());
Expand All @@ -314,13 +297,13 @@ public void testFollowFromReference() {
@Test
public void testMultiReferences() {
MockTracer tracer = new MockTracer(MockTracer.Propagator.TEXT_MAP);
final MockSpan parent = tracer.buildSpan("parent").startManual();
final MockSpan precedent = tracer.buildSpan("precedent").startManual();
final MockSpan parent = tracer.buildSpan("parent").start();
final MockSpan precedent = tracer.buildSpan("precedent").start();

final MockSpan followingSpan = tracer.buildSpan("follows")
.addReference(References.FOLLOWS_FROM, precedent.context())
.asChildOf(parent.context())
.startManual();
.start();

assertEquals(parent.context().spanId(), followingSpan.parentId());
assertEquals(2, followingSpan.references().size());
Expand All @@ -335,15 +318,15 @@ public void testMultiReferences() {
@Test
public void testMultiReferencesBaggage() {
MockTracer tracer = new MockTracer(MockTracer.Propagator.TEXT_MAP);
final MockSpan parent = tracer.buildSpan("parent").startManual();
final MockSpan parent = tracer.buildSpan("parent").start();
parent.setBaggageItem("parent", "foo");
final MockSpan precedent = tracer.buildSpan("precedent").startManual();
final MockSpan precedent = tracer.buildSpan("precedent").start();
precedent.setBaggageItem("precedent", "bar");

final MockSpan followingSpan = tracer.buildSpan("follows")
.addReference(References.FOLLOWS_FROM, precedent.context())
.asChildOf(parent.context())
.startManual();
.start();

assertEquals("foo", followingSpan.getBaggageItem("parent"));
assertEquals("bar", followingSpan.getBaggageItem("precedent"));
Expand All @@ -352,11 +335,11 @@ public void testMultiReferencesBaggage() {
@Test
public void testNonStandardReference() {
MockTracer tracer = new MockTracer(MockTracer.Propagator.TEXT_MAP);
final MockSpan parent = tracer.buildSpan("parent").startManual();
final MockSpan parent = tracer.buildSpan("parent").start();

final MockSpan nextSpan = tracer.buildSpan("follows")
.addReference("a_reference", parent.context())
.startManual();
.start();

assertEquals(parent.context().spanId(), nextSpan.parentId());
assertEquals(1, nextSpan.references().size());
Expand Down Expand Up @@ -384,11 +367,10 @@ public void testDefaultConstructor() {
MockTracer mockTracer = new MockTracer();
Span span = mockTracer.buildSpan("foo").start();
Scope scope = mockTracer.activateSpan(span);
assertEquals(scope, mockTracer.scopeManager().active());
assertEquals(span, mockTracer.scopeManager().activeSpan());

Map<String, String> propag = new HashMap<>();
mockTracer.inject(scope.span().context(), Format.Builtin.TEXT_MAP, new TextMapAdapter(propag));
mockTracer.inject(span.context(), Format.Builtin.TEXT_MAP, new TextMapAdapter(propag));
assertFalse(propag.isEmpty());
}

Expand Down
2 changes: 1 addition & 1 deletion opentracing-noop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>io.opentracing</groupId>
<artifactId>parent</artifactId>
<version>0.32.1-SNAPSHOT</version>
<version>0.33.1-SNAPSHOT</version>
</parent>

<artifactId>opentracing-noop</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,12 @@ interface NoopScope extends Scope {
* A noop (i.e., cheap-as-possible) implementation of an ScopeManager.
*/
class NoopScopeManagerImpl implements NoopScopeManager {
@Override
public Scope activate(Span span, boolean finishOnClose) {
return NoopScope.INSTANCE;
}

@Override
public Scope activate(Span span) {
return NoopScope.INSTANCE;
}

@Override
public Scope active() {
return NoopScope.INSTANCE;
}

@Override
public Span activeSpan() {
return NoopSpan.INSTANCE;
Expand All @@ -52,10 +43,5 @@ public Span activeSpan() {
static class NoopScopeImpl implements NoopScopeManager.NoopScope {
@Override
public void close() {}

@Override
public Span span() {
return NoopSpan.INSTANCE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,8 @@ public Tracer.SpanBuilder withStartTimestamp(long microseconds) {
return this;
}

@Override
public Scope startActive(boolean finishOnClose) {
return NoopScopeManager.NoopScope.INSTANCE;
}

@Override
public Span start() {
return startManual();
}

@Override
public Span startManual() {
return NoopSpanImpl.INSTANCE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public class NoopScopeManagerTest {
@Test
public void activeValueToleratesUseTest() {
try{
final Scope active = NoopScopeManager.INSTANCE.active();
final Scope active = NoopScopeManager.INSTANCE.activate(NoopSpanImpl.INSTANCE);
assertNotNull(active);
active.close();
} catch (final NullPointerException e) {
fail("NoopScopeManagerImpl.active() should return a usable scope");
}
}
}
}
Loading

0 comments on commit 5ed6a47

Please sign in to comment.