Skip to content

Commit

Permalink
Update google java format to 1.9 (#1854)
Browse files Browse the repository at this point in the history
* Update google java format to 1.9

* Spotless

* Update Contributing.md
  • Loading branch information
Anuraag Agrawal authored Oct 23, 2020
1 parent 5e31e99 commit 23444d6
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Make sure to review the projects [license](LICENSE) and sign the
[CNCF CLA](https://identity.linuxfoundation.org/projects/cncf). A signed CLA will be enforced by an
automatic check once you submit a PR, but you can also sign it after opening your PR.

## Requirements

Java 11 or higher is required to build the projects in this repository. The built artifacts can be
used on Java 8 or higher.

## Checks

Before submitting a PR, you should make sure the style checks and unit tests pass. You can run these
Expand Down
4 changes: 1 addition & 3 deletions api/src/main/java/io/opentelemetry/OpenTelemetry.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ static void setGlobalPropagators(ContextPropagators propagators) {
requireNonNull(propagators, "propagators");
DefaultOpenTelemetry.setGlobalOpenTelemetry(
((DefaultOpenTelemetry) DefaultOpenTelemetry.getGlobalOpenTelemetry())
.toBuilder()
.setPropagators(propagators)
.build());
.toBuilder().setPropagators(propagators).build());
}

/** Returns the {@link TracerProvider} for this {@link OpenTelemetry}. */
Expand Down
9 changes: 3 additions & 6 deletions api/src/test/java/io/opentelemetry/trace/TraceStateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ void updateEntry() {
@Test
void addAndUpdateEntry() {
assertThat(
firstTraceState
.toBuilder()
firstTraceState.toBuilder()
.set(FIRST_KEY, SECOND_VALUE) // update the existing entry
.set(SECOND_KEY, FIRST_VALUE) // add a new entry
.build()
Expand All @@ -229,8 +228,7 @@ void addAndUpdateEntry() {
@Test
void addSameKey() {
assertThat(
EMPTY
.toBuilder()
EMPTY.toBuilder()
.set(FIRST_KEY, SECOND_VALUE) // update the existing entry
.set(FIRST_KEY, FIRST_VALUE) // add a new entry
.build()
Expand All @@ -247,8 +245,7 @@ void remove() {
@Test
void addAndRemoveEntry() {
assertThat(
EMPTY
.toBuilder()
EMPTY.toBuilder()
.set(FIRST_KEY, SECOND_VALUE) // update the existing entry
.remove(FIRST_KEY) // add a new entry
.build())
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ configure(opentelemetryProjects) {

spotless {
java {
googleJavaFormat("1.7")
googleJavaFormat("1.9")
licenseHeaderFile rootProject.file('buildscripts/spotless.license.java'), '(package|import|class|// Includes work from:)'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ void generateSpan_WithAttributes() {

assertThat(ZipkinSpanExporter.generateSpan(data, localEndpoint))
.isEqualTo(
buildZipkinSpan(Span.Kind.CLIENT)
.toBuilder()
buildZipkinSpan(Span.Kind.CLIENT).toBuilder()
.putTag("string", "string value")
.putTag("boolean", "false")
.putTag("long", "9999")
Expand All @@ -181,8 +180,7 @@ void generateSpan_WithInstrumentationLibraryInfo() {

assertThat(ZipkinSpanExporter.generateSpan(data, localEndpoint))
.isEqualTo(
buildZipkinSpan(Span.Kind.CLIENT)
.toBuilder()
buildZipkinSpan(Span.Kind.CLIENT).toBuilder()
.putTag("otel.library.name", "io.opentelemetry.auto")
.putTag("otel.library.version", "1.0.0")
.build());
Expand All @@ -202,8 +200,7 @@ void generateSpan_AlreadyHasHttpStatusInfo() {

assertThat(ZipkinSpanExporter.generateSpan(data, localEndpoint))
.isEqualTo(
buildZipkinSpan(Span.Kind.CLIENT)
.toBuilder()
buildZipkinSpan(Span.Kind.CLIENT).toBuilder()
.clearTags()
.putTag(SemanticAttributes.HTTP_STATUS_CODE.getKey(), "404")
.putTag("error", "A user provided error")
Expand All @@ -224,8 +221,7 @@ void generateSpan_WithRpcErrorStatus() {

assertThat(ZipkinSpanExporter.generateSpan(data, localEndpoint))
.isEqualTo(
buildZipkinSpan(Span.Kind.SERVER)
.toBuilder()
buildZipkinSpan(Span.Kind.SERVER).toBuilder()
.putTag(ZipkinSpanExporter.OTEL_STATUS_DESCRIPTION, errorMessage)
.putTag(SemanticAttributes.RPC_SERVICE.getKey(), "my service name")
.putTag(ZipkinSpanExporter.OTEL_STATUS_CODE, "ERROR")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ public class SpanAttributeTruncateBenchmark {
@Setup(Level.Trial)
public final void setup() {
TraceConfig config =
OpenTelemetrySdk.getTracerManagement()
.getActiveTraceConfig()
.toBuilder()
OpenTelemetrySdk.getTracerManagement().getActiveTraceConfig().toBuilder()
.setMaxLengthOfAttributeValues(maxLength)
.build();
OpenTelemetrySdk.getTracerManagement().updateActiveTraceConfig(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,7 @@ void addEvent() {
void droppingAttributes() {
final int maxNumberOfAttributes = 8;
TraceConfig traceConfig =
TraceConfig.getDefault()
.toBuilder()
TraceConfig.getDefault().toBuilder()
.setMaxNumberOfAttributes(maxNumberOfAttributes)
.build();
RecordEventsReadableSpan span = createTestSpan(traceConfig);
Expand All @@ -516,8 +515,7 @@ void droppingAttributes() {
void droppingAndAddingAttributes() {
final int maxNumberOfAttributes = 8;
TraceConfig traceConfig =
TraceConfig.getDefault()
.toBuilder()
TraceConfig.getDefault().toBuilder()
.setMaxNumberOfAttributes(maxNumberOfAttributes)
.build();
RecordEventsReadableSpan span = createTestSpan(traceConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ void addLink() {
void truncateLink() {
final int maxNumberOfLinks = 8;
TraceConfig traceConfig =
tracerSdkFactory
.getActiveTraceConfig()
.toBuilder()
tracerSdkFactory.getActiveTraceConfig().toBuilder()
.setMaxNumberOfLinks(maxNumberOfLinks)
.build();
tracerSdkFactory.updateActiveTraceConfig(traceConfig);
Expand All @@ -124,9 +122,7 @@ void truncateLink() {
@Test
void truncateLinkAttributes() {
TraceConfig traceConfig =
tracerSdkFactory
.getActiveTraceConfig()
.toBuilder()
tracerSdkFactory.getActiveTraceConfig().toBuilder()
.setMaxNumberOfAttributesPerLink(1)
.build();
tracerSdkFactory.updateActiveTraceConfig(traceConfig);
Expand Down Expand Up @@ -353,9 +349,7 @@ void setAttribute_nullAttributeValue_afterEnd() {
void droppingAttributes() {
final int maxNumberOfAttrs = 8;
TraceConfig traceConfig =
tracerSdkFactory
.getActiveTraceConfig()
.toBuilder()
tracerSdkFactory.getActiveTraceConfig().toBuilder()
.setMaxNumberOfAttributes(maxNumberOfAttrs)
.build();
tracerSdkFactory.updateActiveTraceConfig(traceConfig);
Expand All @@ -379,9 +373,7 @@ void droppingAttributes() {
@Test
public void tooLargeAttributeValuesAreTruncated() {
TraceConfig traceConfig =
tracerSdkFactory
.getActiveTraceConfig()
.toBuilder()
tracerSdkFactory.getActiveTraceConfig().toBuilder()
.setMaxLengthOfAttributeValues(10)
.build();
tracerSdkFactory.updateActiveTraceConfig(traceConfig);
Expand Down Expand Up @@ -430,9 +422,7 @@ public void tooLargeAttributeValuesAreTruncated() {
@Test
void addAttributes_OnlyViaSampler() {
TraceConfig traceConfig =
tracerSdkFactory
.getActiveTraceConfig()
.toBuilder()
tracerSdkFactory.getActiveTraceConfig().toBuilder()
.setSampler(Samplers.traceIdRatioBased(1))
.build();
tracerSdkFactory.updateActiveTraceConfig(traceConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ void updateTraceConfig_SystemProperties() {
System.setProperty("otel.config.max.event.attrs", "7");
System.setProperty("otel.config.max.link.attrs", "11");
TraceConfig traceConfig =
TraceConfig.getDefault()
.toBuilder()
TraceConfig.getDefault().toBuilder()
.readEnvironmentVariables()
.readSystemProperties()
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ void updateTraceConfig_OnTraceIdRatioBased() {
@Test
void updateTraceConfig_All() {
TraceConfig traceConfig =
TraceConfig.getDefault()
.toBuilder()
TraceConfig.getDefault().toBuilder()
.setSampler(Samplers.alwaysOff())
.setMaxNumberOfAttributes(8)
.setMaxNumberOfEvents(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public static ByteString toProtoTraceId(String traceId) {
*/
public static TraceConfig traceConfigFromProto(
io.opentelemetry.proto.trace.v1.TraceConfig traceConfigProto) {
return TraceConfig.getDefault()
.toBuilder()
return TraceConfig.getDefault().toBuilder()
.setSampler(fromProtoSampler(traceConfigProto))
.setMaxNumberOfAttributes((int) traceConfigProto.getMaxNumberOfAttributes())
.setMaxNumberOfEvents((int) traceConfigProto.getMaxNumberOfTimedEvents())
Expand Down

0 comments on commit 23444d6

Please sign in to comment.