use of io.opentelemetry.sdk.logs.data.Severity in project opentelemetry-java by open-telemetry.
the class SdkLogBuilderTest method buildAndEmit.
@Test
// test deprecated setName method
@SuppressWarnings("deprecation")
void buildAndEmit() {
Instant now = Instant.now();
String name = "skippy";
String bodyStr = "body";
String sevText = "sevText";
Severity severity = Severity.DEBUG3;
Attributes attrs = Attributes.empty();
AtomicReference<LogData> seenLog = new AtomicReference<>();
LogProcessor logProcessor = seenLog::set;
LogEmitterSharedState state = mock(LogEmitterSharedState.class);
LogDataBuilder delegate = mock(LogDataBuilder.class);
LogData logData = mock(LogData.class);
Context context = mock(Context.class);
when(state.getLogLimits()).thenReturn(LogLimits.getDefault());
when(state.getLogProcessor()).thenReturn(logProcessor);
when(delegate.build()).thenReturn(logData);
SdkLogBuilder builder = new SdkLogBuilder(state, delegate);
builder.setBody(bodyStr);
verify(delegate).setBody(bodyStr);
builder.setEpoch(123, TimeUnit.SECONDS);
verify(delegate).setEpoch(123, TimeUnit.SECONDS);
builder.setEpoch(now);
verify(delegate).setEpoch(now);
builder.setAttributes(attrs);
verify(delegate).setAttributes(attrs);
builder.setContext(context);
verify(delegate).setContext(context);
builder.setName(name);
verify(delegate).setName(name);
builder.setSeverity(severity);
verify(delegate).setSeverity(severity);
builder.setSeverityText(sevText);
verify(delegate).setSeverityText(sevText);
builder.emit();
assertThat(seenLog.get()).isSameAs(logData);
}
Aggregations