use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method resourceFromConfig_empty.
@Test
void resourceFromConfig_empty() {
Attributes attributes = ResourceConfiguration.getAttributes(DefaultConfigProperties.createForTest(emptyMap()));
assertThat(attributes).isEmpty();
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method resourceFromConfig_overrideServiceName.
@Test
void resourceFromConfig_overrideServiceName() {
Attributes attributes = ResourceConfiguration.getAttributes(DefaultConfigProperties.createForTest(ImmutableMap.of(ResourceConfiguration.ATTRIBUTE_PROPERTY, "service.name=myService,appName=MyApp", ResourceConfiguration.SERVICE_NAME_PROPERTY, "ReallyMyService")));
assertThat(attributes).hasSize(2).containsEntry(ResourceAttributes.SERVICE_NAME, "ReallyMyService").containsEntry("appName", "MyApp");
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class ResourceConfigurationTest method resourceFromConfig_emptyEnvVar.
@Test
void resourceFromConfig_emptyEnvVar() {
Attributes attributes = ResourceConfiguration.getAttributes(DefaultConfigProperties.createForTest(singletonMap(ResourceConfiguration.ATTRIBUTE_PROPERTY, "")));
assertThat(attributes).isEmpty();
}
use of io.opentelemetry.api.common.Attributes in project opentelemetry-java by open-telemetry.
the class NestedCallbacksTest method test.
@Test
void test() {
Span span = tracer.spanBuilder("one").startSpan();
submitCallbacks(span);
await().atMost(Duration.ofSeconds(15)).until(TestUtils.finishedSpansSize(otelTesting), equalTo(1));
List<SpanData> spans = otelTesting.getSpans();
assertThat(spans).hasSize(1);
assertThat(spans.get(0).getName()).isEqualTo("one");
Attributes attrs = spans.get(0).getAttributes();
assertThat(attrs.size()).isEqualTo(3);
for (int i = 1; i <= 3; i++) {
assertThat(attrs.get(stringKey("key" + i))).isEqualTo(Integer.toString(i));
}
assertThat(Span.current()).isSameAs(Span.getInvalid());
}
use of io.opentelemetry.api.common.Attributes in project otel-mule4-observability-agent by rickbansal-mulesoft.
the class LoggerParser method addLoggerEventsToSpan.
// --------------------------------------------------------------------------------------------
// Annotate the span with Logger event
// --------------------------------------------------------------------------------------------
private void addLoggerEventsToSpan(EnrichedServerNotification notification, MuleSoftTraceStore traceStore) {
String loggerOutput = NotificationParserUtils.getMessage(notification);
Span span = traceStore.getMessageProcessorSpan(NotificationParserUtils.getMuleSoftTraceId(notification), NotificationParserUtils.getFlowId(notification), NotificationParserUtils.getSpanId(notification));
// ----------------------------------------------------------------------------------------
if (loggerOutput != null && notification.getException() == null) {
Attributes eventAttributes = Attributes.of(AttributeKey.stringKey("logger.output"), loggerOutput);
span.addEvent("logger.output.event", eventAttributes);
}
}
Aggregations