Search in sources :

Example 16 with RawSpan

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

the class MigrationTestHttp method testRequestUrlTagKeysPriority.

@ParameterizedTest
@MethodSource("provideMapForTestingRequestUrlTagKeysPriority")
public void testRequestUrlTagKeysPriority(Map<String, String> tagsMap, String expectedUrl) throws Exception {
    Span span = createSpanFromTags(tagsMap);
    RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    // now, we are not populating first class fields. So, it should be null.
    assertNull(rawSpan.getEvent().getHttp());
    assertEquals(expectedUrl, HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get());
}
Also used : RawSpan(org.hypertrace.core.datamodel.RawSpan) Span(io.jaegertracing.api_v2.JaegerSpanInternalModel.Span) RawSpan(org.hypertrace.core.datamodel.RawSpan) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 17 with RawSpan

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

the class MigrationTestHttp method testHttpFields.

@Test
public void testHttpFields() throws Exception {
    Map<String, String> tagsMap = new HashMap<>() {

        {
            put(RawSpanConstants.getValue(HTTP_REQUEST_METHOD), "GET");
            put(RawSpanConstants.getValue(OT_SPAN_TAG_HTTP_METHOD), "PUT");
            put(RawSpanConstants.getValue(OT_SPAN_TAG_HTTP_URL), "https://example.ai/url1");
            put(RawSpanConstants.getValue(HTTP_URL), "https://example.ai/url2");
            put(RawSpanConstants.getValue(HTTP_REQUEST_URL), "https://example.ai/url3");
            put(RawSpanConstants.getValue(HTTP_HOST), "example.ai");
            put(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "/url1");
            put(RawSpanConstants.getValue(HTTP_PATH), "/url2");
            put(RawSpanConstants.getValue(HTTP_USER_DOT_AGENT), "Chrome 1");
            put(RawSpanConstants.getValue(HTTP_USER_AGENT_WITH_UNDERSCORE), "Chrome 2");
            put(RawSpanConstants.getValue(HTTP_USER_AGENT_WITH_DASH), "Chrome 3");
            put(RawSpanConstants.getValue(HTTP_USER_AGENT_REQUEST_HEADER), "Chrome 4");
            put(RawSpanConstants.getValue(HTTP_USER_AGENT), "Chrome 5");
            put(RawSpanConstants.getValue(ENVOY_REQUEST_SIZE), "50");
            put(RawSpanConstants.getValue(HTTP_REQUEST_SIZE), "40");
            put(RawSpanConstants.getValue(ENVOY_RESPONSE_SIZE), "30");
            put(RawSpanConstants.getValue(HTTP_RESPONSE_SIZE), "20");
            put(RawSpanConstants.getValue(HTTP_REQUEST_QUERY_STRING), "a1=v1&a2=v2");
        }
    };
    Span span = createSpanFromTags(tagsMap);
    RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    // now, we are not populating first class fields. So, it should be null.
    assertNull(rawSpan.getEvent().getHttp());
    assertAll(() -> assertEquals("GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals("https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()), () -> assertEquals("/url1", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals("Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals(50, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals(30, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()));
}
Also used : HashMap(java.util.HashMap) RawSpan(org.hypertrace.core.datamodel.RawSpan) Span(io.jaegertracing.api_v2.JaegerSpanInternalModel.Span) RawSpan(org.hypertrace.core.datamodel.RawSpan) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with RawSpan

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

the class MigrationTestHttp method testHttpFieldGenerationForOtelSpan.

@Test
public void testHttpFieldGenerationForOtelSpan() throws Exception {
    Map<String, String> tagsMap = new HashMap<>() {

        {
            put(OTelHttpSemanticConventions.HTTP_TARGET.getValue(), "/url2");
            put(OTelHttpSemanticConventions.HTTP_URL.getValue(), "https://example.ai/url1");
            put(OTelHttpSemanticConventions.HTTP_USER_AGENT.getValue(), "Chrome 1");
            put(OTelHttpSemanticConventions.HTTP_REQUEST_SIZE.getValue(), "100");
            put(OTelHttpSemanticConventions.HTTP_RESPONSE_SIZE.getValue(), "200");
            put(OTelHttpSemanticConventions.HTTP_METHOD.getValue(), "GET");
            put(OTelHttpSemanticConventions.HTTP_SCHEME.getValue(), "https");
        }
    };
    Span span = createSpanFromTags(tagsMap);
    RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    // now, we are not populating first class fields. So, it should be null.
    assertNull(rawSpan.getEvent().getHttp());
    assertAll(() -> assertEquals("GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals("https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals("/url2", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals("Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals(100, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals(200, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()));
}
Also used : HashMap(java.util.HashMap) RawSpan(org.hypertrace.core.datamodel.RawSpan) Span(io.jaegertracing.api_v2.JaegerSpanInternalModel.Span) RawSpan(org.hypertrace.core.datamodel.RawSpan) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with RawSpan

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

the class MigrationTestHttp method testRequestPathTagKeysPriority.

@ParameterizedTest
@MethodSource("provideMapForTestingRequestPathTagKeysPriority")
public void testRequestPathTagKeysPriority(Map<String, String> tagsMap, String expectedPath) throws Exception {
    Span span = createSpanFromTags(tagsMap);
    RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    // now, we are not populating first class fields. So, it should be null.
    assertNull(rawSpan.getEvent().getHttp());
    assertEquals(expectedPath, HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
}
Also used : RawSpan(org.hypertrace.core.datamodel.RawSpan) Span(io.jaegertracing.api_v2.JaegerSpanInternalModel.Span) RawSpan(org.hypertrace.core.datamodel.RawSpan) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 20 with RawSpan

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

the class MigrationTestHttp method testInvalidRequestPath.

@Test
public void testInvalidRequestPath() throws Exception {
    Span span = createSpanFromTags(Map.of(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "path1", RawSpanConstants.getValue(HTTP_PATH), "  "));
    RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    assertFalse(HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).isPresent());
    span = createSpanFromTags(Map.of(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "path1", RawSpanConstants.getValue(HTTP_PATH), "/"));
    rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
    assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
}
Also used : RawSpan(org.hypertrace.core.datamodel.RawSpan) Span(io.jaegertracing.api_v2.JaegerSpanInternalModel.Span) RawSpan(org.hypertrace.core.datamodel.RawSpan) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RawSpan (org.hypertrace.core.datamodel.RawSpan)43 Span (io.jaegertracing.api_v2.JaegerSpanInternalModel.Span)33 Test (org.junit.jupiter.api.Test)25 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)25 HashMap (java.util.HashMap)14 Config (com.typesafe.config.Config)12 TraceIdentity (org.hypertrace.core.spannormalizer.TraceIdentity)9 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 StructuredTrace (org.hypertrace.core.datamodel.StructuredTrace)6 ByteBuffer (java.nio.ByteBuffer)5 Map (java.util.Map)5 Properties (java.util.Properties)5 StreamsBuilder (org.apache.kafka.streams.StreamsBuilder)5 TestOutputTopic (org.apache.kafka.streams.TestOutputTopic)5 TopologyTestDriver (org.apache.kafka.streams.TopologyTestDriver)5 JaegerSpanSerde (org.hypertrace.core.spannormalizer.jaeger.JaegerSpanSerde)5 SetEnvironmentVariable (org.junitpioneer.jupiter.SetEnvironmentVariable)5 ByteString (com.google.protobuf.ByteString)4 Counter (io.micrometer.core.instrument.Counter)4 Instant (java.time.Instant)4