-
Notifications
You must be signed in to change notification settings - Fork 870
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce overhead of unsampled requests (#3681)
* Optimize sampled out requests * Comment
- Loading branch information
Showing
5 changed files
with
63 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
.../main/java/io/opentelemetry/javaagent/instrumentation/springwebmvc/ServerNameUpdater.java
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...io/opentelemetry/javaagent/instrumentation/springwebmvc/SpringWebMvcServerSpanNaming.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.springwebmvc; | ||
|
||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath; | ||
import java.util.function.Supplier; | ||
import javax.servlet.http.HttpServletRequest; | ||
import org.springframework.web.servlet.HandlerMapping; | ||
|
||
public class SpringWebMvcServerSpanNaming { | ||
|
||
public static Supplier<String> getServerSpanNameSupplier( | ||
Context context, HttpServletRequest request) { | ||
return () -> getServerSpanName(context, request); | ||
} | ||
|
||
public static String getServerSpanName(Context context, HttpServletRequest request) { | ||
Object bestMatchingPattern = | ||
request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); | ||
if (bestMatchingPattern != null) { | ||
return ServletContextPath.prepend(context, bestMatchingPattern.toString()); | ||
} | ||
return null; | ||
} | ||
} |