Repository: ktorio/ktor
File: ktor-server/ktor-server-plugins/ktor-server-metrics-micrometer/jvm/src/io/ktor/server/metrics/micrometer/MicrometerMetrics.kt (Kotlin)

Code before:

    internal var transformRoute: RoutingNode.() -> String = { path }

    /**
     * Configures mapping function for the route label string of the [CallMeasure].
     * Defaults to [RoutingNode.path].
     *
     * **Examples:**
     *
     * Use the toString() function of the RoutingNode:
     * ```kotlin
     * transformRoute {
     *    toString()
     * }
     * ```
     *
     * Remove a prefix from the path:
     * ```kotlin
     * transformRoute {
     *     path.removePrefix("/path/prefix")
     * }
     * ```
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.metrics.micrometer.MicrometerMetricsConfig.transformRoute)
     */
    public fun transformRoute(block : RoutingNode.() -> String) {
        transformRoute = block
    }
}

/**
 * A plugin that enables Micrometer metrics in your Ktor server application and
 * allows you to choose the required monitoring system, such as Prometheus, JMX, Elastic, and so on.
 * By default, Ktor exposes metrics for monitoring HTTP requests and a set of low-level metrics for monitoring the JVM.
 * You can customize these metrics or create new ones.
 *
 * You can learn more from [Micrometer metrics](https://ktor.io/docs/micrometer-metrics.html).
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.metrics.micrometer.MicrometerMetrics)
 */
public val MicrometerMetrics: ApplicationPlugin<MicrometerMetricsConfig> =
    createApplicationPlugin("MicrometerMetrics", ::MicrometerMetricsConfig) {

        if (pluginConfig.metricName.isBlank()) {
            throw IllegalArgumentException("Metric name should be defined")
        }

        val metricName = pluginConfig.metricName
        val activeRequestsGaugeName = "$metricName.active"
        val registry = pluginConfig.registry


Review comment (suggestion):
I'd make `RoutingNode` a parameter as it is a common pattern for transforming functions.
```suggestion
    public fun transformRoute(block: (RoutingNode) -> String) {
```

Code after:

    internal var transformRoute: (RoutingNode) -> String = { it.path }

    /**
     * Configures mapping function for the route label string of the [CallMeasure].
     * Defaults to [RoutingNode.path].
     *
     * **Examples:**
     *
     * Use the toString() function of the RoutingNode:
     * ```kotlin
     * transformRoute {
     *    it.toString()
     * }
     * ```
     *
     * Remove a prefix from the path:
     * ```kotlin
     * transformRoute {
     *     it.path.removePrefix("/path/prefix")
     * }
     * ```
     *
     * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.metrics.micrometer.MicrometerMetricsConfig.transformRoute)
     */
    public fun transformRoute(block: (RoutingNode) -> String) {
        transformRoute = block
    }
}

/**
 * A plugin that enables Micrometer metrics in your Ktor server application and
 * allows you to choose the required monitoring system, such as Prometheus, JMX, Elastic, and so on.
 * By default, Ktor exposes metrics for monitoring HTTP requests and a set of low-level metrics for monitoring the JVM.
 * You can customize these metrics or create new ones.
 *
 * You can learn more from [Micrometer metrics](https://ktor.io/docs/micrometer-metrics.html).
 *
 * [Report a problem](https://ktor.io/feedback/?fqname=io.ktor.server.metrics.micrometer.MicrometerMetrics)
 */
public val MicrometerMetrics: ApplicationPlugin<MicrometerMetricsConfig> =
    createApplicationPlugin("MicrometerMetrics", ::MicrometerMetricsConfig) {

        if (pluginConfig.metricName.isBlank()) {
            throw IllegalArgumentException("Metric name should be defined")
        }

        val metricName = pluginConfig.metricName
        val activeRequestsGaugeName = "$metricName.active"
        val registry = pluginConfig.registry