use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichEvent_test_enrichEvent_missingBackendOperationEvent.
@Test
public void test_EnrichEvent_test_enrichEvent_missingBackendOperationEvent() {
Event e = createApiEntryEvent(EVENT_ID).build();
StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
enricher.enrichEvent(trace, e);
Assertions.assertNull(EnrichedSpanUtils.getBackendOperation(e));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichTrace_BackendResolvedForBrokenEvent.
@Test
public void test_EnrichTrace_BackendResolvedForBrokenEvent() {
String eventName = "broken event";
String backendName = "peer";
String backendId = "peerId";
String serviceName = "client";
Map<String, String> identifyingAttributes = Map.of(BACKEND_PROTOCOL_ATTR_NAME, "UNKNOWN", BACKEND_HOST_ATTR_NAME, backendName, BACKEND_PORT_ATTR_NAME, "-1");
Map<String, String> attributes = Map.of("FROM_EVENT", eventName, "FROM_EVENT_ID", HexUtils.getHex(ByteBuffer.wrap(EVENT_ID.getBytes())));
Entity backendEntity = createEntity(EntityType.BACKEND, backendName, identifyingAttributes, attributes, TENANT_ID);
when(edsClient.upsert(eq(backendEntity))).thenReturn(Entity.newBuilder(backendEntity).setEntityId(backendId).putAllAttributes(createEdsAttributes(identifyingAttributes)).build());
// for broken event service and peer service are different
Event e = createApiExitEvent(EVENT_ID, serviceName, backendName).setEventName(eventName).build();
StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
enricher.enrichTrace(trace);
// assert that backend has been created
Assertions.assertNotNull(EnrichedSpanUtils.getBackendId(e));
Assertions.assertNotNull(EnrichedSpanUtils.getBackendName(e));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichTrace_noBackendResolved.
@Test
public void test_EnrichTrace_noBackendResolved() {
Event e = createApiExitEvent(EVENT_ID).build();
StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
enricher.enrichTrace(trace);
Assertions.assertEquals(ByteBuffer.wrap(EVENT_ID.getBytes()), e.getEventId());
Assertions.assertNull(EnrichedSpanUtils.getBackendId(e));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichTrace_ExternalBackendNotResolvedAsPeerServiceExists.
@Test
public void test_EnrichTrace_ExternalBackendNotResolvedAsPeerServiceExists() {
String eventName = "service exists";
String backendName = "external-backend";
String serviceId = "serviceId";
String peerService = "peerService";
// return false for backend service name identified by http backend resolver
AttributeValue fqnAttribute = AttributeValue.newBuilder().setValue(Value.newBuilder().setString(backendName)).build();
ByTypeAndIdentifyingAttributes request = ByTypeAndIdentifyingAttributes.newBuilder().setEntityType(EntityType.SERVICE.name()).putIdentifyingAttributes(EntityConstants.getValue(org.hypertrace.entity.constants.v1.CommonAttribute.COMMON_ATTRIBUTE_FQN), fqnAttribute).build();
// check for if service exists for peer service
when(edsClient.getByTypeAndIdentifyingAttributes(eq(TENANT_ID), eq(request))).thenReturn(null);
AttributeValue fqnAttributePeerService = AttributeValue.newBuilder().setValue(Value.newBuilder().setString(peerService)).build();
ByTypeAndIdentifyingAttributes requestPeerService = ByTypeAndIdentifyingAttributes.newBuilder().setEntityType(EntityType.SERVICE.name()).putIdentifyingAttributes(EntityConstants.getValue(org.hypertrace.entity.constants.v1.CommonAttribute.COMMON_ATTRIBUTE_FQN), fqnAttributePeerService).build();
when(edsClient.getByTypeAndIdentifyingAttributes(eq(TENANT_ID), eq(requestPeerService))).thenReturn(Entity.newBuilder().setEntityId(serviceId).build());
// for broken event service and peer service are different
Event.Builder eventBuilder = createApiExitEvent(EVENT_ID, backendName, peerService).setEventName(eventName).setEnrichedAttributes(createNewAvroAttributes(Map.of("PROTOCOL", "HTTPS")));
eventBuilder.getHttpBuilder().getRequestBuilder().setHost(backendName).setScheme("https").setPath("/abc/v1/book");
Event e = eventBuilder.build();
StructuredTrace trace = createStructuredTrace(TENANT_ID, e);
enricher.enrichTrace(trace);
// assert that backend has been created
Assertions.assertNull(EnrichedSpanUtils.getBackendId(e));
Assertions.assertNull(EnrichedSpanUtils.getBackendName(e));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class ApiBoundaryTypeAttributeEnricherTest method test_enrichEvent_noAttributes_noNPE.
@Test
public void test_enrichEvent_noAttributes_noNPE() {
StructuredTrace noAttributesTrace = mock(StructuredTrace.class, RETURNS_DEEP_STUBS);
when(noAttributesTrace.getAttributes()).thenReturn(null);
}
Aggregations