Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hypertrace.semantic.convention.utils.rpc;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.hypertrace.core.datamodel.shared.SpanAttributeUtils.getStringAttribute;
import static org.hypertrace.core.span.constants.v1.CensusResponse.CENSUS_RESPONSE_STATUS_MESSAGE;
import static org.hypertrace.core.span.constants.v1.Envoy.ENVOY_GRPC_STATUS_MESSAGE;
import static org.hypertrace.core.span.constants.v1.Envoy.ENVOY_REQUEST_SIZE;
Expand Down Expand Up @@ -131,7 +132,7 @@ public class RpcSemanticConventionUtils {
*/
public static Optional<String> getGrpcURL(Event event) {
if (SpanAttributeUtils.containsAttributeKey(event, OTHER_GRPC_HOST_PORT)) {
return Optional.of(SpanAttributeUtils.getStringAttribute(event, OTHER_GRPC_HOST_PORT));
return Optional.of(getStringAttribute(event, OTHER_GRPC_HOST_PORT));
}
// look for grpc authority
Optional<String> grpcAuthority = getSanitizedGrpcAuthority(event);
Expand Down Expand Up @@ -218,7 +219,7 @@ public static boolean isRpcTypeGrpcForOTelFormat(Map<String, AttributeValue> val
*/
public static Optional<String> getGrpcURI(Event event) {
if (SpanAttributeUtils.containsAttributeKey(event, OTHER_GRPC_HOST_PORT)) {
return Optional.of(SpanAttributeUtils.getStringAttribute(event, OTHER_GRPC_HOST_PORT));
return Optional.of(getStringAttribute(event, OTHER_GRPC_HOST_PORT));
} else if (isRpcTypeGrpcForOTelFormat(event)) {
return SpanSemanticConventionUtils.getURIForOtelFormat(event);
}
Expand Down Expand Up @@ -530,10 +531,9 @@ public static Optional<String> getGrpcRequestEndpoint(Event event) {
return sanitizePath(attributeValue.get().getValue());
}

attributeValue =
Optional.ofNullable(attributeValueMap.get(RawSpanConstants.getValue(GRPC_PATH)));
if (attributeValue.isPresent() && StringUtils.isNotBlank(attributeValue.get().getValue())) {
return sanitizePath(attributeValue.get().getValue());
Optional<String> maybeGrpcPath = getGrpcPath(event);
if (maybeGrpcPath.isPresent()) {
return sanitizePath(maybeGrpcPath.get());
}

return Optional.ofNullable(event.getEventName());
Expand Down Expand Up @@ -573,6 +573,15 @@ public static Optional<String> getRpcPath(Event event) {
return Optional.empty();
}

public static Optional<String> getGrpcPath(Event event) {
String grpcPath = getStringAttribute(event, RawSpanConstants.getValue(GRPC_PATH));
if (grpcPath != null && !grpcPath.isBlank()) {
return Optional.of(grpcPath);
}

return Optional.empty();
}

static Optional<String> getSanitizedGrpcAuthority(Event event) {

Optional<String> grpcAuthority = getGrpcAuthority(event);
Expand All @@ -581,8 +590,7 @@ static Optional<String> getSanitizedGrpcAuthority(Event event) {
} else if (SpanAttributeUtils.containsAttributeKey(
event, RawSpanConstants.getValue(Envoy.ENVOY_GRPC_AUTHORITY))) {
return getSanitizedAuthorityValue(
SpanAttributeUtils.getStringAttribute(
event, RawSpanConstants.getValue(Envoy.ENVOY_GRPC_AUTHORITY)));
getStringAttribute(event, RawSpanConstants.getValue(Envoy.ENVOY_GRPC_AUTHORITY)));
}
return Optional.empty();
}
Expand Down