Skip to content

Commit

Permalink
all: retrofit and update to OpenCensus v0.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Sep 3, 2019
1 parent 5cca3af commit 67b4ec7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
}
}

def opencensusVersion = '0.21.0'
def opencensusVersion = '0.24.0'
def errorProneVersion = '2.3.1'
def findBugsJsr305Version = '3.0.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package io.opencensus.integration.jdbc;
package io.orijtech.integrations.ocjdbc;

import io.opencensus.integration.jdbc.Observability.TraceOption;
import io.orijtech.integrations.ocjdbc.Observability.TraceOption;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import io.opencensus.tags.TagContext;
import io.opencensus.tags.TagContextBuilder;
import io.opencensus.tags.TagKey;
import io.opencensus.tags.TagMetadata;
import io.opencensus.tags.TagValue;
import io.opencensus.tags.Tagger;
import io.opencensus.trace.AttributeValue;
import io.opencensus.trace.BlankSpan;
import io.opencensus.trace.Span;
import io.opencensus.trace.SpanBuilder;
import io.opencensus.trace.Status;
Expand Down Expand Up @@ -68,7 +70,9 @@ public void setUp() {
MockitoAnnotations.initMocks(this);
Mockito.doNothing().when(mockViewManager).registerView(any(View.class));
Mockito.when(mockTagger.currentBuilder()).thenReturn(mockTagContextBuilder);
Mockito.when(mockTagContextBuilder.put(any(TagKey.class), any(TagValue.class)))
Mockito.when(
mockTagContextBuilder.put(
any(TagKey.class), any(TagValue.class), any(TagMetadata.class)))
.thenReturn(mockTagContextBuilder);
Mockito.when(mockTagContextBuilder.build()).thenReturn(mockTagContext);
Mockito.when(mockStatsRecorder.newMeasureMap()).thenReturn(mockMeasureMap);
Expand Down Expand Up @@ -148,7 +152,8 @@ public void trackingOperation_withSpan() {
TrackingOperation trackingOperation =
new TrackingOperation("method", "update", mockStatsRecorder, mockTagger, mockTracer);
trackingOperation.withSpan();
Mockito.verify(mockTracer, Mockito.times(1)).spanBuilderWithExplicitParent("method", null);
Mockito.verify(mockTracer, Mockito.times(1))
.spanBuilderWithExplicitParent("method", BlankSpan.INSTANCE);
Mockito.verify(mockSpanBuilder, Mockito.times(1)).startSpan();
Mockito.verify(mockSpan, Mockito.times(1))
.putAttribute("sql", AttributeValue.stringAttributeValue("update"));
Expand All @@ -161,9 +166,15 @@ public void trackingOperation_end() {
trackingOperation.end();
Mockito.verify(mockTagger, Mockito.times(1)).currentBuilder();
Mockito.verify(mockTagContextBuilder, Mockito.times(1))
.put(eq(Observability.JAVA_SQL_METHOD), eq(TagValue.create("method")));
.put(
eq(Observability.JAVA_SQL_METHOD),
eq(TagValue.create("method")),
eq(Observability.TAG_METADATA_TTL_UNLIMITED));
Mockito.verify(mockTagContextBuilder, Mockito.times(1))
.put(eq(Observability.JAVA_SQL_STATUS), eq(Observability.VALUE_OK));
.put(
eq(Observability.JAVA_SQL_STATUS),
eq(Observability.VALUE_OK),
eq(Observability.TAG_METADATA_TTL_UNLIMITED));
Mockito.verify(mockStatsRecorder, Mockito.times(1)).newMeasureMap();
Mockito.verify(mockMeasureMap, Mockito.times(1))
.put(eq(Observability.MEASURE_LATENCY_MS), anyDouble());
Expand All @@ -180,11 +191,20 @@ public void trackingOperation_end_recordException() {
trackingOperation.end();
Mockito.verify(mockTagger, Mockito.times(1)).currentBuilder();
Mockito.verify(mockTagContextBuilder, Mockito.times(1))
.put(eq(Observability.JAVA_SQL_METHOD), eq(TagValue.create("method")));
.put(
eq(Observability.JAVA_SQL_METHOD),
eq(TagValue.create("method")),
eq(Observability.TAG_METADATA_TTL_UNLIMITED));
Mockito.verify(mockTagContextBuilder, Mockito.times(1))
.put(eq(Observability.JAVA_SQL_ERROR), eq(TagValue.create(exception.toString())));
.put(
eq(Observability.JAVA_SQL_ERROR),
eq(TagValue.create(exception.toString())),
eq(Observability.TAG_METADATA_TTL_UNLIMITED));
Mockito.verify(mockTagContextBuilder, Mockito.times(1))
.put(eq(Observability.JAVA_SQL_STATUS), eq(Observability.VALUE_ERROR));
.put(
eq(Observability.JAVA_SQL_STATUS),
eq(Observability.VALUE_ERROR),
eq(Observability.TAG_METADATA_TTL_UNLIMITED));
Mockito.verify(mockSpan, Mockito.times(1))
.setStatus(eq(Status.UNKNOWN.withDescription(exception.toString())));
Mockito.verify(mockStatsRecorder, Mockito.times(1)).newMeasureMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package io.opencensus.integration.jdbc;
package io.orijtech.integrations.ocjdbc;

import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import io.opencensus.integration.jdbc.Observability.TraceOption;
import io.orijtech.integrations.ocjdbc.Observability.TraceOption;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.EnumSet;
Expand Down

0 comments on commit 67b4ec7

Please sign in to comment.