use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class TraceValueSourceTest method canReadMetrics.
@Test
void canReadMetrics() {
StructuredTrace trace = defaultedStructuredTraceBuilder().setMetrics(buildMetricsWithKeyValue("traceKey", 10.3)).build();
assertEquals(Optional.of(doubleLiteral(10.3)), new TraceValueSource(trace).getMetric("traceKey", AttributeKind.TYPE_DOUBLE));
assertEquals(Optional.of(longLiteral(10)), new TraceValueSource(trace).getMetric("traceKey", AttributeKind.TYPE_INT64));
assertEquals(Optional.empty(), new TraceValueSource(trace).getMetric("fake", AttributeKind.TYPE_INT64));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class TraceValueSourceTest method canResolveFields.
@Test
void canResolveFields() {
StructuredTrace trace = defaultedStructuredTraceBuilder().setStartTimeMillis(15).setEndTimeMillis(18).build();
assertEquals(Optional.of(longLiteral(15)), new TraceValueSource(trace).getSourceField(SourceField.SOURCE_FIELD_START_TIME, AttributeKind.TYPE_TIMESTAMP));
assertEquals(Optional.of(longLiteral(18)), new TraceValueSource(trace).getSourceField(SourceField.SOURCE_FIELD_END_TIME, AttributeKind.TYPE_TIMESTAMP));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class ViewGeneratorStateTest method testGetApiTraceGraph.
@Test
public void testGetApiTraceGraph() {
StructuredTrace trace = getTestTrace(customerId, traceId1);
ApiTraceGraph apiTraceGraph = ViewGeneratorState.getApiTraceGraph(trace);
assertNotNull(apiTraceGraph);
ApiTraceGraph sameApiTraceGraph = ViewGeneratorState.getApiTraceGraph(trace);
assertEquals(sameApiTraceGraph, apiTraceGraph);
StructuredTrace modifiedTrace = getTestTrace(customerId, traceId1);
modifiedTrace.setEntityList(Arrays.asList(Entity.newBuilder().setCustomerId(customerId).setEntityId("entity-2").setEntityName("entity-2").setEntityType("service").build()));
// same trace id but different object should result in rebuilding of trace state
ApiTraceGraph differentApiTraceGraph1 = ViewGeneratorState.getApiTraceGraph(modifiedTrace);
assertNotEquals(apiTraceGraph, differentApiTraceGraph1);
StructuredTrace differentTrace = getTestTrace(customerId, traceId2);
ApiTraceGraph differentApiTraceGraph2 = ViewGeneratorState.getApiTraceGraph(differentTrace);
assertNotEquals(apiTraceGraph, differentApiTraceGraph2);
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class RawSpanToStructuredTraceTransformer method transform.
@Override
public KeyValue<String, StructuredTrace> transform(TraceIdentity key, RawSpan rawSpan) {
StructuredTrace structuredTrace = StructuredTraceBuilder.buildStructuredTraceFromRawSpans(List.of(rawSpan), key.getTraceId(), key.getTenantId());
tenantToBypassSpanCounter.computeIfAbsent(key.getTenantId(), tenant -> PlatformMetricsRegistry.registerCounter(BYPASS_SPANS, Map.of("tenantId", key.getTenantId()))).increment();
return new KeyValue<>(null, structuredTrace);
}
Aggregations