Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
kailyak committed Apr 17, 2024
1 parent 1291438 commit e762f61
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ import io.micrometer.core.instrument.DistributionSummary
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.Tag
import io.micrometer.core.instrument.Timer
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.boot.actuate.metrics.AutoTimer
Expand All @@ -44,14 +52,6 @@ import java.util.Optional
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletionStage
import kotlin.jvm.optionals.getOrNull
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch

class DgsGraphQLMetricsInstrumentation(
private val schemaProvider: DgsSchemaProvider,
Expand Down Expand Up @@ -257,8 +257,10 @@ class DgsGraphQLMetricsInstrumentation(
)
}

private suspend fun captureGqlQueryRequestSizeMetric(executionInput: ExecutionInput,
state: MetricsInstrumentationState) = coroutineScope {
private suspend fun captureGqlQueryRequestSizeMetric(
executionInput: ExecutionInput,
state: MetricsInstrumentationState
) = coroutineScope {
val tags = buildList { addAll(state.tags()) }

val requestSizeMeter = DistributionSummary.builder(GqlMetric.QUERY_REQUEST_SIZE.key)
Expand All @@ -278,8 +280,11 @@ class DgsGraphQLMetricsInstrumentation(
}
}

private suspend fun captureGqlQueryResponseSizeMetric(executionResult: ExecutionResult, parameters: InstrumentationExecutionParameters,
state: MetricsInstrumentationState) = coroutineScope {
private suspend fun captureGqlQueryResponseSizeMetric(
executionResult: ExecutionResult,
parameters: InstrumentationExecutionParameters,
state: MetricsInstrumentationState
) = coroutineScope {
val tags = buildList {
addAll(state.tags())
addAll(tagsProvider.getExecutionTags(state, parameters, executionResult, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,10 @@ class MicrometerServletSmokeTest {

// Check metrics are present.
assertThat(meters).containsKeys(
"gql.query.request.size", "gql.query.request.size.percentile",
"gql.query.response.size", "gql.query.response.size.percentile"
"gql.query.request.size",
"gql.query.request.size.percentile",
"gql.query.response.size",
"gql.query.response.size.percentile"
)

// Check expected percentiles: .90, .95, .99
Expand Down Expand Up @@ -824,7 +826,7 @@ class MicrometerServletSmokeTest {
|{
| "errors":[
| {"message":"Exception triggered.",
| "locations":[],"path":["triggerBadRequestFailure"],
| "path":["triggerBadRequestFailure"],
| "extensions":{"errorType":"BAD_REQUEST"}}
| ],
| "data":{"triggerBadRequestFailure":null}
Expand All @@ -838,8 +840,10 @@ class MicrometerServletSmokeTest {

// Check metrics are present.
assertThat(meters).containsKeys(
"gql.query.request.size", "gql.query.request.size.percentile",
"gql.query.response.size", "gql.query.response.size.percentile"
"gql.query.request.size",
"gql.query.request.size.percentile",
"gql.query.response.size",
"gql.query.response.size.percentile"
)

// Check metric name and expected tags.
Expand Down

0 comments on commit e762f61

Please sign in to comment.