-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ adds configurable operation name mappings for http client instrumen…
…tation
- Loading branch information
1 parent
e94625a
commit 7a14929
Showing
9 changed files
with
105 additions
and
25 deletions.
There are no files selected for viewing
4 changes: 1 addition & 3 deletions
4
...on-akka-http/src/main/scala/kamon/instrumentation/akka/http/AkkaHttpInstrumentation.scala
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
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
21 changes: 21 additions & 0 deletions
21
...nstrumentation-common/src/main/scala/kamon/instrumentation/http/HttpInstrumentation.scala
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,21 @@ | ||
package kamon.instrumentation.http | ||
|
||
import kamon.util.Filter | ||
|
||
object HttpInstrumentation { | ||
|
||
final case class OperationNameSettings(defaultOperationName: String, | ||
operationMappings: Map[Filter.Glob, String], | ||
operationNameGenerator: HttpOperationNameGenerator) | ||
|
||
private[http] def operationName(settings: OperationNameSettings, request: HttpMessage.Request): String = { | ||
val requestPath = request.path | ||
//first apply any mappings rules | ||
val customMapping = settings.operationMappings.collectFirst { | ||
case (pattern, operationName) if pattern.accept(requestPath) => operationName | ||
}.orElse( //fallback to use any configured name generator | ||
settings.operationNameGenerator.name(request) | ||
) | ||
customMapping.getOrElse(settings.defaultOperationName) | ||
} | ||
} |
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