Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sanket-mundra committed Jan 29, 2024
1 parent 131029f commit 02cbae2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static Optional<String> getFullHttpUrl(Event event) {
}

public static Optional<String> getDestinationIpAddress(Event event) {
return HttpSemanticConventionUtils.getPeerIpAddress(event);
return HttpSemanticConventionUtils.getDestinationIpAddress(event);
}

public static Optional<String> getPath(Event event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ public void process(Record<TraceIdentity, RawSpan> record) {
}

Event event = value.getEvent();
// spans whose trace is not created by ByPass flow, their trace will be created in below
// function call. Those spans' trace will not be created by TraceEmitPunctuator
if (isPeerServiceNameIdentificationRequired(event)) {
processSpanForPeerServiceNameIdentification(key, value, traceState, currentTimeMs);
return;
Expand Down Expand Up @@ -258,6 +260,7 @@ private void processSpanForPeerServiceNameIdentification(
handleServerSpan(tenantId, event, maybeEnvironment.orElse(null));
}

// create structured trace and forward
Timestamps timestamps =
traceLatencyMeter.trackEndToEndLatencyTimestamps(
currentTimeMs, firstEntry ? currentTimeMs : traceState.getTraceStartTimestamp());
Expand Down Expand Up @@ -289,7 +292,7 @@ private void handleClientSpan(String tenantId, Event event, String environment)
peerIdentity,
SpanMetadata.newBuilder()
.setServiceName(serviceName)
.setEventId(HexUtils.getHex(event.getEventId()))
.setEventId(event.getEventId())
.build());
}
}
Expand Down Expand Up @@ -317,7 +320,7 @@ private void handleServerSpan(String tenantId, Event event, String environment)
"Adding {} as: {} from spanId: {} in spanId: {} with service name: {}",
PEER_SERVICE_NAME,
spanMetadata.getServiceName(),
spanMetadata.getEventId(),
HexUtils.getHex(spanMetadata.getEventId()),
HexUtils.getHex(event.getEventId()),
event.getServiceName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ public static Optional<String> getFullHttpUrl(Event event) {
: getValidHttpUrl(event).map(AttributeValue::getValue);
}

public static Optional<String> getDestinationIpAddress(Event event) {
return Optional.ofNullable(
SpanAttributeUtils.getStringAttribute(
event, OTelSpanSemanticConventions.NET_SOCK_PEER_ADDR.getValue()))
.or(
() ->
Optional.ofNullable(
SpanAttributeUtils.getStringAttribute(
event, OTelSpanSemanticConventions.NET_PEER_IP.getValue())));
}

public static Optional<String> getPeerIpAddress(Event event) {
return Optional.ofNullable(
SpanAttributeUtils.getStringAttribute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
protocol SpanMetadataProtocol {
record SpanMetadata {
string service_name;
string event_id;
bytes event_id;
}
}

0 comments on commit 02cbae2

Please sign in to comment.