diff --git a/ktor-features/ktor-metrics/build.gradle b/ktor-features/ktor-metrics/build.gradle index eeaed058f..d9367e9e5 100644 --- a/ktor-features/ktor-metrics/build.gradle +++ b/ktor-features/ktor-metrics/build.gradle @@ -3,8 +3,8 @@ kotlin { sourceSets { jvmMain { dependencies { - api group: 'io.dropwizard.metrics', name: 'metrics-core', version: '3.2.4' - api group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: '3.2.4' + api group: 'io.dropwizard.metrics', name: 'metrics-core', version: '4.1.0' + api group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: '4.1.0' } } } diff --git a/ktor-features/ktor-metrics/jvm/test/io/ktor/metrics/dropwizard/DropwizardMetricsTests.kt b/ktor-features/ktor-metrics/jvm/test/io/ktor/metrics/dropwizard/DropwizardMetricsTests.kt new file mode 100644 index 000000000..1f18c1e66 --- /dev/null +++ b/ktor-features/ktor-metrics/jvm/test/io/ktor/metrics/dropwizard/DropwizardMetricsTests.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2014-2019 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package io.ktor.metrics.dropwizard + +import com.codahale.metrics.* +import io.ktor.application.* +import io.ktor.response.* +import io.ktor.routing.* +import io.ktor.server.testing.* +import org.junit.* +import org.junit.Assert.* + + +class DropwizardMetricsTests { + + @Test + fun `meter is registered for a given path`(): Unit = withTestApplication { + val testRegistry = MetricRegistry() + + application.install(DropwizardMetrics) { + registry = testRegistry + } + + application.routing { + get("/uri") { + call.respond("hello") + } + } + + handleRequest { + uri = "/uri" + } + + assertEquals(1, testRegistry.meter("/uri/(method:GET).200").count) + } +}