use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class UserAgentSpanEnricherTest method enrichUserAgentFromGrpc.
@Test
public void enrichUserAgentFromGrpc() {
String userAgent = "grpc-java-okhttp/1.19.0";
Event e = createMockEvent();
mockProtocol(e, Protocol.PROTOCOL_GRPC);
addAttribute(e, RPC_REQUEST_METADATA_USER_AGENT.getValue(), userAgent);
addAttribute(e, OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), "grpc");
enricher.enrichEvent(null, e);
Map<String, AttributeValue> map = e.getEnrichedAttributes().getAttributeMap();
assertEquals(7, map.size());
assertEquals("unknown", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_NAME)).getValue());
assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_BROWSER_VERSION)).getValue());
assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_DEVICE_CATEGORY)).getValue());
assertEquals("unknown", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_NAME)).getValue());
assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_OS_VERSION)).getValue());
assertEquals("", map.get(Constants.getEnrichedSpanConstant(UserAgent.USER_AGENT_BROWSER_VERSION)).getValue());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichTrace_apiEntryEvent.
@Test
public void test_EnrichTrace_apiEntryEvent() {
Event e = createApiEntryEvent(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.Event in project hypertrace-ingester by hypertrace.
the class BackendEntityEnricherTest method test_EnrichTrace_BackendResolvedForBrokenFacadeEvent.
@Test
public void test_EnrichTrace_BackendResolvedForBrokenFacadeEvent() {
String eventName = "broken facade event";
String backendName = "peer";
String serviceName = "peer";
String backendId = "peerId";
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());
// both service and peer service are same
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 for above event
Assertions.assertNotNull(EnrichedSpanUtils.getBackendId(e));
Assertions.assertNotNull(EnrichedSpanUtils.getBackendName(e));
}
use of org.hypertrace.core.datamodel.Event 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.Event 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));
}
Aggregations