Search in sources :

Example 41 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class SpanEventViewGeneratorTest method test_getRequestUrl_httpProtocol_shouldReturnFullUrl.

@Test
public void test_getRequestUrl_httpProtocol_shouldReturnFullUrl() {
    Event event = createMockEventWithAttribute(RawSpanConstants.getValue(HTTP_URL), "http://www.example.com");
    assertEquals("http://www.example.com", spanEventViewGenerator.getRequestUrl(event, Protocol.PROTOCOL_HTTP));
}
Also used : Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 42 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class DefaultTraceAttributeReaderTest method canReadSpanValues.

@Test
void canReadSpanValues() {
    AttributeMetadata metadata = AttributeMetadata.newBuilder().setScopeString("TEST_SCOPE").setType(AttributeType.ATTRIBUTE).setValueKind(AttributeKind.TYPE_STRING).setDefinition(AttributeDefinition.newBuilder().setSourcePath("attrPath").build()).build();
    when(this.mockAttributeClient.get("TEST_SCOPE", "key")).thenReturn(Single.just(metadata));
    Event span = defaultedEventBuilder().setAttributes(buildAttributesWithKeyValue("attrPath", "attrValue")).build();
    assertEquals(stringLiteral("attrValue"), this.traceAttributeReader.getSpanValue(mock(StructuredTrace.class), span, "TEST_SCOPE", "key").blockingGet());
}
Also used : StructuredTrace(org.hypertrace.core.datamodel.StructuredTrace) AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 43 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class DefaultValueResolverTest method resolvesFirstAvailableDefinition.

@Test
void resolvesFirstAvailableDefinition() {
    AttributeMetadata metadata = AttributeMetadata.newBuilder().setScopeString("TEST_SCOPE").setType(AttributeType.ATTRIBUTE).setValueKind(AttributeKind.TYPE_INT64).setDefinition(AttributeDefinition.newBuilder().setFirstValuePresent(AttributeDefinitions.newBuilder().addDefinitions(AttributeDefinition.newBuilder().setSourcePath("path.to.string")).addDefinitions(AttributeDefinition.newBuilder().setSourcePath("non.existent")).addDefinitions(AttributeDefinition.newBuilder().setSourcePath("path.to.int")).addDefinitions(AttributeDefinition.newBuilder().setSourceField(SourceField.SOURCE_FIELD_START_TIME)))).build();
    Event span = defaultedEventBuilder().setAttributes(buildAttributesWithKeyValues(Map.of("path.to.string", "foo", "path.to.int", "14"))).build();
    assertEquals(longLiteral(14), this.resolver.resolve(ValueSourceFactory.forSpan(this.mockStructuredTrace, span), metadata).blockingGet());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 44 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class DefaultValueResolverTest method resolvesMetrics.

@Test
void resolvesMetrics() {
    AttributeMetadata metadata = AttributeMetadata.newBuilder().setScopeString("TEST_SCOPE").setType(AttributeType.METRIC).setValueKind(AttributeKind.TYPE_INT64).setDefinition(AttributeDefinition.newBuilder().setSourcePath("metricPath").build()).build();
    Event span = defaultedEventBuilder().setMetrics(buildMetricsWithKeyValue("metricPath", 42)).build();
    assertEquals(longLiteral(42), this.resolver.resolve(ValueSourceFactory.forSpan(this.mockStructuredTrace, span), metadata).blockingGet());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Example 45 with Event

use of org.hypertrace.core.datamodel.Event in project hypertrace-ingester by hypertrace.

the class DefaultValueResolverTest method resolvesFirstAttributeProjection.

@Test
void resolvesFirstAttributeProjection() {
    AttributeMetadata metadata = AttributeMetadata.newBuilder().setScopeString("TEST_SCOPE").setType(AttributeType.ATTRIBUTE).setValueKind(AttributeKind.TYPE_INT64).setDefinition(AttributeDefinition.newBuilder().setFirstValuePresent(AttributeDefinitions.newBuilder().addDefinitions(AttributeDefinition.newBuilder().setSourcePath("non.existent")).addDefinitions(AttributeDefinition.newBuilder().setProjection(Projection.newBuilder().setLiteral(LiteralValue.newBuilder().setStringValue("expected-value")))))).build();
    Event span = defaultedEventBuilder().build();
    assertEquals(stringLiteral("expected-value"), this.resolver.resolve(ValueSourceFactory.forSpan(this.mockStructuredTrace, span), metadata).blockingGet());
}
Also used : AttributeMetadata(org.hypertrace.core.attribute.service.v1.AttributeMetadata) Event(org.hypertrace.core.datamodel.Event) Test(org.junit.jupiter.api.Test)

Aggregations

Event (org.hypertrace.core.datamodel.Event)304 Test (org.junit.jupiter.api.Test)257 AttributeValue (org.hypertrace.core.datamodel.AttributeValue)54 StructuredTrace (org.hypertrace.core.datamodel.StructuredTrace)54 Attributes (org.hypertrace.core.datamodel.Attributes)41 Entity (org.hypertrace.entity.data.service.v1.Entity)27 HashMap (java.util.HashMap)25 AbstractAttributeEnricherTest (org.hypertrace.traceenricher.enrichment.enrichers.AbstractAttributeEnricherTest)17 ByteBuffer (java.nio.ByteBuffer)13 BackendInfo (org.hypertrace.traceenricher.enrichment.enrichers.resolver.backend.BackendInfo)13 StructuredTraceGraph (org.hypertrace.core.datamodel.shared.StructuredTraceGraph)12 TestUtil.buildAttributeValue (org.hypertrace.traceenricher.TestUtil.buildAttributeValue)11 AttributeMetadata (org.hypertrace.core.attribute.service.v1.AttributeMetadata)10 SemanticConventionTestUtil.buildAttributes (org.hypertrace.semantic.convention.utils.SemanticConventionTestUtil.buildAttributes)8 Edge (org.hypertrace.core.datamodel.Edge)7 Entity (org.hypertrace.core.datamodel.Entity)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5