Skip to content

Commit 233f429

Browse files
committed
fix: remove unnecessary overload
1 parent c7ea2e9 commit 233f429

3 files changed

Lines changed: 11 additions & 24 deletions

File tree

gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracerFactory.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,15 @@ enum OperationType {
6262
*/
6363
ApiTracer newTracer(ApiTracer parent, SpanName spanName, OperationType operationType);
6464

65-
/**
66-
* Create a new {@link ApiTracer} that will be a child of the current context.
67-
*
68-
* @param parent the parent of this tracer
69-
* @param tracerContext the method-definition-specific tracer context
70-
* @param operationType the type of operation that the tracer will trace
71-
*/
72-
default ApiTracer newTracer(
73-
ApiTracer parent, ApiTracerContext tracerContext, OperationType operationType) {
74-
SpanName spanName = SpanName.of(tracerContext);
75-
return newTracer(parent, spanName, operationType);
76-
}
77-
7865
/**
7966
* Create a new {@link ApiTracer} that will be a child of the current context.
8067
*
8168
* @param parent the parent of this tracer
8269
* @param tracerContext the method-definition-specific tracer context
8370
*/
8471
default ApiTracer newTracer(ApiTracer parent, ApiTracerContext tracerContext) {
85-
return newTracer(parent, tracerContext, tracerContext.operationType());
72+
SpanName spanName = SpanName.of(tracerContext);
73+
return newTracer(parent, spanName, tracerContext.operationType());
8674
}
8775

8876
/**

gax-java/gax/src/main/java/com/google/api/gax/tracing/SpanTracerFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public ApiTracer newTracer(ApiTracer parent, SpanName spanName, OperationType op
7777

7878
@Override
7979
public ApiTracer newTracer(
80-
ApiTracer parent, ApiTracerContext apiTracerContext, OperationType operationType) {
80+
ApiTracer parent, ApiTracerContext apiTracerContext) {
8181
ApiTracerContext context = this.apiTracerContext.merge(apiTracerContext);
8282

8383
String attemptSpanName;
@@ -90,8 +90,7 @@ public ApiTracer newTracer(
9090
attemptSpanName = context.fullMethodName() + "/attempt";
9191
}
9292

93-
SpanTracer spanTracer = new SpanTracer(traceManager, context, attemptSpanName);
94-
return spanTracer;
93+
return new SpanTracer(traceManager, context, attemptSpanName);
9594
}
9695

9796
@Override

gax-java/gax/src/test/java/com/google/api/gax/tracing/SpanTracerFactoryTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void testNewTracer_createsSpanTracer(boolean useContext) {
7272
.setTransport(Transport.GRPC)
7373
.setLibraryMetadata(LibraryMetadata.empty())
7474
.build();
75-
tracer = factory.newTracer(null, context, OperationType.Unary);
75+
tracer = factory.newTracer(null, context);
7676
} else {
7777
tracer = factory.newTracer(null, SpanName.of("service", "method"), OperationType.Unary);
7878
}
@@ -97,7 +97,7 @@ void testNewTracer_addsAttributes(boolean useContext) {
9797
.setTransport(Transport.GRPC)
9898
.setLibraryMetadata(LibraryMetadata.empty())
9999
.build();
100-
tracer = factory.newTracer(null, context, OperationType.Unary);
100+
tracer = factory.newTracer(null, context);
101101
} else {
102102
tracer = factory.newTracer(null, SpanName.of("service", "method"), OperationType.Unary);
103103
}
@@ -131,7 +131,7 @@ void testWithContext_addsInferredAttributes(boolean useContext) {
131131
.setTransport(Transport.GRPC)
132132
.setLibraryMetadata(LibraryMetadata.empty())
133133
.build();
134-
tracer = factoryWithContext.newTracer(null, callContext, OperationType.Unary);
134+
tracer = factoryWithContext.newTracer(null, callContext);
135135
} else {
136136
tracer =
137137
factoryWithContext.newTracer(null, SpanName.of("service", "method"), OperationType.Unary);
@@ -163,7 +163,7 @@ void testWithContext_noEndpointContext_doesNotAddServerAddressAttribute(boolean
163163
.setTransport(Transport.GRPC)
164164
.setLibraryMetadata(LibraryMetadata.empty())
165165
.build();
166-
tracer = factoryWithContext.newTracer(null, callContext, OperationType.Unary);
166+
tracer = factoryWithContext.newTracer(null, callContext);
167167
} else {
168168
tracer =
169169
factoryWithContext.newTracer(null, SpanName.of("service", "method"), OperationType.Unary);
@@ -189,7 +189,7 @@ void testNewTracer_withContext_grpc_usesFullMethodName() {
189189
.build();
190190

191191
SpanTracerFactory factory = new SpanTracerFactory(traceManager);
192-
ApiTracer tracer = factory.newTracer(null, context, OperationType.Unary);
192+
ApiTracer tracer = factory.newTracer(null, context);
193193

194194
tracer.attemptStarted(null, 1);
195195

@@ -206,7 +206,7 @@ void testNewTracer_withContext_http_usesPlaceholder() {
206206
.build();
207207

208208
SpanTracerFactory factory = new SpanTracerFactory(traceManager);
209-
ApiTracer tracer = factory.newTracer(null, context, OperationType.Unary);
209+
ApiTracer tracer = factory.newTracer(null, context);
210210

211211
tracer.attemptStarted(null, 1);
212212

@@ -240,7 +240,7 @@ void testNewTracer_mergesFactoryContext() {
240240
.setLibraryMetadata(LibraryMetadata.empty())
241241
.build();
242242

243-
ApiTracer tracer = factory.newTracer(null, callContext, OperationType.Unary);
243+
ApiTracer tracer = factory.newTracer(null, callContext);
244244
tracer.attemptStarted(null, 1);
245245

246246
ArgumentCaptor<Map<String, Object>> attributesCaptor = ArgumentCaptor.forClass(Map.class);

0 commit comments

Comments
 (0)