use of org.hypertrace.core.datamodel.Attributes in project hypertrace-ingester by hypertrace.
the class ApiTraceGraphDebug method addEnrichedAttribute.
void addEnrichedAttribute(Event event, String key, AttributeValue value) {
Attributes enrichedAttributes = event.getEnrichedAttributes();
if (enrichedAttributes == null) {
enrichedAttributes = Attributes.newBuilder().build();
event.setEnrichedAttributes(enrichedAttributes);
}
enrichedAttributes.getAttributeMap().put(key, value);
}
use of org.hypertrace.core.datamodel.Attributes in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testGetRabbitmqOperation.
@Test
public void testGetRabbitmqOperation() {
Event e = mock(Event.class);
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_OPERATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("publish")));
when(e.getAttributes()).thenReturn(attributes);
Optional<String> v = MessagingSemanticConventionUtils.getMessagingOperation(e);
assertEquals("publish", v.get());
}
use of org.hypertrace.core.datamodel.Attributes in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testIsRabbitMqBackend.
@Test
public void testIsRabbitMqBackend() {
Event e = mock(Event.class);
// otel format
String routingKey = "otelRoutingKey";
Attributes attributes = buildAttributes(Map.of(OtelMessagingSemanticConventions.RABBITMQ_ROUTING_KEY.getValue(), buildAttributeValue(routingKey)));
when(e.getAttributes()).thenReturn(attributes);
boolean v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
assertTrue(v);
// other format
routingKey = "otherRoutingKey";
attributes = buildAttributes(Map.of(RawSpanConstants.getValue(RabbitMq.RABBIT_MQ_ROUTING_KEY), buildAttributeValue(routingKey)));
when(e.getAttributes()).thenReturn(attributes);
v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
assertTrue(v);
// not present
attributes = buildAttributes(Map.of());
when(e.getAttributes()).thenReturn(attributes);
v = MessagingSemanticConventionUtils.isRabbitMqBackend(e);
Assertions.assertFalse(v);
}
use of org.hypertrace.core.datamodel.Attributes in project hypertrace-ingester by hypertrace.
the class MessagingSemanticConventionUtilsTest method testGetKafkaDestination.
@Test
public void testGetKafkaDestination() {
Event e = mock(Event.class);
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OtelMessagingSemanticConventions.MESSAGING_DESTINATION.getValue(), SemanticConventionTestUtil.buildAttributeValue("queueName"), OtelMessagingSemanticConventions.MESSAGING_KAFKA_CONSUMER_GROUP.getValue(), SemanticConventionTestUtil.buildAttributeValue("test")));
when(e.getAttributes()).thenReturn(attributes);
Optional<String> v = MessagingSemanticConventionUtils.getMessagingDestinationForKafka(e);
assertEquals("test.queueName", v.get());
}
use of org.hypertrace.core.datamodel.Attributes in project hypertrace-ingester by hypertrace.
the class RpcSemanticConventionUtilsTest method testIsRpcTypeGrpcForOTelFormat.
@Test
public void testIsRpcTypeGrpcForOTelFormat() {
Event e = mock(Event.class);
// otel format
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelRpcSemanticConventions.RPC_SYSTEM.getValue(), SemanticConventionTestUtil.buildAttributeValue(OTelRpcSemanticConventions.RPC_SYSTEM_VALUE_GRPC.getValue())));
when(e.getAttributes()).thenReturn(attributes);
boolean v = RpcSemanticConventionUtils.isRpcTypeGrpcForOTelFormat(e);
assertTrue(v);
attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelRpcSemanticConventions.RPC_SYSTEM.getValue(), SemanticConventionTestUtil.buildAttributeValue("other")));
when(e.getAttributes()).thenReturn(attributes);
v = RpcSemanticConventionUtils.isRpcTypeGrpcForOTelFormat(e);
assertFalse(v);
}
Aggregations