Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added request uri as the operation name of the spam #260

Merged
merged 1 commit into from
Dec 11, 2023
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
Expand Up @@ -72,7 +72,7 @@ public static Scope extractCurrentSpan(HttpServletRequest request) {
for (String headerName : Collections.list(request.getHeaderNames())) {
headers.put(headerName, request.getHeader(headerName));
}
return buildSpanFromHeaders(headers);
return buildSpanFromHeaders(headers, request.getRequestURI());
}

/**
Expand All @@ -89,22 +89,23 @@ public static Scope extractCurrentSpan(HttpHeaders httpHeaders) {
for (String headerName : httpHeaders.getRequestHeaders().keySet()) {
headers.put(headerName, httpHeaders.getRequestHeader(headerName).get(0));
}
return buildSpanFromHeaders(headers);
return buildSpanFromHeaders(headers, "op");
}

/**
* Helper method to extract and build the active span out of Map containing the
* processed headers.
*
* @param headers is the Map of the processed headers
* @param operationName is the operation name of the span (can be either URL or URI)
* @return Scope containing the extracted span marked as active. Can be used
* with try-with-resource construct
*/
private static Scope buildSpanFromHeaders(Map<String, String> headers) {
Tracer.SpanBuilder spanBuilder = GlobalTracer.get().buildSpan("op");
private static Scope buildSpanFromHeaders(Map<String, String> headers, String operationName) {
Tracer.SpanBuilder spanBuilder = GlobalTracer.get().buildSpan(operationName);
try {
SpanContext parentSpanCtx = GlobalTracer.get().extract(Format.Builtin.HTTP_HEADERS,
new TextMapExtractAdapter(headers));
new TextMapExtractAdapter(headers));
if (parentSpanCtx != null) {
spanBuilder = spanBuilder.asChildOf(parentSpanCtx);
}
Expand Down