use of org.hypertrace.core.datamodel.Event 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);
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class RpcSemanticConventionUtilsTest method testRpcMethod.
@Test
public void testRpcMethod() {
Event event = createMockEventWithAttribute(OTEL_SPAN_TAG_RPC_METHOD.getValue(), "GetId");
assertEquals("GetId", RpcSemanticConventionUtils.getRpcMethod(event).get());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class RpcSemanticConventionUtilsTest method testGetGrpcRequestMetadataHostForNotGrpcSystem.
@Test
public void testGetGrpcRequestMetadataHostForNotGrpcSystem() {
Event event = mock(Event.class);
when(event.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(RPC_REQUEST_METADATA_HOST.getValue(), AttributeValue.newBuilder().setValue("webhost:9011").build())).build());
assertEquals(Optional.empty(), RpcSemanticConventionUtils.getGrpcRequestMetadataHost(event));
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class SpanSemanticConventionUtilsTest method testGetURIForOtelFormat.
@Test
public void testGetURIForOtelFormat() {
Event e = mock(Event.class);
// host present
Attributes attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), SemanticConventionTestUtil.buildAttributeValue("example.com")));
when(e.getAttributes()).thenReturn(attributes);
Optional<String> v = SpanSemanticConventionUtils.getURIForOtelFormat(e);
assertEquals("example.com", v.get());
// ip present
attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("172.0.1.17")));
when(e.getAttributes()).thenReturn(attributes);
v = SpanSemanticConventionUtils.getURIForOtelFormat(e);
assertEquals("172.0.1.17", v.get());
// host & port
attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("172.0.1.17"), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), SemanticConventionTestUtil.buildAttributeValue("2705")));
when(e.getAttributes()).thenReturn(attributes);
v = SpanSemanticConventionUtils.getURIForOtelFormat(e);
assertEquals("172.0.1.17:2705", v.get());
// ip & host both present
attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue("172.0.1.17"), OTelSpanSemanticConventions.NET_PEER_NAME.getValue(), SemanticConventionTestUtil.buildAttributeValue("example.com"), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), SemanticConventionTestUtil.buildAttributeValue("2705")));
when(e.getAttributes()).thenReturn(attributes);
v = SpanSemanticConventionUtils.getURIForOtelFormat(e);
assertEquals("example.com:2705", v.get());
// empty host
attributes = SemanticConventionTestUtil.buildAttributes(Map.of(OTelSpanSemanticConventions.NET_PEER_IP.getValue(), SemanticConventionTestUtil.buildAttributeValue(""), OTelSpanSemanticConventions.NET_PEER_PORT.getValue(), SemanticConventionTestUtil.buildAttributeValue("2705")));
when(e.getAttributes()).thenReturn(attributes);
v = SpanSemanticConventionUtils.getURIForOtelFormat(e);
assertFalse(v.isPresent());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class SpanEventViewGeneratorTest method test_getRequestUrl_nullProtocol_shouldReturnNull.
@Test
public void test_getRequestUrl_nullProtocol_shouldReturnNull() {
Event event = mock(Event.class);
Assertions.assertNull(spanEventViewGenerator.getRequestUrl(event, null));
}
Aggregations