Skip to content
This repository has been archived by the owner on Mar 29, 2020. It is now read-only.

Kamon Operation Name Mapping cannot be configured #72

Closed
danischroeter opened this issue Dec 6, 2019 · 2 comments · Fixed by kamon-io/Kamon#624
Closed

Kamon Operation Name Mapping cannot be configured #72

danischroeter opened this issue Dec 6, 2019 · 2 comments · Fixed by kamon-io/Kamon#624

Comments

@danischroeter
Copy link

I tried to use the new glob replace feature but I cannot make it work. I tried it in the modules tests but the tests fail.

To reproduce:
Apply the example configuration so it's used in tests:

diff --git a/kamon-akka-http/src/test/resources/application.conf b/kamon-akka-http/src/test/resources/application.conf
index 51f62a4..0d796a6 100644
--- a/kamon-akka-http/src/test/resources/application.conf
+++ b/kamon-akka-http/src/test/resources/application.conf
@@ -1,5 +1,42 @@
 kamon {
   trace.sampler = "always"
+
+
+  instrumentation.akka.http {
+    server {
+      tracing {
+        operations {
+
+          # The default operation name to be used when creating Spans to handle the HTTP server requests. In most
+          # cases it is not possible to define an operation name right at the moment of starting the HTTP server Span
+          # and in those cases, this operation name will be initially assigned to the Span. Instrumentation authors
+          # should do their best effort to provide a suitable operation name or make use of the "mappings" facilities.
+          #default = "http.server.request"
+
+          # Provides custom mappings from HTTP paths into operation names. Meant to be used in cases where the bytecode
+          # instrumentation is not able to provide a sensible operation name that is free of high cardinality values.
+          # For example, with the following configuration:
+          #   mappings {
+          #     "/organization/*/user/*/profile" = "/organization/:orgID/user/:userID/profile"
+          #     "/events/*/rsvps" = "EventRSVPs"
+          #   }
+          #
+          # Requests to "/organization/3651/user/39652/profile" and "/organization/22234/user/54543/profile" will have
+          # the same operation name "/organization/:orgID/user/:userID/profile".
+          #
+          # Similarly, requests to "/events/aaa-bb-ccc/rsvps" and "/events/1234/rsvps" will have the same operation
+          # name "EventRSVPs".
+          #
+          # The patterns are expressed as globs and the operation names are free form.
+          #
+          mappings {
+            "/organization/*/user/*/profile" = "/organization/:orgID/user/:userID/profile"
+            "/events/*/rsvps" = "EventRSVPs"
+          }
+        }
+      }
+    }
+  }
 }

The config tests fail with:

[info] ServerFlowWrapperSpec:
[info] the server flow wrapper
[info] - should keep strict entities strict *** FAILED ***
[info]   com.typesafe.config.ConfigException$BadPath: path parameter: Invalid path '/events/*/rsvps': Token not allowed in path expression: '*' (Reserved character '*' is not allowed outside quotes) (you can double-quote this token if you really want it here)
[info]   at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:155)
[info]   at com.typesafe.config.impl.PathParser.parsePathExpression(PathParser.java:74)
[info]   at com.typesafe.config.impl.PathParser.parsePath(PathParser.java:61)
[info]   at com.typesafe.config.impl.Path.newPath(Path.java:230)
[info]   at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:192)
[info]   at com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:250)
[info]   at kamon.package$UtilsOnConfig$.$anonfun$pairs$1(package.scala:97)
[info]   at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100)
[info]   at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87)
[info]   at scala.collection.immutable.Set$Set2.map(Set.scala:159)
[info]   ...

@danischroeter
Copy link
Author

basically the config is valid and can be used. With above config:

val config = ConfigFactory.load()
      import scala.collection.JavaConverters._
      println(config.getConfig("kamon.instrumentation.akka.http.server.tracing.operations.mappings").entrySet().asScala.map(_.getKey))

will produce

HashSet("/organization/*/user/*/profile", "/events/*/rsvps")

@danischroeter
Copy link
Author

The alternative (imho better since more flexible way) as a workaround that we had in 1.x is still missing in 2.x https://github.com/kamon-io/kamon-instrumentation-common/issues/2

mladens added a commit to mladens/Kamon that referenced this issue Dec 6, 2019
Extract key-value pairs directly from config set. Extracting topLevelKeys
and then fetching values by key will explode in cases where key is not
a valid `com.typesafe.config.impl.Path` (globs)
Fixes kamon-io/kamon-akka-http#72
ivantopo pushed a commit to kamon-io/Kamon that referenced this issue Dec 12, 2019
Extract key-value pairs directly from config set. Extracting topLevelKeys
and then fetching values by key will explode in cases where key is not
a valid `com.typesafe.config.impl.Path` (globs)
Fixes kamon-io/kamon-akka-http#72
ivantopo pushed a commit to kamon-io/Kamon that referenced this issue Dec 12, 2019
* Config utils pairs fix

Extract key-value pairs directly from config set. Extracting topLevelKeys
and then fetching values by key will explode in cases where key is not
a valid `com.typesafe.config.impl.Path` (globs)
Fixes kamon-io/kamon-akka-http#72

* use throwable message for error.message for spans failed with a throwable
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant