Search in sources :

Example 21 with RawSpan

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

the class MigrationTestHttp method testResponseStatusCodePriority.

@ParameterizedTest
@MethodSource("provideMapForTestingResponseStatusCodePriority")
public void testResponseStatusCodePriority(Map<String, String> tagsMap, int statusCode) 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(statusCode, HttpSemanticConventionUtils.getHttpResponseStatusCode(rawSpan.getEvent()));
}
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 22 with RawSpan

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

the class MigrationTestRpc method testGrpcFields.

@Test
public void testGrpcFields() throws Exception {
    String grpcRequestBodyValue = "some grpc request body";
    String grpcResponseBodyValue = "some grpc response body";
    String grpcErrorMessageValue = "some error message";
    String censusResponseStatusMessageValue = "CENSUS_RESPONSE_STATUS_MESSAGE";
    String envoyGrpcStatusMessage = "ENVOY_GRPC_STATUS_MESSAGE";
    Map<String, String> tagsMap = new HashMap<>() {

        {
            put(RawSpanConstants.getValue(GRPC_ERROR_MESSAGE), grpcErrorMessageValue);
            put(RawSpanConstants.getValue(CENSUS_RESPONSE_STATUS_CODE), "12");
            put(RawSpanConstants.getValue(GRPC_STATUS_CODE), "13");
            put(RawSpanConstants.getValue(CENSUS_RESPONSE_CENSUS_STATUS_CODE), "14");
            put(RawSpanConstants.getValue(CENSUS_RESPONSE_STATUS_MESSAGE), censusResponseStatusMessageValue);
            put(RawSpanConstants.getValue(ENVOY_GRPC_STATUS_MESSAGE), envoyGrpcStatusMessage);
            put(RawSpanConstants.getValue(GRPC_REQUEST_BODY), grpcRequestBodyValue);
            put(RawSpanConstants.getValue(GRPC_RESPONSE_BODY), grpcResponseBodyValue);
        }
    };
    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().getGrpc());
    assertEquals(grpcErrorMessageValue, RpcSemanticConventionUtils.getGrpcErrorMsg(rawSpan.getEvent()));
    assertEquals(12, RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent()));
    assertEquals(censusResponseStatusMessageValue, RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent()));
    assertEquals(grpcResponseBodyValue.length(), RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get());
    assertEquals(grpcRequestBodyValue.length(), RpcSemanticConventionUtils.getGrpcRequestSize(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 23 with RawSpan

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

the class MigrationTestRpc method testGrpcFieldsConverterEnvoyRequestAndResponseSizeHigherPriority.

@Test
public void testGrpcFieldsConverterEnvoyRequestAndResponseSizeHigherPriority() throws Exception {
    Map<String, String> tagsMap = Map.of(RawSpanConstants.getValue(GRPC_REQUEST_BODY), "some grpc request body", RawSpanConstants.getValue(GRPC_RESPONSE_BODY), "some grpc response body", RawSpanConstants.getValue(ENVOY_REQUEST_SIZE), "200", RawSpanConstants.getValue(ENVOY_RESPONSE_SIZE), "400");
    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().getGrpc());
    assertEquals(400, RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get());
    assertEquals(200, RpcSemanticConventionUtils.getGrpcRequestSize(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)

Example 24 with RawSpan

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

the class MigrationTestRpc method testGrpcFieldsConverterStatusMessagePriority.

@ParameterizedTest
@MethodSource("provideArgumentsForTestingGrpcFieldsConverterStatusMessagePriority")
public void testGrpcFieldsConverterStatusMessagePriority(Map<String, String> tagsMap, String statusMessage) 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().getGrpc());
    assertEquals(statusMessage, RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent()));
}
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 25 with RawSpan

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

the class AbstractAttributeEnricherTest method getBigTrace.

protected StructuredTrace getBigTrace() {
    /*
     * The graph looks like
     *             0 (proxy/entry)
     *             |
     *             1 (i)
     *           /    \
     *          2 (i)  3 (i)
     *          |
     *          4 (proxy/exit)
     *
     * i -> intermediate span
     */
    // 0th raw span
    Map<String, AttributeValue> entrySpanProxyMap = new HashMap<>();
    entrySpanProxyMap.put(Constants.getEnrichedSpanConstant(SPAN_TYPE), AttributeValue.newBuilder().setValue("ENTRY").build());
    entrySpanProxyMap.put(Constants.getEnrichedSpanConstant(Api.API_BOUNDARY_TYPE), AttributeValue.newBuilder().setValue("ENTRY").build());
    entrySpanProxyMap.put(Constants.getRawSpanConstant(TRACER_TYPE), AttributeValue.newBuilder().setValue(PROXY_TRACER).build());
    entrySpanProxyMap.put(Constants.getRawSpanConstant(Docker.DOCKER_CONTAINER_ID), AttributeValue.newBuilder().setValue("container1").build());
    Map<String, AttributeValue> enrichedEntrySpanProxyMap = new HashMap<>();
    enrichedEntrySpanProxyMap.put(Constants.getEntityConstant(ServiceAttribute.SERVICE_ATTRIBUTE_ID), AttributeValue.newBuilder().setValue(COMMON_ENTITY_ID).build());
    enrichedEntrySpanProxyMap.put(Constants.getEntityConstant(ServiceAttribute.SERVICE_ATTRIBUTE_NAME), AttributeValue.newBuilder().setValue(COMMON_ENTITY_NAME).build());
    Event event0 = Event.newBuilder().setCustomerId(TENANT_ID).setAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(entrySpanProxyMap).build()).setEnrichedAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(enrichedEntrySpanProxyMap).build()).setEventId(createByteBuffer("event0")).build();
    RawSpan rawSpan0 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event0).setTraceId(createByteBuffer("trace")).build();
    // 1st raw span CHILD_OF event0
    EventRef eventRef0 = EventRef.newBuilder().setRefType(EventRefType.CHILD_OF).setTraceId(createByteBuffer("trace")).setEventId(createByteBuffer("event0")).build();
    Map<String, AttributeValue> event1EnrichedMap = new HashMap<>();
    event1EnrichedMap.put(Constants.getRawSpanConstant(TRACER_TYPE), AttributeValue.newBuilder().setValue(JAVA_TRACER).build());
    event1EnrichedMap.put(Constants.getEnrichedSpanConstant(SPAN_TYPE), AttributeValue.newBuilder().setValue("ENTRY").build());
    event1EnrichedMap.put(Constants.getRawSpanConstant(Docker.DOCKER_CONTAINER_ID), AttributeValue.newBuilder().setValue("agentContainerId").build());
    Event event1 = Event.newBuilder().setCustomerId(TENANT_ID).setEventId(createByteBuffer("event1")).setEventRefList(Collections.singletonList(eventRef0)).setEnrichedAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(event1EnrichedMap).build()).build();
    RawSpan rawSpan1 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event1).setTraceId(createByteBuffer("trace")).build();
    // 2nd raw span CHILD_OF event1
    EventRef eventRef1 = EventRef.newBuilder().setRefType(EventRefType.CHILD_OF).setTraceId(createByteBuffer("trace")).setEventId(createByteBuffer("event1")).build();
    Map<String, AttributeValue> event2EnrichedMap = new HashMap<>();
    event2EnrichedMap.put(Constants.getRawSpanConstant(TRACER_TYPE), AttributeValue.newBuilder().setValue(JAVA_TRACER).build());
    event2EnrichedMap.put(Constants.getEnrichedSpanConstant(SPAN_TYPE), AttributeValue.newBuilder().setValue("EXIT").build());
    event2EnrichedMap.put(Constants.getRawSpanConstant(Docker.DOCKER_CONTAINER_ID), AttributeValue.newBuilder().setValue("agentContainerId").build());
    Event event2 = Event.newBuilder().setCustomerId(TENANT_ID).setEventId(createByteBuffer("event2")).setEnrichedAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(event2EnrichedMap).build()).setEventRefList(Collections.singletonList(eventRef1)).build();
    RawSpan rawSpan2 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event2).setTraceId(createByteBuffer("trace")).build();
    // 3nd raw span CHILD_OF event1
    Event event3 = Event.newBuilder().setCustomerId(TENANT_ID).setEventId(createByteBuffer("event3")).setEventRefList(Collections.singletonList(eventRef1)).build();
    RawSpan rawSpan3 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event3).setTraceId(createByteBuffer("trace")).build();
    // 4th raw span CHILD_OF event2
    EventRef eventRef2 = EventRef.newBuilder().setRefType(EventRefType.CHILD_OF).setTraceId(createByteBuffer("trace")).setEventId(createByteBuffer("event2")).build();
    Map<String, AttributeValue> exitSpanProxyMap = new HashMap<>();
    exitSpanProxyMap.put(Constants.getRawSpanConstant(TRACER_TYPE), AttributeValue.newBuilder().setValue(PROXY_TRACER).build());
    exitSpanProxyMap.put(Constants.getRawSpanConstant(Docker.DOCKER_CONTAINER_ID), AttributeValue.newBuilder().setValue("container1").build());
    Map<String, AttributeValue> exitSpanProxyEnrichedMap = new HashMap<>();
    exitSpanProxyEnrichedMap.put(Constants.getEnrichedSpanConstant(SPAN_TYPE), AttributeValue.newBuilder().setValue("EXIT").build());
    exitSpanProxyEnrichedMap.put(Constants.getEnrichedSpanConstant(Api.API_BOUNDARY_TYPE), AttributeValue.newBuilder().setValue("EXIT").build());
    exitSpanProxyEnrichedMap.put(Constants.getEntityConstant(ServiceAttribute.SERVICE_ATTRIBUTE_ID), AttributeValue.newBuilder().setValue(COMMON_ENTITY_ID).build());
    exitSpanProxyEnrichedMap.put(Constants.getEntityConstant(ServiceAttribute.SERVICE_ATTRIBUTE_NAME), AttributeValue.newBuilder().setValue(COMMON_ENTITY_NAME).build());
    Event event4 = Event.newBuilder().setCustomerId(TENANT_ID).setEventId(createByteBuffer("event4")).setAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(exitSpanProxyMap).build()).setEnrichedAttributes(org.hypertrace.core.datamodel.Attributes.newBuilder().setAttributeMap(exitSpanProxyEnrichedMap).build()).setEventRefList(Collections.singletonList(eventRef2)).build();
    RawSpan rawSpan4 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event4).setTraceId(createByteBuffer("trace")).build();
    return StructuredTraceBuilder.buildStructuredTraceFromRawSpans(List.of(rawSpan0, rawSpan1, rawSpan2, rawSpan3, rawSpan4), createByteBuffer("trace"), TENANT_ID);
}
Also used : AttributeValue(org.hypertrace.core.datamodel.AttributeValue) EventRef(org.hypertrace.core.datamodel.EventRef) HashMap(java.util.HashMap) Event(org.hypertrace.core.datamodel.Event) RawSpan(org.hypertrace.core.datamodel.RawSpan)

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