use of com.google.cloud.videointelligence.v1p2beta1.Entity 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 com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.
the class CassandraBackendProviderTest method testBackendResolution.
@Test
public void testBackendResolution() {
BackendInfo backendInfo = backendEntityEnricher.resolve(getCassandraEvent(), structuredTrace, structuredTraceGraph).get();
Entity entity = backendInfo.getEntity();
Assertions.assertEquals("localhost:9000", entity.getEntityName());
Map<String, AttributeValue> attributes = backendInfo.getAttributes();
assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("select"), "BACKEND_DESTINATION", AttributeValueCreator.create("customer.orders")), attributes);
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.
the class CassandraBackendProviderTest method testBackendResolutionForOTEvent.
@Test
public void testBackendResolutionForOTEvent() {
BackendInfo backendInfo = backendEntityEnricher.resolve(getCassandraOTEvent(), structuredTrace, structuredTraceGraph).get();
Entity entity = backendInfo.getEntity();
Assertions.assertEquals("localhost:9000", entity.getEntityName());
Map<String, AttributeValue> attributes = backendInfo.getAttributes();
assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("select")), attributes);
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.
the class ClientSpanEndpointProviderTest method checkFallbackBackendEntityGeneratedFromClientExitSpan.
@Test
public void checkFallbackBackendEntityGeneratedFromClientExitSpan() {
Event e = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("bdf03dfabf5c70f8".getBytes())).setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824")).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of("SPAN_TYPE", AttributeValue.newBuilder().setValue("EXIT").build())).build()).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of("span.kind", AttributeValue.newBuilder().setValue("client").build(), "k8s.pod_id", AttributeValue.newBuilder().setValue("55636196-c840-11e9-a417-42010a8a0064").build(), "docker.container_id", AttributeValue.newBuilder().setValue("ee85cf2cfc3b24613a3da411fdbd2f3eabbe729a5c86c5262971c8d8c29dad0f").build(), "FLAGS", AttributeValue.newBuilder().setValue("0").build())).build()).setEventName("redis::getDrivers").setStartTimeMillis(1566869077746L).setEndTimeMillis(1566869077750L).setMetrics(Metrics.newBuilder().setMetricMap(Map.of("Duration", MetricValue.newBuilder().setValue(4.0).build())).build()).setServiceName("redis").setEventRefList(Arrays.asList(EventRef.newBuilder().setTraceId(ByteBuffer.wrap("random_trace_id".getBytes())).setEventId(ByteBuffer.wrap("random_event_id".getBytes())).setRefType(EventRefType.CHILD_OF).build())).build();
Event parentEvent = Event.newBuilder().setCustomerId("__default").setEventId(ByteBuffer.wrap("random".getBytes())).setAttributes(Attributes.newBuilder().setAttributeMap(Map.of("span.kind", AttributeValue.newBuilder().setValue("server").build())).build()).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(Map.of(SERVICE_NAME_ATTR, AttributeValue.newBuilder().setValue("customer").build())).build()).setEventName("getDrivers").setStartTimeMillis(1566869077746L).build();
when(structuredTraceGraph.getParentEvent(e)).thenReturn(parentEvent);
Entity backendEntity = backendEntityEnricher.resolve(e, structuredTrace, structuredTraceGraph).get().getEntity();
assertEquals("redis", backendEntity.getIdentifyingAttributesMap().get(Constants.getEntityConstant(BackendAttribute.BACKEND_ATTRIBUTE_HOST)).getValue().getString());
}
use of com.google.cloud.videointelligence.v1p2beta1.Entity in project hypertrace-ingester by hypertrace.
the class ElasticsearchBackendProviderTest method testBackendResolutionForOTelEvent.
@Test
public void testBackendResolutionForOTelEvent() {
BackendInfo backendInfo = backendEntityEnricher.resolve(getElasticsearchOTelEvent(), structuredTrace, structuredTraceGraph).get();
Entity entity = backendInfo.getEntity();
Assertions.assertEquals("test:2000", entity.getEntityName());
Map<String, AttributeValue> attributes = backendInfo.getAttributes();
assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("GetAction"), "BACKEND_DESTINATION", AttributeValueCreator.create("test-index")), attributes);
}
Aggregations