use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class DefaultValueResolverTest method resolvesProjectionsAcrossScopes.
@Test
void resolvesProjectionsAcrossScopes() {
AttributeMetadata projectionMetadata = AttributeMetadata.newBuilder().setDefinition(AttributeDefinition.newBuilder().setProjection(Projection.newBuilder().setAttributeId("TRACE.other"))).build();
AttributeMetadata otherMetadata = AttributeMetadata.newBuilder().setScopeString("TRACE").setType(AttributeType.METRIC).setValueKind(AttributeKind.TYPE_INT64).setDefinition(AttributeDefinition.newBuilder().setSourcePath("metricPath").build()).build();
when(this.mockAttributeClient.get("TRACE.other")).thenReturn(Single.just(otherMetadata));
StructuredTrace trace = defaultedStructuredTraceBuilder().setMetrics(buildMetricsWithKeyValue("metricPath", 42)).build();
assertEquals(longLiteral(42), this.resolver.resolve(ValueSourceFactory.forSpan(trace, mock(Event.class)), projectionMetadata).blockingGet());
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class SpanValueSourceTest method returnsValueIfMatchingKeyInResource.
@Test
void returnsValueIfMatchingKeyInResource() {
StructuredTrace trace = defaultedStructuredTraceBuilder().setResourceList(List.of(// idx 0 won't be used in this test
mock(Resource.class), Resource.newBuilder().setAttributes(buildAttributesWithKeyValue("resourceKey", "value")).build())).build();
Event span = defaultedEventBuilder().setResourceIndex(1).build();
assertEquals(Optional.of(stringLiteral("value")), new SpanValueSource(trace, span).getAttribute("resourceKey", AttributeKind.TYPE_STRING));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class SpanValueSourceTest method canConvertValueSourceBasedOnScope.
@Test
void canConvertValueSourceBasedOnScope() {
StructuredTrace mockTrace = mock(StructuredTrace.class);
SpanValueSource originalSource = new SpanValueSource(mockTrace, mock(Event.class));
assertEquals(Optional.of(originalSource), originalSource.sourceForScope("OTHER"));
assertEquals(Optional.of(ValueSourceFactory.forTrace(mockTrace)), originalSource.sourceForScope("TRACE"));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class TraceValueSourceTest method canReadAttributes.
@Test
void canReadAttributes() {
StructuredTrace trace = defaultedStructuredTraceBuilder().setAttributes(buildAttributesWithKeyValue("traceKey", "traceValue")).build();
assertEquals(Optional.of(stringLiteral("traceValue")), new TraceValueSource(trace).getAttribute("traceKey", AttributeKind.TYPE_STRING));
assertEquals(Optional.empty(), new TraceValueSource(trace).getAttribute("fake", AttributeKind.TYPE_STRING));
}
use of org.hypertrace.core.datamodel.StructuredTrace in project hypertrace-ingester by hypertrace.
the class TestUtils method createTraceWithEventsAndEdges.
public static StructuredTrace createTraceWithEventsAndEdges(Event[] events, Map<Integer, int[]> adjList) {
StructuredTrace trace = createStructuredTrace(events);
List<Edge> eventEdgeList = new ArrayList<>();
adjList.forEach((src, list) -> {
for (int target : list) {
eventEdgeList.add(Edge.newBuilder().setSrcIndex(src).setTgtIndex(target).setEdgeType(EdgeType.EVENT_EVENT).build());
}
});
trace.setEventEdgeList(eventEdgeList);
return trace;
}
Aggregations