use of org.hypertrace.traceenricher.enrichedspan.constants.v1.Backend in project hypertrace-ingester by hypertrace.
the class AbstractBackendEntityEnricher method enrichTrace.
// At trace level, based on the next span to identify if a backend entity is actually a service
// entity.
@Override
public void enrichTrace(StructuredTrace trace) {
try {
StructuredTraceGraph structuredTraceGraph = buildGraph(trace);
trace.getEventList().stream().filter(event -> EnrichedSpanUtils.isExitSpan(event) && SpanAttributeUtils.isLeafSpan(structuredTraceGraph, event) && canResolveBackend(structuredTraceGraph, event)).map(event -> Pair.of(event, resolve(event, trace, structuredTraceGraph))).filter(pair -> pair.getRight().isPresent()).filter(pair -> isValidBackendEntity(trace, pair.getLeft(), pair.getRight().get())).forEach(pair -> decorateWithBackendEntity(pair.getRight().get(), pair.getLeft(), trace));
} catch (Exception ex) {
LOGGER.error("An error occurred while enriching backend", ex);
}
}
use of org.hypertrace.traceenricher.enrichedspan.constants.v1.Backend in project hypertrace-ingester by hypertrace.
the class ServiceCallViewGenerator method getServiceCallFromSingleExitEvent.
private ServiceCallView getServiceCallFromSingleExitEvent(StructuredTrace trace, Event event) {
ServiceCallView.Builder builder = createAndInitializeBuilder(trace);
buildCommonServiceCallView(event, builder);
Protocol protocol = EnrichedSpanUtils.getProtocol(event);
buildExitSpanView(event, builder);
// If the call was made into a backend, populate Backend specific data on the view.
if (event.getEnrichedAttributes().getAttributeMap().containsKey(EntityConstants.getValue(BackendAttribute.BACKEND_ATTRIBUTE_ID))) {
buildExitSpanViewForBackendEntity(event, builder, protocol);
}
return builder.build();
}
use of org.hypertrace.traceenricher.enrichedspan.constants.v1.Backend in project hypertrace-ingester by hypertrace.
the class SpanTypeAttributeEnricher method enrichEvent.
@Override
public void enrichEvent(StructuredTrace trace, Event event) {
if (event.getAttributes() == null) {
return;
}
Map<String, AttributeValue> attributeMap = event.getAttributes().getAttributeMap();
if (attributeMap == null) {
return;
}
// Figure out if event is entry or exit based on other span attributes
Boolean isEntry = null;
if (attributeMap.containsKey(OTEL_SPAN_KIND)) {
String spanKindValue = attributeMap.get(OTEL_SPAN_KIND).getValue();
if (spanKindValue.equalsIgnoreCase(OTEL_SPAN_KIND_SERVER_VALUE) || spanKindValue.equalsIgnoreCase(OtelMessagingSemanticConventions.CONSUMER.getValue())) {
isEntry = true;
} else if (spanKindValue.equalsIgnoreCase(OTEL_SPAN_KIND_CLIENT_CLIENT) || spanKindValue.equalsIgnoreCase(OtelMessagingSemanticConventions.PRODUCER.getValue())) {
isEntry = false;
} else {
LOGGER.debug("Unrecognized span_kind value: {}. Event: {}.", spanKindValue, event);
}
} else if (attributeMap.containsKey(SPAN_KIND_KEY)) {
String spanKindValue = attributeMap.get(SPAN_KIND_KEY).getValue();
if (spanKindValue.equalsIgnoreCase(SERVER_VALUE) || spanKindValue.equalsIgnoreCase(OtelMessagingSemanticConventions.CONSUMER.getValue())) {
isEntry = true;
} else if (spanKindValue.equalsIgnoreCase(CLIENT_VALUE) || spanKindValue.equalsIgnoreCase(OtelMessagingSemanticConventions.PRODUCER.getValue())) {
isEntry = false;
} else {
LOGGER.debug("Unrecognized span.kind value: {}. Event: {}.", spanKindValue, event);
}
} else if (attributeMap.containsKey(CLIENT_KEY)) {
String clientValue = attributeMap.get(CLIENT_KEY).getValue();
if (clientValue.equalsIgnoreCase("false")) {
isEntry = true;
} else if (clientValue.equalsIgnoreCase("true")) {
isEntry = false;
} else {
LOGGER.debug("Unrecognized Client value: {}. Event: {}.", clientValue, event);
}
} else if (attributeMap.containsKey(envoyOperationNameAttr)) {
String spanType = attributeMap.get(envoyOperationNameAttr).getValue();
if (StringUtils.equalsIgnoreCase(envoyIngressSpanValue, spanType)) {
isEntry = true;
} else if (StringUtils.equalsIgnoreCase(envoyEgressSpanValue, spanType)) {
isEntry = false;
} else {
LOGGER.debug("Unrecognized envoyOperationNameAttr value: {}. Event: {}.", spanType, event);
}
} else if (StringUtils.startsWith(event.getEventName(), RawSpanConstants.getValue(SpanNamePrefix.SPAN_NAME_PREFIX_SENT))) {
// Go Opencensus instrumentation seems to have this convention Sent. prefix
// meaning client/exit/backend call
isEntry = false;
} else if (StringUtils.startsWith(event.getEventName(), RawSpanConstants.getValue(SpanNamePrefix.SPAN_NAME_PREFIX_RECV))) {
isEntry = true;
}
// Add the new information as an enriched attribute, not raw attribute.
if (isEntry == null) {
addEnrichedAttribute(event, spanTypeAttrName, AttributeValueCreator.create(Constants.getEnrichedSpanConstant(BoundaryTypeValue.BOUNDARY_TYPE_VALUE_UNSPECIFIED)));
} else if (isEntry) {
addEnrichedAttribute(event, spanTypeAttrName, AttributeValueCreator.create(Constants.getEnrichedSpanConstant(BoundaryTypeValue.BOUNDARY_TYPE_VALUE_ENTRY)));
} else {
addEnrichedAttribute(event, spanTypeAttrName, AttributeValueCreator.create(Constants.getEnrichedSpanConstant(BoundaryTypeValue.BOUNDARY_TYPE_VALUE_EXIT)));
}
// Get the protocol and name and create API entity based on the protocol.
Protocol protocol = getProtocolName(event);
addEnrichedAttribute(event, PROTOCOL_ATTR, AttributeValueCreator.create(Constants.getEnrichedSpanConstant(protocol)));
}
Aggregations