Search in sources :

Example 76 with StructuredTrace

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

Example 77 with StructuredTrace

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

Example 78 with StructuredTrace

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

Example 79 with StructuredTrace

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);
}
Also used : Counter(io.micrometer.core.instrument.Counter) RawSpan(org.hypertrace.core.datamodel.RawSpan) StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) Transformer(org.apache.kafka.streams.kstream.Transformer) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KeyValue(org.apache.kafka.streams.KeyValue) StructuredTraceBuilder(org.hypertrace.core.datamodel.shared.trace.StructuredTraceBuilder) ConcurrentMap(java.util.concurrent.ConcurrentMap) PlatformMetricsRegistry(org.hypertrace.core.serviceframework.metrics.PlatformMetricsRegistry) ProcessorContext(org.apache.kafka.streams.processor.ProcessorContext) List(java.util.List) Map(java.util.Map) TraceIdentity(org.hypertrace.core.spannormalizer.TraceIdentity) KeyValue(org.apache.kafka.streams.KeyValue) StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace)

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