Search in sources :

Example 16 with StructuredTrace

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());
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Test(org.junit.jupiter.api.Test)

Example 17 with StructuredTrace

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));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Resource(org.hypertrace.core.datamodel.Resource) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 18 with StructuredTrace

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"));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 19 with StructuredTrace

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));
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Test(org.junit.jupiter.api.Test)

Example 20 with StructuredTrace

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;
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) ArrayList(java.util.ArrayList) Edge(org.hypertrace.core.datamodel.Edge)

Aggregations

StructuredTrace (org.hypertrace.core.datamodel.StructuredTrace)79 Test (org.junit.jupiter.api.Test)66 Event (org.hypertrace.core.datamodel.Event)47 HashMap (java.util.HashMap)15 AbstractAttributeEnricherTest (org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)15 Config (com.typesafe.config.Config)7 ByteBuffer (java.nio.ByteBuffer)7 Map (java.util.Map)7 Edge (org.hypertrace.core.datamodel.Edge)7 File (java.io.File)6 List (java.util.List)6 Entity (org.hypertrace.entity.data.service.v1.Entity)6 URL (java.net.URL)5 ArrayList (java.util.ArrayList)5 SpecificDatumReader (org.apache.avro.specific.SpecificDatumReader)5 RawSpan (org.hypertrace.core.datamodel.RawSpan)5 HexUtils (org.hypertrace.core.datamodel.shared.HexUtils)5 Counter (io.micrometer.core.instrument.Counter)4 Duration (java.time.Duration)4 Instant (java.time.Instant)4