Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename newBuilder to builder for consistency. #1790

Merged
merged 1 commit into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ TracerSdkManagement tracerSdkManagement = OpenTelemetrySdk.getTracerManagement()

// Set to export the traces to a logging stream
tracerSdkManagement.addSpanProcessor(
SimpleSpanProcessor.newBuilder(
SimpleSpanProcessor.builder(
new LoggingSpanExporter()
).build());
```
Expand Down Expand Up @@ -360,14 +360,14 @@ in bulk. Multiple Span processors can be configured to be active at the same tim

```java
tracerSdkManagement.addSpanProcessor(
SimpleSpanProcessor.newBuilder(new LoggingSpanExporter()).build()
SimpleSpanProcessor.builder(new LoggingSpanExporter()).build()
);
tracerSdkManagement.addSpanProcessor(
BatchSpanProcessor.newBuilder(new LoggingSpanExporter()).build()
BatchSpanProcessor.builder(new LoggingSpanExporter()).build()
);
tracerSdkManagement.addSpanProcessor(MultiSpanProcessor.create(Arrays.asList(
SimpleSpanProcessor.newBuilder(new LoggingSpanExporter()).build(),
BatchSpanProcessor.newBuilder(new LoggingSpanExporter()).build()
SimpleSpanProcessor.builder(new LoggingSpanExporter()).build(),
BatchSpanProcessor.builder(new LoggingSpanExporter()).build()
)));
```

Expand All @@ -385,16 +385,16 @@ Other exporters can be found in the [OpenTelemetry Registry].

```java
tracerSdkManagement.addSpanProcessor(
SimpleSpanProcessor.newBuilder(InMemorySpanExporter.create()).build());
SimpleSpanProcessor.builder(InMemorySpanExporter.create()).build());
tracerSdkManagement.addSpanProcessor(
SimpleSpanProcessor.newBuilder(new LoggingSpanExporter()).build());
SimpleSpanProcessor.builder(new LoggingSpanExporter()).build());

ManagedChannel jaegerChannel =
ManagedChannelBuilder.forAddress([ip:String], [port:int]).usePlaintext().build();
JaegerGrpcSpanExporter jaegerExporter = JaegerGrpcSpanExporter.newBuilder()
JaegerGrpcSpanExporter jaegerExporter = JaegerGrpcSpanExporter.builder()
.setServiceName("example").setChannel(jaegerChannel).setDeadline(30000)
.build();
tracerSdkManagement.addSpanProcessor(BatchSpanProcessor.newBuilder(
tracerSdkManagement.addSpanProcessor(BatchSpanProcessor.builder(
jaegerExporter
).build());
```
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/io/opentelemetry/common/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Immutable
public abstract class Attributes extends ImmutableKeyValuePairs<AttributeKey, Object>
implements ReadableAttributes {
private static final Attributes EMPTY = Attributes.newBuilder().build();
private static final Attributes EMPTY = Attributes.builder().build();

@AutoValue
@Immutable
Expand Down Expand Up @@ -179,12 +179,12 @@ private static Attributes sortAndFilterToAttributes(Object... data) {
}

/** Returns a new {@link Builder} instance for creating arbitrary {@link Attributes}. */
public static Builder newBuilder() {
public static Builder builder() {
return new Builder();
}

/** Returns a new {@link Builder} instance from ReadableAttributes. */
public static Builder newBuilder(ReadableAttributes attributes) {
public static Builder builder(ReadableAttributes attributes) {
final Builder builder = new Builder();
attributes.forEach(builder::setAttribute);
return builder;
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/io/opentelemetry/common/Labels.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Immutable
public abstract class Labels extends ImmutableKeyValuePairs<String, String> {

private static final Labels EMPTY = Labels.newBuilder().build();
private static final Labels EMPTY = Labels.builder().build();

public abstract void forEach(LabelConsumer consumer);

Expand Down Expand Up @@ -117,7 +117,7 @@ public Builder toBuilder() {
}

/** Creates a new {@link Builder} instance for creating arbitrary {@link Labels}. */
public static Builder newBuilder() {
public static Builder builder() {
return new Builder();
}

Expand Down
16 changes: 8 additions & 8 deletions api/src/test/java/io/opentelemetry/common/AttributesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void forEach_singleAttribute() {

@Test
void builder_nullKey() {
Attributes attributes = Attributes.newBuilder().setAttribute(stringKey(null), "value").build();
Attributes attributes = Attributes.builder().setAttribute(stringKey(null), "value").build();
assertThat(attributes).isEqualTo(Attributes.empty());
}

Expand Down Expand Up @@ -125,7 +125,7 @@ void emptyAndNullKey() {
@Test
void builder() {
Attributes attributes =
Attributes.newBuilder()
Attributes.builder()
.setAttribute("string", "value1")
.setAttribute("long", 100)
.setAttribute(longKey("long2"), 10)
Expand All @@ -148,7 +148,7 @@ void builder() {
false);
assertThat(attributes).isEqualTo(wantAttributes);

Attributes.Builder newAttributes = Attributes.newBuilder(attributes);
Attributes.Builder newAttributes = Attributes.builder(attributes);
newAttributes.setAttribute("newKey", "newValue");
assertThat(newAttributes.build())
.isEqualTo(
Expand All @@ -172,7 +172,7 @@ void builder() {
@Test
void builder_arrayTypes() {
Attributes attributes =
Attributes.newBuilder()
Attributes.builder()
.setAttribute("string", "value1", "value2")
.setAttribute("long", 100L, 200L)
.setAttribute("double", 33.44, -44.33)
Expand Down Expand Up @@ -230,7 +230,7 @@ void get() {
@Test
void toBuilder() {
Attributes filled =
Attributes.newBuilder().setAttribute("cat", "meow").setAttribute("dog", "bark").build();
Attributes.builder().setAttribute("cat", "meow").setAttribute("dog", "bark").build();

Attributes fromEmpty =
Attributes.empty()
Expand All @@ -242,16 +242,16 @@ void toBuilder() {
// Original not mutated.
assertThat(Attributes.empty().isEmpty()).isTrue();

Attributes partial = Attributes.newBuilder().setAttribute("cat", "meow").build();
Attributes partial = Attributes.builder().setAttribute("cat", "meow").build();
Attributes fromPartial = partial.toBuilder().setAttribute("dog", "bark").build();
assertThat(fromPartial).isEqualTo(filled);
// Original not mutated.
assertThat(partial).isEqualTo(Attributes.newBuilder().setAttribute("cat", "meow").build());
assertThat(partial).isEqualTo(Attributes.builder().setAttribute("cat", "meow").build());
}

@Test
void nullsAreNoOps() {
Attributes.Builder builder = Attributes.newBuilder();
Attributes.Builder builder = Attributes.builder();
builder.setAttribute(stringKey("attrValue"), "attrValue");
builder.setAttribute("string", "string");
builder.setAttribute("long", 10);
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/java/io/opentelemetry/common/LabelsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void fourLabels() {
@Test
void builder() {
Labels labels =
Labels.newBuilder()
Labels.builder()
.setLabel("key1", "duplicateShouldBeIgnored")
.setLabel("key1", "value1")
.setLabel("key2", "value2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* {@literal @}Before
* public void setup() {
* tracer.addSpanProcessor(SimpleSampledSpansProcessor.newBuilder(testExporter).build());
* tracer.addSpanProcessor(SimpleSampledSpansProcessor.builder(testExporter).build());
* }
*
* {@literal @}Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public final InMemoryTracing build() {
.addTextMapPropagator(HttpTraceContext.getInstance())
.build());
InMemorySpanExporter exporter = InMemorySpanExporter.create();
getTracerSdkManagement().addSpanProcessor(SimpleSpanProcessor.newBuilder(exporter).build());
getTracerSdkManagement().addSpanProcessor(SimpleSpanProcessor.builder(exporter).build());
return setSpanExporter(exporter).autoBuild();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InMemorySpanExporterTest {

@BeforeEach
void setup() {
tracerSdkProvider.addSpanProcessor(SimpleSpanProcessor.newBuilder(exporter).build());
tracerSdkProvider.addSpanProcessor(SimpleSpanProcessor.builder(exporter).build());
}

@Test
Expand Down Expand Up @@ -87,7 +87,7 @@ void export_ReturnCode() {
}

static SpanData makeBasicSpan() {
return TestSpanData.newBuilder()
return TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TraceId.getInvalid())
.setSpanId(SpanId.getInvalid())
Expand Down
6 changes: 3 additions & 3 deletions exporters/jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spans will be sent to a Jaeger gRPC endpoint running on `localhost`:

```java
JaegerGrpcSpanExporter exporter =
JaegerGrpcSpanExporter.newBuilder()
JaegerGrpcSpanExporter.builder()
.setEndpoint("localhost:14250")
.setServiceName("my-service")
.build();
Expand All @@ -24,15 +24,15 @@ Service name and Endpoint can be also configured via environment variables or sy
```java
// Using environment variables
JaegerGrpcSpanExporter exporter =
JaegerGrpcSpanExporter.newBuilder()
JaegerGrpcSpanExporter.builder()
.readEnvironmentVariables()
.build()
```

```java
// Using system properties
JaegerGrpcSpanExporter exporter =
JaegerGrpcSpanExporter.newBuilder()
JaegerGrpcSpanExporter.builder()
.readSystemProperties()
.build()
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public CompletableResultCode flush() {
*
* @return a new builder instance for this exporter.
*/
public static Builder newBuilder() {
public static Builder builder() {
return new Builder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void testStatusNotUnset() {
long startMs = System.currentTimeMillis();
long endMs = startMs + 900;
SpanData span =
TestSpanData.newBuilder()
TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TRACE_ID)
.setSpanId(SPAN_ID)
Expand All @@ -237,7 +237,7 @@ void testSpanError() {
long startMs = System.currentTimeMillis();
long endMs = startMs + 900;
SpanData span =
TestSpanData.newBuilder()
TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TRACE_ID)
.setSpanId(SPAN_ID)
Expand Down Expand Up @@ -271,7 +271,7 @@ private static SpanData getSpanData(long startMs, long endMs) {

Link link = Link.create(createSpanContext(LINK_TRACE_ID, LINK_SPAN_ID), attributes);

return TestSpanData.newBuilder()
return TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TRACE_ID)
.setSpanId(SPAN_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void testExport() throws Exception {
long startMs = System.currentTimeMillis();
long endMs = startMs + duration;
SpanData span =
TestSpanData.newBuilder()
TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TRACE_ID)
.setSpanId(SPAN_ID)
Expand All @@ -97,7 +97,7 @@ void testExport() throws Exception {

// test
JaegerGrpcSpanExporter exporter =
JaegerGrpcSpanExporter.newBuilder().setServiceName("test").setChannel(channel).build();
JaegerGrpcSpanExporter.builder().setServiceName("test").setChannel(channel).build();
exporter.export(Collections.singletonList(span));

// verify
Expand Down Expand Up @@ -158,7 +158,7 @@ void configTest() {
String endpoint = "127.0.0.1:9090";
options.put("otel.exporter.jaeger.service.name", serviceName);
options.put("otel.exporter.jaeger.endpoint", endpoint);
JaegerGrpcSpanExporter.Builder config = JaegerGrpcSpanExporter.newBuilder();
JaegerGrpcSpanExporter.Builder config = JaegerGrpcSpanExporter.builder();
JaegerGrpcSpanExporter.Builder spy = Mockito.spy(config);
spy.fromConfigMap(options, ConfigBuilderTest.getNaming()).build();
Mockito.verify(spy).setServiceName(serviceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ private static void setupJaegerExporter() {
.usePlaintext()
.build();
SpanExporter jaegerExporter =
JaegerGrpcSpanExporter.newBuilder()
JaegerGrpcSpanExporter.builder()
.setServiceName(SERVICE_NAME)
.setChannel(jaegerChannel)
.setDeadlineMs(30000)
.build();
OpenTelemetrySdk.getTracerManagement()
.addSpanProcessor(SimpleSpanProcessor.newBuilder(jaegerExporter).build());
.addSpanProcessor(SimpleSpanProcessor.builder(jaegerExporter).build());
}

private void imitateWork() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void tearDown() {
void returnCode() {
long epochNanos = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
SpanData spanData =
TestSpanData.newBuilder()
TestSpanData.builder()
.setHasEnded(true)
.setTraceId(TraceId.fromLongs(1234L, 6789L))
.setSpanId(SpanId.fromLong(9876L))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public CompletableResultCode flush() {
*
* @return a new builder instance for this exporter.
*/
public static Builder newBuilder() {
public static Builder builder() {
return new Builder();
}

Expand All @@ -155,7 +155,7 @@ public static Builder newBuilder() {
* @since 0.5.0
*/
public static OtlpGrpcMetricExporter getDefault() {
return newBuilder().readEnvironmentVariables().readSystemProperties().build();
return builder().readEnvironmentVariables().readSystemProperties().build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public CompletableResultCode flush() {
*
* @return a new builder instance for this exporter.
*/
public static Builder newBuilder() {
public static Builder builder() {
return new Builder();
}

Expand All @@ -157,7 +157,7 @@ public static Builder newBuilder() {
* @since 0.5.0
*/
public static OtlpGrpcSpanExporter getDefault() {
return newBuilder().readEnvironmentVariables().readSystemProperties().build();
return builder().readEnvironmentVariables().readSystemProperties().build();
}

/**
Expand Down
Loading