Skip to content

Commit

Permalink
Add meaningful .toString to NoopLogRecordProcessor and `DefaultOp…
Browse files Browse the repository at this point in the history
…enTelemetry` (#5493)
  • Loading branch information
iRevive committed Jun 1, 2023
1 parent b14bed8 commit 0ab6915
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public MeterProvider getMeterProvider() {
public ContextPropagators getPropagators() {
return propagators;
}

@Override
public String toString() {
return "DefaultOpenTelemetry{" + "propagators=" + propagators + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ void getThenSet() {
.hasStackTraceContaining("getOpenTelemetry");
}

@Test
void toString_noop_Valid() {
assertThat(OpenTelemetry.noop().toString())
.isEqualTo(
"DefaultOpenTelemetry{"
+ "propagators=DefaultContextPropagators{textMapPropagator=NoopTextMapPropagator}"
+ "}");
}

private static void setOpenTelemetry() {
GlobalOpenTelemetry.set(OpenTelemetry.noop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ private NoopLogRecordProcessor() {}

@Override
public void onEmit(Context context, ReadWriteLogRecord logRecord) {}

@Override
public String toString() {
return "NoopLogRecordProcessor";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ void noCrash() {
assertThat(logRecordProcessor.forceFlush().isSuccess()).isEqualTo(true);
assertThat(logRecordProcessor.shutdown().isSuccess()).isEqualTo(true);
}

@Test
void toString_Valid() {
assertThat(NoopLogRecordProcessor.getInstance().toString()).isEqualTo("NoopLogRecordProcessor");
}
}

0 comments on commit 0ab6915

Please sign in to comment.