thanksforallthefish
04/08/2025, 12:38 PMprivate class EnhancedServerRequestObservationConvention(properties: ObservationProperties): ServerRequestObservationConvention {
private val delegate = DefaultServerRequestObservationConvention(properties.http.server.requests.name)
override fun getLowCardinalityKeyValues(context: ServerRequestObservationContext): KeyValues {
val eventId = context.pathPattern?.let { UriTemplate(it).match(context.carrier.requestURI)["eventId"] } ?: "none"
return delegate.getLowCardinalityKeyValues(context).and(KeyValue.of("eventId", eventId))
}
override fun supportsContext(context: Observation.Context): Boolean = delegate.supportsContext(context)
override fun getContextualName(context: ServerRequestObservationContext): String? = delegate.getContextualName(context)
override fun getName(): String? = delegate.name
override fun getHighCardinalityKeyValues(context: ServerRequestObservationContext): KeyValues =
delegate.getHighCardinalityKeyValues(context)
}
the interface provides 5 methods, and I only need to customize one of them, so it be nice to have private class EnhancedServerRequestObservationConvention(private val delegate: DefaultServerRequestObservationConvention) : ServerRequestObservationConvention by delegate
but alas cannot. I am wondering if other use cases (non spring server, eg android, other web framework) delegation as is is still somehow useful and if there is any desire to change that behavior, maybe in kotlin 3 or whateverthanksforallthefish
04/08/2025, 12:44 PMephemient
04/08/2025, 12:45 PMthanksforallthefish
04/08/2025, 12:45 PMthanksforallthefish
04/08/2025, 12:45 PM