Search in sources :

Example 26 with Event

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);
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 27 with Event

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());
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 28 with Event

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));
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 29 with 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());
}
Also used : Attributes(org.hypertrace.core.datamodel.Attributes) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 30 with Event

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));
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Aggregations

Event (org.hypertrace.core.datamodel.Event)304 Test (org.junit.jupiter.api.Test)257 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)54 StructuredTrace (org.hypertrace.core.datamodel.StructuredTrace)54 Attributes (org.hypertrace.core.datamodel.Attributes)41 Entity (org.hypertrace.entity.data.service.v1.Entity)27 HashMap (java.util.HashMap)25 AbstractAttributeEnricherTest (org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)17 ByteBuffer (java.nio.ByteBuffer)13 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)13 StructuredTraceGraph (org.hypertrace.core.datamodel.shared.StructuredTraceGraph)12 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)11 AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)10 SemanticConventionTestUtil.buildAttributes (org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes)8 Edge (org.hypertrace.core.datamodel.Edge)7 Entity (org.hypertrace.core.datamodel.Entity)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5