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()));
}
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());
}
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());
}
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()));
}
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);
}
Aggregations