Skip to content

Commit

Permalink
fix: cleaning up startSpan(spanName, parentContext) variant
Browse files Browse the repository at this point in the history
  • Loading branch information
jimit-j-shah committed Sep 18, 2024
1 parent 900cdef commit 451aeab
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ com.google.datastore.v1.BeginTransactionResponse beginTransaction(
final com.google.datastore.v1.BeginTransactionRequest requestPb) {
com.google.cloud.datastore.telemetry.TraceUtil.Span span =
otelTraceUtil.startSpan(
com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION,
otelTraceUtil.getCurrentContext());
com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION);
try (com.google.cloud.datastore.telemetry.TraceUtil.Scope scope = span.makeCurrent()) {
return RetryHelper.runWithRetries(
() -> datastoreRpc.beginTransaction(requestPb),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ public Span startSpan(String spanName) {
return new Span();
}

@Override
public TraceUtil.Span startSpan(String spanName, TraceUtil.Context parentContext) {
return new Span();
}

@Override
public TraceUtil.Span startSpan(String spanName, TraceUtil.Span parentSpan) {
return new Span();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,6 @@ public Span startSpan(String spanName) {
return new Span(span, spanName);
}

@Override
public TraceUtil.Span startSpan(String spanName, TraceUtil.Context parentContext) {
SpanBuilder spanBuilder =
tracer
.spanBuilder(spanName)
.setSpanKind(SpanKind.PRODUCER)
.setParent(((EnabledTraceUtil.Context) parentContext).context);
return new Span(addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(), spanName);
}

@Override
public TraceUtil.Span startSpan(String spanName, TraceUtil.Span parentSpan) {
SpanBuilder spanBuilder =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,9 @@ interface Scope extends AutoCloseable {
Span startSpan(String spanName);

/**
* Starts a new span with the given name and the span represented by the parentSpanContext as its
* parents, sets it as the current span and returns it.
* Starts a new span with the given name and the span represented by the parentSpan as its parent,
* sets it as the current span and returns it.
*/
Span startSpan(String spanName, Context parentContext);

Span startSpan(String spanName, Span parentSpan);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void usesDisabledSpan() {
assertThat(traceUtil.getCurrentSpan() instanceof DisabledTraceUtil.Span).isTrue();
assertThat(traceUtil.startSpan("foo") instanceof DisabledTraceUtil.Span).isTrue();
assertThat(
traceUtil.startSpan("foo", traceUtil.getCurrentContext())
traceUtil.startSpan("foo", traceUtil.getCurrentSpan())
instanceof DisabledTraceUtil.Span)
.isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ public void usesEnabledSpan() {
assertThat(traceUtil.getCurrentSpan() instanceof EnabledTraceUtil.Span).isTrue();
assertThat(traceUtil.startSpan("foo") != null).isTrue();
assertThat(
traceUtil.startSpan("foo", traceUtil.getCurrentContext())
instanceof EnabledTraceUtil.Span)
traceUtil.startSpan("foo", traceUtil.getCurrentSpan()) instanceof EnabledTraceUtil.Span)
.isTrue();
}

Expand Down

0 comments on commit 451aeab

Please sign in to comment.