use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class TraceStatsEnricher method enrichTrace.
@Override
public void enrichTrace(StructuredTrace trace) {
ApiTraceGraph apiTraceGraph = ApiTraceGraphBuilder.buildGraph(trace);
if (apiTraceGraph.getApiNodeList().isEmpty()) {
return;
}
Event firstNodeHeadSpan = apiTraceGraph.getApiNodeList().get(0).getHeadEvent();
if (firstNodeHeadSpan == null) {
return;
}
addHeadSpanIdTraceAttribute(trace, firstNodeHeadSpan);
addUniqueApiNodesCountTraceAttribute(apiTraceGraph.getApiNodeList(), trace);
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class AbstractBackendEntityEnricher method enrichTrace.
// At trace level, based on the next span to identify if a backend entity is actually a service
// entity.
@Override
public void enrichTrace(StructuredTrace trace) {
try {
StructuredTraceGraph structuredTraceGraph = buildGraph(trace);
trace.getEventList().stream().filter(event -> EnrichedSpanUtils.isExitSpan(event) && SpanAttributeUtils.isLeafSpan(structuredTraceGraph, event) && canResolveBackend(structuredTraceGraph, event)).map(event -> Pair.of(event, resolve(event, trace, structuredTraceGraph))).filter(pair -> pair.getRight().isPresent()).filter(pair -> isValidBackendEntity(trace, pair.getLeft(), pair.getRight().get())).forEach(pair -> decorateWithBackendEntity(pair.getRight().get(), pair.getLeft(), trace));
} catch (Exception ex) {
LOGGER.error("An error occurred while enriching backend", ex);
}
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method getResponseSize_httpProtocol_noSize.
@Test
public void getResponseSize_httpProtocol_noSize() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
Optional<Integer> requestSize = EnrichedSpanUtils.getResponseSize(e);
assertTrue(requestSize.isEmpty());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method should_getNullUrl_noHttpFields.
@Test
public void should_getNullUrl_noHttpFields() {
Event e = mock(Event.class);
when(e.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
Optional<String> url = EnrichedSpanUtils.getFullHttpUrl(e);
assertTrue(url.isEmpty());
}
use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.
the class EnrichedSpanUtilsTest method createMockEventWithAttribute.
private Event createMockEventWithAttribute(String key, String value) {
Event e = mock(Event.class);
when(e.getAttributes()).thenReturn(Attributes.newBuilder().setAttributeMap(Map.of(key, AttributeValue.newBuilder().setValue(value).build())).build());
when(e.getEnrichedAttributes()).thenReturn(null);
return e;
}
Aggregations