use of org.hypertrace.core.datamodel.EventRef in project hypertrace-ingester by hypertrace.
the class EndpointEnricherTest method getBigTrace.
protected StructuredTrace getBigTrace() {
/*
* The graph looks like
* 0 (entry)
* |
* 1 (intermediate)
* ------------|-------------------
* 2 (exit)
*/
// 0th raw span
Map<String, AttributeValue> entrySpan0Map = new HashMap<>();
entrySpan0Map.put(EnrichedSpanConstants.getValue(Http.HTTP_REQUEST_URL), AttributeValue.newBuilder().setValue("http://someservice.ai/users/1/checkout").build());
Map<String, AttributeValue> enrichedEntrySpan0Map = new HashMap<>();
enrichedEntrySpan0Map.put(EnrichedSpanConstants.getValue(Api.API_BOUNDARY_TYPE), AttributeValue.newBuilder().setValue("ENTRY").build());
enrichedEntrySpan0Map.put(EntityConstants.getValue(ServiceAttribute.SERVICE_ATTRIBUTE_ID), AttributeValue.newBuilder().setValue(SERVICE_ID).build());
enrichedEntrySpan0Map.put(EntityConstants.getValue(ServiceAttribute.SERVICE_ATTRIBUTE_NAME), AttributeValue.newBuilder().setValue(SERVICE_NAME).build());
enrichedEntrySpan0Map.put(EntityConstants.getValue(ApiAttribute.API_ATTRIBUTE_ID), AttributeValue.newBuilder().setValue(API_ID).build());
enrichedEntrySpan0Map.put(EntityConstants.getValue(ApiAttribute.API_ATTRIBUTE_URL_PATTERN), AttributeValue.newBuilder().setValue(API_PATTERN_VAL).build());
enrichedEntrySpan0Map.put(EntityConstants.getValue(ApiAttribute.API_ATTRIBUTE_NAME), AttributeValue.newBuilder().setValue(API_NAME_VAL).build());
Event event0 = Event.newBuilder().setCustomerId(TENANT_ID).setAttributes(Attributes.newBuilder().setAttributeMap(entrySpan0Map).build()).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(enrichedEntrySpan0Map).build()).setEventId(createByteBuffer("event0")).setEventName(API_PATTERN_VAL).build();
RawSpan rawSpan0 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event0).setTraceId(createByteBuffer("trace")).build();
// 1st intermediate raw span
EventRef eventRef0 = EventRef.newBuilder().setRefType(EventRefType.CHILD_OF).setTraceId(createByteBuffer("trace")).setEventId(createByteBuffer("event0")).build();
Map<String, AttributeValue> exitSpanMap = new HashMap<>();
Map<String, AttributeValue> enrichedExitSpanMap = new HashMap<>();
Event event1 = Event.newBuilder().setCustomerId(TENANT_ID).setEventId(createByteBuffer("event1")).setAttributes(Attributes.newBuilder().setAttributeMap(exitSpanMap).build()).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(enrichedExitSpanMap).build()).setEventRefList(Collections.singletonList(eventRef0)).build();
RawSpan rawSpan1 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event1).setTraceId(createByteBuffer("trace")).build();
// 2nd exit raw span
EventRef eventRef1 = EventRef.newBuilder().setRefType(EventRefType.CHILD_OF).setTraceId(createByteBuffer("trace")).setEventId(createByteBuffer("event1")).build();
Map<String, AttributeValue> entrySpan2Map = new HashMap<>();
entrySpan2Map.put(EnrichedSpanConstants.getValue(Http.HTTP_REQUEST_URL), AttributeValue.newBuilder().setValue("http://nextservice.ai/login").build());
Map<String, AttributeValue> enrichedEntrySpan2Map = new HashMap<>();
enrichedEntrySpan2Map.put(EnrichedSpanConstants.getValue(Api.API_BOUNDARY_TYPE), AttributeValue.newBuilder().setValue("EXIT").build());
Event event2 = Event.newBuilder().setCustomerId(TENANT_ID).setAttributes(Attributes.newBuilder().setAttributeMap(entrySpan2Map).build()).setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(enrichedEntrySpan2Map).build()).setEventId(createByteBuffer("event2")).setEventRefList(Collections.singletonList(eventRef1)).build();
RawSpan rawSpan2 = RawSpan.newBuilder().setCustomerId(TENANT_ID).setEvent(event2).setTraceId(createByteBuffer("trace")).build();
return StructuredTraceBuilder.buildStructuredTraceFromRawSpans(List.of(rawSpan0, rawSpan1, rawSpan2), createByteBuffer("trace"), TENANT_ID);
}
use of org.hypertrace.core.datamodel.EventRef 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