fix(deps): update spotless packages to v7 (major) (#13004)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
This commit is contained in:
renovate[bot] 2025-01-08 07:37:47 -08:00 committed by GitHub
parent ae3f6ac481
commit c22bb598e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 387 additions and 479 deletions

View File

@ -1,6 +1,6 @@
plugins {
id("java")
id("com.diffplug.spotless") version "6.25.0"
id("com.diffplug.spotless") version "7.0.1"
}
spotless {

View File

@ -1,7 +1,7 @@
plugins {
`kotlin-dsl`
// When updating, update below in dependencies too
id("com.diffplug.spotless") version "6.25.0"
id("com.diffplug.spotless") version "7.0.1"
}
spotless {
@ -54,7 +54,7 @@ dependencies {
implementation("org.apache.maven:maven-aether-provider:3.3.9")
// When updating, update above in plugins too
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.1")
implementation("com.google.guava:guava:33.4.0-jre")
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")

View File

@ -76,7 +76,9 @@ spotless {
// also very hard to find out where this happens
"ktlint_standard_wrapping" to "disabled",
// we use variable names like v1_10Deps
"ktlint_standard_property-naming" to "disabled"
"ktlint_standard_property-naming" to "disabled",
// prevent moving comment to next line in latestDepTestLibrary("xxx") { // see xxx module
"ktlint_standard_function-literal" to "disabled"
)
)
}
@ -97,7 +99,7 @@ if (project == rootProject) {
"**/*.dockerfile",
"**/gradle.properties"
)
indentWithSpaces()
leadingTabsToSpaces()
trimTrailingWhitespace()
endWithNewline()
}

View File

@ -12,7 +12,7 @@ buildscript {
}
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.25.0"
classpath "com.diffplug.spotless:spotless-plugin-gradle:7.0.1"
classpath "com.gradleup.shadow:shadow-gradle-plugin:8.3.5"
classpath "io.opentelemetry.instrumentation:gradle-plugins:2.12.0-alpha-SNAPSHOT"
}

View File

@ -11,7 +11,7 @@ plugins {
See https://imperceptiblethoughts.com/shadow/ for more details about Shadow plugin.
*/
id "com.gradleup.shadow" version "8.3.5"
id "com.diffplug.spotless" version "6.25.0"
id "com.diffplug.spotless" version "7.0.1"
id "io.opentelemetry.instrumentation.muzzle-generation" version "2.12.0-alpha-SNAPSHOT"
id "io.opentelemetry.instrumentation.muzzle-check" version "2.12.0-alpha-SNAPSHOT"

View File

@ -25,9 +25,7 @@ val scalaMinor = Regex("""^([0-9]+\.[0-9]+)\.?.*$""").find(scalaVersion)!!.run {
minorVersion
}
val scalified = fun(pack: String): String {
return "${pack}_$scalaMinor"
}
val scalified = fun(pack: String): String = "${pack}_$scalaMinor"
dependencies {
bootstrap(project(":instrumentation:executors:bootstrap"))

View File

@ -71,7 +71,7 @@ class MetricRegistrar {
String unit = metricInfo.getUnit();
switch (instrumentType) {
// CHECKSTYLE:OFF
// CHECKSTYLE:OFF
case COUNTER:
{
// CHECKSTYLE:ON
@ -88,7 +88,7 @@ class MetricRegistrar {
}
break;
// CHECKSTYLE:OFF
// CHECKSTYLE:OFF
case UPDOWNCOUNTER:
{
// CHECKSTYLE:ON
@ -105,7 +105,7 @@ class MetricRegistrar {
}
break;
// CHECKSTYLE:OFF
// CHECKSTYLE:OFF
case GAUGE:
{
// CHECKSTYLE:ON
@ -121,7 +121,7 @@ class MetricRegistrar {
logger.log(INFO, "Created Gauge for {0}", metricName);
}
break;
// CHECKSTYLE:OFF
// CHECKSTYLE:OFF
case STATE:
{
// CHECKSTYLE:ON

View File

@ -95,34 +95,34 @@ class ExpandFramesClassVisitor extends ClassVisitor {
@Override
public void visitFrame(int type, int numLocal, Object[] local, int numStack, Object[] stack) {
switch (type) {
// An expanded frame.
// An expanded frame.
case Opcodes.F_NEW:
// A compressed frame with complete frame data.
// A compressed frame with complete frame data.
case Opcodes.F_FULL:
copy(local, numLocal, currentLocals);
copy(stack, numStack, currentStack);
break;
// A compressed frame with exactly the same locals as the previous frame and with an empty
// stack.
// A compressed frame with exactly the same locals as the previous frame and with an empty
// stack.
case Opcodes.F_SAME:
currentStack.clear();
break;
// A compressed frame with exactly the same locals as the previous frame and with a single
// value on the stack.
// A compressed frame with exactly the same locals as the previous frame and with a single
// value on the stack.
case Opcodes.F_SAME1:
currentStack.clear();
currentStack.add(stack[0]);
break;
// A compressed frame where locals are the same as the locals in the previous frame,
// except that additional 1-3 locals are defined, and with an empty stack.
// A compressed frame where locals are the same as the locals in the previous frame,
// except that additional 1-3 locals are defined, and with an empty stack.
case Opcodes.F_APPEND:
currentStack.clear();
for (int i = 0; i < numLocal; i++) {
currentLocals.add(local[i]);
}
break;
// A compressed frame where locals are the same as the locals in the previous frame,
// except that the last 1-3 locals are absent and with an empty stack.
// A compressed frame where locals are the same as the locals in the previous frame,
// except that the last 1-3 locals are absent and with an empty stack.
case Opcodes.F_CHOP:
currentStack.clear();
for (Iterator<Object> iterator =

View File

@ -461,9 +461,7 @@ class KotlinCoroutinesInstrumentationTest {
tracer.spanBuilder(opName).startSpan().end()
}
private fun <T> runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T {
return runTest(dispatcherWrapper.dispatcher, block)
}
private fun <T> runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T = runTest(dispatcherWrapper.dispatcher, block)
private fun <T> runTest(dispatcher: CoroutineDispatcher, block: suspend CoroutineScope.() -> T): T {
val parentSpan = tracer.spanBuilder("parent").startSpan()
@ -562,9 +560,7 @@ class KotlinCoroutinesInstrumentationTest {
oldState.close()
}
override fun updateThreadContext(context: CoroutineContext): Scope {
return otelContext.makeCurrent()
}
override fun updateThreadContext(context: CoroutineContext): Scope = otelContext.makeCurrent()
}
// regression test for

View File

@ -10,8 +10,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.onCompletion
fun <REQUEST, RESPONSE> onComplete(flow: Flow<*>, instrumenter: Instrumenter<REQUEST, RESPONSE>, context: Context, request: REQUEST & Any): Flow<*> {
return flow.onCompletion { cause: Throwable? ->
instrumenter.end(context, request, null, cause)
}
fun <REQUEST, RESPONSE> onComplete(flow: Flow<*>, instrumenter: Instrumenter<REQUEST, RESPONSE>, context: Context, request: REQUEST & Any): Flow<*> = flow.onCompletion { cause: Throwable? ->
instrumenter.end(context, request, null, cause)
}

View File

@ -185,9 +185,7 @@ class KotlinCoroutines13InstrumentationTest {
tracer.spanBuilder(opName).startSpan().end()
}
private fun <T> runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T {
return runTest(dispatcherWrapper.dispatcher, block)
}
private fun <T> runTest(dispatcherWrapper: DispatcherWrapper, block: suspend CoroutineScope.() -> T): T = runTest(dispatcherWrapper.dispatcher, block)
private fun <T> runTest(dispatcher: CoroutineDispatcher, block: suspend CoroutineScope.() -> T): T {
val parentSpan = tracer.spanBuilder("parent").startSpan()

View File

@ -9,11 +9,7 @@ import io.ktor.request.*
import io.opentelemetry.context.propagation.TextMapGetter
internal object ApplicationRequestGetter : TextMapGetter<ApplicationRequest> {
override fun keys(carrier: ApplicationRequest): Iterable<String> {
return carrier.headers.names()
}
override fun keys(carrier: ApplicationRequest): Iterable<String> = carrier.headers.names()
override fun get(carrier: ApplicationRequest?, name: String): String? {
return carrier?.headers?.get(name)
}
override fun get(carrier: ApplicationRequest?, name: String): String? = carrier?.headers?.get(name)
}

View File

@ -11,43 +11,26 @@ import io.ktor.response.*
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter
import io.opentelemetry.instrumentation.ktor.isIpAddress
internal enum class KtorHttpServerAttributesGetter :
HttpServerAttributesGetter<ApplicationRequest, ApplicationResponse> {
internal enum class KtorHttpServerAttributesGetter : HttpServerAttributesGetter<ApplicationRequest, ApplicationResponse> {
INSTANCE, ;
override fun getHttpRequestMethod(request: ApplicationRequest): String {
return request.httpMethod.value
}
override fun getHttpRequestMethod(request: ApplicationRequest): String = request.httpMethod.value
override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List<String> {
return request.headers.getAll(name) ?: emptyList()
}
override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List<String> = request.headers.getAll(name) ?: emptyList()
override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? {
return response.status()?.value
}
override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? = response.status()?.value
override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List<String> {
return response.headers.allValues().getAll(name) ?: emptyList()
}
override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List<String> = response.headers.allValues().getAll(name) ?: emptyList()
override fun getUrlScheme(request: ApplicationRequest): String {
return request.origin.scheme
}
override fun getUrlScheme(request: ApplicationRequest): String = request.origin.scheme
override fun getUrlPath(request: ApplicationRequest): String {
return request.path()
}
override fun getUrlPath(request: ApplicationRequest): String = request.path()
override fun getUrlQuery(request: ApplicationRequest): String {
return request.queryString()
}
override fun getUrlQuery(request: ApplicationRequest): String = request.queryString()
override fun getNetworkProtocolName(request: ApplicationRequest, response: ApplicationResponse?): String? =
if (request.httpVersion.startsWith("HTTP/")) "http" else null
override fun getNetworkProtocolName(request: ApplicationRequest, response: ApplicationResponse?): String? = if (request.httpVersion.startsWith("HTTP/")) "http" else null
override fun getNetworkProtocolVersion(request: ApplicationRequest, response: ApplicationResponse?): String? =
if (request.httpVersion.startsWith("HTTP/")) request.httpVersion.substring("HTTP/".length) else null
override fun getNetworkProtocolVersion(request: ApplicationRequest, response: ApplicationResponse?): String? = if (request.httpVersion.startsWith("HTTP/")) request.httpVersion.substring("HTTP/".length) else null
override fun getNetworkPeerAddress(request: ApplicationRequest, response: ApplicationResponse?): String? {
val remote = request.local.remoteHost

View File

@ -48,10 +48,12 @@ class KtorServerTelemetry private constructor(
extractor: (SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>) -> SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>
) {
builder.setStatusExtractor { prevExtractor ->
SpanStatusExtractor { spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable? ->
SpanStatusExtractor {
spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable?
->
extractor(prevExtractor).extract(spanStatusBuilder, request, response, throwable)
}
}

View File

@ -49,10 +49,12 @@ class KtorServerTracing private constructor(
extractor: (SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>) -> SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>
) {
builder.setStatusExtractor { prevExtractor ->
SpanStatusExtractor { spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable? ->
SpanStatusExtractor {
spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable?
->
extractor(prevExtractor).extract(spanStatusBuilder, request, response, throwable)
}
}

View File

@ -35,67 +35,65 @@ class KtorHttpServerOldTest : AbstractHttpServerTest<ApplicationEngine>() {
val testing = HttpServerInstrumentationExtension.forLibrary()
}
override fun setupServer(): ApplicationEngine {
return embeddedServer(Netty, port = port) {
KtorOldTestUtil.installOpenTelemetry(this, testing.openTelemetry)
override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) {
KtorOldTestUtil.installOpenTelemetry(this, testing.openTelemetry)
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
}.start()
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
}
}
}.start()
override fun stopServer(server: ApplicationEngine) {
server.stop(0, 10, TimeUnit.SECONDS)

View File

@ -35,67 +35,65 @@ class KtorHttpServerTest : AbstractHttpServerTest<ApplicationEngine>() {
val testing = HttpServerInstrumentationExtension.forLibrary()
}
override fun setupServer(): ApplicationEngine {
return embeddedServer(Netty, port = port) {
KtorTestUtil.installOpenTelemetry(this, testing.openTelemetry)
override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) {
KtorTestUtil.installOpenTelemetry(this, testing.openTelemetry)
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
}.start()
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
}
}
}.start()
override fun stopServer(server: ApplicationEngine) {
server.stop(0, 10, TimeUnit.SECONDS)

View File

@ -56,32 +56,30 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest<ApplicationE
override fun getContextPath() = ""
override fun setupServer(): ApplicationEngine {
return embeddedServer(Netty, port = port) {
install(KtorServerTelemetry) {
setOpenTelemetry(testing.openTelemetry)
setSpanKindExtractor {
SpanKindExtractor { req ->
if (req.uri.startsWith("/from-pubsub/")) {
SpanKind.CONSUMER
} else {
SpanKind.SERVER
}
override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) {
install(KtorServerTelemetry) {
setOpenTelemetry(testing.openTelemetry)
setSpanKindExtractor {
SpanKindExtractor { req ->
if (req.uri.startsWith("/from-pubsub/")) {
SpanKind.CONSUMER
} else {
SpanKind.SERVER
}
}
}
}
routing {
post(consumerKindEndpoint.path) {
call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status))
}
post(serverKindEndpoint.path) {
call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status))
}
routing {
post(consumerKindEndpoint.path) {
call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status))
}
}.start()
}
post(serverKindEndpoint.path) {
call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status))
}
}
}.start()
override fun stopServer(server: ApplicationEngine) {
server.stop(0, 10, TimeUnit.SECONDS)
@ -105,10 +103,8 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest<ApplicationE
)
}
private fun provideArguments(): Stream<Arguments> {
return Stream.of(
arguments(consumerKindEndpoint, SpanKind.CONSUMER),
arguments(serverKindEndpoint, SpanKind.SERVER),
)
}
private fun provideArguments(): Stream<Arguments> = Stream.of(
arguments(consumerKindEndpoint, SpanKind.CONSUMER),
arguments(serverKindEndpoint, SpanKind.SERVER),
)
}

View File

@ -29,9 +29,7 @@ abstract class AbstractKtorClientTelemetryBuilder(
internal lateinit var openTelemetry: OpenTelemetry
protected lateinit var builder: DefaultHttpClientInstrumenterBuilder<HttpRequestData, HttpResponse>
internal fun builder(): DefaultHttpClientInstrumenterBuilder<HttpRequestData, HttpResponse> {
return builder
}
internal fun builder(): DefaultHttpClientInstrumenterBuilder<HttpRequestData, HttpResponse> = builder
fun setOpenTelemetry(openTelemetry: OpenTelemetry) {
this.openTelemetry = openTelemetry
@ -42,9 +40,7 @@ abstract class AbstractKtorClientTelemetryBuilder(
)
}
protected fun getOpenTelemetry(): OpenTelemetry {
return openTelemetry
}
protected fun getOpenTelemetry(): OpenTelemetry = openTelemetry
fun capturedRequestHeaders(vararg headers: String) = capturedRequestHeaders(headers.asIterable())
@ -98,9 +94,7 @@ abstract class AbstractKtorClientTelemetryBuilder(
onEnd = block
}
internal fun build(): Extractor {
return Extractor(onStart, onEnd)
}
internal fun build(): Extractor = Extractor(onStart, onEnd)
}
internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit)

View File

@ -44,10 +44,12 @@ abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationNam
fun spanStatusExtractor(extract: SpanStatusData.(SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>) -> Unit) {
builder.setStatusExtractor { prevExtractor ->
SpanStatusExtractor { spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable? ->
SpanStatusExtractor {
spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable?
->
extract(
SpanStatusData(spanStatusBuilder, request, response, throwable),
prevExtractor
@ -102,9 +104,7 @@ abstract class AbstractKtorServerTelemetryBuilder(private val instrumentationNam
onEnd = block
}
internal fun build(): Extractor {
return Extractor(onStart, onEnd)
}
internal fun build(): Extractor = Extractor(onStart, onEnd)
}
internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit)

View File

@ -9,11 +9,7 @@ import io.ktor.server.request.*
import io.opentelemetry.context.propagation.TextMapGetter
internal object ApplicationRequestGetter : TextMapGetter<ApplicationRequest> {
override fun keys(carrier: ApplicationRequest): Iterable<String> {
return carrier.headers.names()
}
override fun keys(carrier: ApplicationRequest): Iterable<String> = carrier.headers.names()
override fun get(carrier: ApplicationRequest?, name: String): String? {
return carrier?.headers?.get(name)
}
override fun get(carrier: ApplicationRequest?, name: String): String? = carrier?.headers?.get(name)
}

View File

@ -11,43 +11,26 @@ import io.ktor.server.response.*
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter
import io.opentelemetry.instrumentation.ktor.isIpAddress
internal enum class KtorHttpServerAttributesGetter :
HttpServerAttributesGetter<ApplicationRequest, ApplicationResponse> {
internal enum class KtorHttpServerAttributesGetter : HttpServerAttributesGetter<ApplicationRequest, ApplicationResponse> {
INSTANCE;
override fun getHttpRequestMethod(request: ApplicationRequest): String {
return request.httpMethod.value
}
override fun getHttpRequestMethod(request: ApplicationRequest): String = request.httpMethod.value
override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List<String> {
return request.headers.getAll(name) ?: emptyList()
}
override fun getHttpRequestHeader(request: ApplicationRequest, name: String): List<String> = request.headers.getAll(name) ?: emptyList()
override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? {
return response.status()?.value
}
override fun getHttpResponseStatusCode(request: ApplicationRequest, response: ApplicationResponse, error: Throwable?): Int? = response.status()?.value
override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List<String> {
return response.headers.allValues().getAll(name) ?: emptyList()
}
override fun getHttpResponseHeader(request: ApplicationRequest, response: ApplicationResponse, name: String): List<String> = response.headers.allValues().getAll(name) ?: emptyList()
override fun getUrlScheme(request: ApplicationRequest): String {
return request.origin.scheme
}
override fun getUrlScheme(request: ApplicationRequest): String = request.origin.scheme
override fun getUrlPath(request: ApplicationRequest): String {
return request.path()
}
override fun getUrlPath(request: ApplicationRequest): String = request.path()
override fun getUrlQuery(request: ApplicationRequest): String {
return request.queryString()
}
override fun getUrlQuery(request: ApplicationRequest): String = request.queryString()
override fun getNetworkProtocolName(request: ApplicationRequest, response: ApplicationResponse?): String? =
if (request.httpVersion.startsWith("HTTP/")) "http" else null
override fun getNetworkProtocolName(request: ApplicationRequest, response: ApplicationResponse?): String? = if (request.httpVersion.startsWith("HTTP/")) "http" else null
override fun getNetworkProtocolVersion(request: ApplicationRequest, response: ApplicationResponse?): String? =
if (request.httpVersion.startsWith("HTTP/")) request.httpVersion.substring("HTTP/".length) else null
override fun getNetworkProtocolVersion(request: ApplicationRequest, response: ApplicationResponse?): String? = if (request.httpVersion.startsWith("HTTP/")) request.httpVersion.substring("HTTP/".length) else null
override fun getNetworkPeerAddress(request: ApplicationRequest, response: ApplicationResponse?): String? {
val remote = request.local.remoteHost

View File

@ -40,9 +40,7 @@ abstract class AbstractKtorClientTracingBuilder(
)
}
protected fun getOpenTelemetry(): OpenTelemetry {
return openTelemetry
}
protected fun getOpenTelemetry(): OpenTelemetry = openTelemetry
@Deprecated(
"Please use method `capturedRequestHeaders`",
@ -137,9 +135,7 @@ abstract class AbstractKtorClientTracingBuilder(
onEnd = block
}
internal fun build(): Extractor {
return Extractor(onStart, onEnd)
}
internal fun build(): Extractor = Extractor(onStart, onEnd)
}
internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit)

View File

@ -73,11 +73,9 @@ object KtorServerTelemetryUtil {
}
}
private fun instrumenter(builder: AbstractKtorServerTelemetryBuilder): Instrumenter<ApplicationRequest, ApplicationResponse> {
return InstrumenterUtil.buildUpstreamInstrumenter(
builder.builder.instrumenterBuilder(),
ApplicationRequestGetter,
builder.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
}
private fun instrumenter(builder: AbstractKtorServerTelemetryBuilder): Instrumenter<ApplicationRequest, ApplicationResponse> = InstrumenterUtil.buildUpstreamInstrumenter(
builder.builder.instrumenterBuilder(),
ApplicationRequestGetter,
builder.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
}

View File

@ -74,11 +74,9 @@ object KtorServerTracingUtil {
}
}
private fun instrumenter(builder: AbstractKtorServerTracingBuilder): Instrumenter<ApplicationRequest, ApplicationResponse> {
return InstrumenterUtil.buildUpstreamInstrumenter(
builder.serverBuilder.instrumenterBuilder(),
ApplicationRequestGetter,
builder.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
}
private fun instrumenter(builder: AbstractKtorServerTracingBuilder): Instrumenter<ApplicationRequest, ApplicationResponse> = InstrumenterUtil.buildUpstreamInstrumenter(
builder.serverBuilder.instrumenterBuilder(),
ApplicationRequestGetter,
builder.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
}

View File

@ -55,10 +55,12 @@ abstract class AbstractKtorServerTracingBuilder(private val instrumentationName:
fun spanStatusExtractor(extract: SpanStatusData.(SpanStatusExtractor<in ApplicationRequest, in ApplicationResponse>) -> Unit) {
serverBuilder.setStatusExtractor { prevExtractor ->
SpanStatusExtractor { spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable? ->
SpanStatusExtractor {
spanStatusBuilder: SpanStatusBuilder,
request: ApplicationRequest,
response: ApplicationResponse?,
throwable: Throwable?
->
extract(
SpanStatusData(spanStatusBuilder, request, response, throwable),
prevExtractor
@ -132,9 +134,7 @@ abstract class AbstractKtorServerTracingBuilder(private val instrumentationName:
onEnd = block
}
internal fun build(): Extractor {
return Extractor(onStart, onEnd)
}
internal fun build(): Extractor = Extractor(onStart, onEnd)
}
internal class Extractor(val onStart: OnStartData.() -> Unit, val onEnd: OnEndData.() -> Unit)

View File

@ -19,9 +19,7 @@ class KtorHttpServerTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forAgent()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
}

View File

@ -18,9 +18,7 @@ class KtorHttpServerOldTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forLibrary()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
KtorOldTestUtil.installOpenTelemetry(application, TESTING.openTelemetry)

View File

@ -18,9 +18,7 @@ class KtorHttpServerTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forLibrary()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
KtorTestUtil.installOpenTelemetry(application, TESTING.openTelemetry)

View File

@ -56,30 +56,28 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest<ApplicationE
override fun getContextPath() = ""
override fun setupServer(): ApplicationEngine {
return embeddedServer(Netty, port = port) {
install(KtorServerTracing) {
setOpenTelemetry(testing.openTelemetry)
spanKindExtractor {
if (uri.startsWith("/from-pubsub/")) {
SpanKind.CONSUMER
} else {
SpanKind.SERVER
}
override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) {
install(KtorServerTracing) {
setOpenTelemetry(testing.openTelemetry)
spanKindExtractor {
if (uri.startsWith("/from-pubsub/")) {
SpanKind.CONSUMER
} else {
SpanKind.SERVER
}
}
}
routing {
post(consumerKindEndpoint.path) {
call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status))
}
post(serverKindEndpoint.path) {
call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status))
}
routing {
post(consumerKindEndpoint.path) {
call.respondText(consumerKindEndpoint.body, status = HttpStatusCode.fromValue(consumerKindEndpoint.status))
}
}.start()
}
post(serverKindEndpoint.path) {
call.respondText(serverKindEndpoint.body, status = HttpStatusCode.fromValue(serverKindEndpoint.status))
}
}
}.start()
override fun stopServer(server: ApplicationEngine) {
server.stop(0, 10, TimeUnit.SECONDS)
@ -103,10 +101,8 @@ class KtorServerSpanKindExtractorTest : AbstractHttpServerUsingTest<ApplicationE
)
}
private fun provideArguments(): Stream<Arguments> {
return Stream.of(
arguments(consumerKindEndpoint, SpanKind.CONSUMER),
arguments(serverKindEndpoint, SpanKind.SERVER),
)
}
private fun provideArguments(): Stream<Arguments> = Stream.of(
arguments(consumerKindEndpoint, SpanKind.CONSUMER),
arguments(serverKindEndpoint, SpanKind.SERVER),
)
}

View File

@ -32,67 +32,65 @@ abstract class AbstractKtorHttpServerTest : AbstractHttpServerTest<ApplicationEn
abstract fun installOpenTelemetry(application: Application)
override fun setupServer(): ApplicationEngine {
return embeddedServer(Netty, port = port) {
installOpenTelemetry(this)
override fun setupServer(): ApplicationEngine = embeddedServer(Netty, port = port) {
installOpenTelemetry(this)
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
}.start()
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
}
}
}.start()
override fun stopServer(server: ApplicationEngine) {
server.stop(0, 10, TimeUnit.SECONDS)

View File

@ -19,9 +19,7 @@ class KtorHttpServerTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forAgent()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
}

View File

@ -19,9 +19,7 @@ class KtorHttpServerOldTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forLibrary()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
application.apply {

View File

@ -18,9 +18,7 @@ class KtorHttpServerTest : AbstractKtorHttpServerTest() {
val TESTING: InstrumentationExtension = HttpServerInstrumentationExtension.forLibrary()
}
override fun getTesting(): InstrumentationExtension {
return TESTING
}
override fun getTesting(): InstrumentationExtension = TESTING
override fun installOpenTelemetry(application: Application) {
application.apply {

View File

@ -32,67 +32,65 @@ abstract class AbstractKtorHttpServerTest : AbstractHttpServerTest<EmbeddedServe
abstract fun installOpenTelemetry(application: Application)
override fun setupServer(): EmbeddedServer<*, *> {
return embeddedServer(Netty, port = port) {
installOpenTelemetry(this)
override fun setupServer(): EmbeddedServer<*, *> = embeddedServer(Netty, port = port) {
installOpenTelemetry(this)
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
routing {
get(ServerEndpoint.SUCCESS.path) {
controller(ServerEndpoint.SUCCESS) {
call.respondText(ServerEndpoint.SUCCESS.body, status = HttpStatusCode.fromValue(ServerEndpoint.SUCCESS.status))
}
}
}.start()
}
get(ServerEndpoint.REDIRECT.path) {
controller(ServerEndpoint.REDIRECT) {
call.respondRedirect(ServerEndpoint.REDIRECT.body)
}
}
get(ServerEndpoint.ERROR.path) {
controller(ServerEndpoint.ERROR) {
call.respondText(ServerEndpoint.ERROR.body, status = HttpStatusCode.fromValue(ServerEndpoint.ERROR.status))
}
}
get(ServerEndpoint.EXCEPTION.path) {
controller(ServerEndpoint.EXCEPTION) {
throw IllegalStateException(ServerEndpoint.EXCEPTION.body)
}
}
get("/query") {
controller(ServerEndpoint.QUERY_PARAM) {
call.respondText("some=${call.request.queryParameters["some"]}", status = HttpStatusCode.fromValue(ServerEndpoint.QUERY_PARAM.status))
}
}
get("/path/{id}/param") {
controller(ServerEndpoint.PATH_PARAM) {
call.respondText(
call.parameters["id"]
?: "",
status = HttpStatusCode.fromValue(ServerEndpoint.PATH_PARAM.status),
)
}
}
get("/child") {
controller(ServerEndpoint.INDEXED_CHILD) {
ServerEndpoint.INDEXED_CHILD.collectSpanAttributes { call.request.queryParameters[it] }
call.respondText(ServerEndpoint.INDEXED_CHILD.body, status = HttpStatusCode.fromValue(ServerEndpoint.INDEXED_CHILD.status))
}
}
get("/captureHeaders") {
controller(ServerEndpoint.CAPTURE_HEADERS) {
call.response.header("X-Test-Response", call.request.header("X-Test-Request") ?: "")
call.respondText(ServerEndpoint.CAPTURE_HEADERS.body, status = HttpStatusCode.fromValue(ServerEndpoint.CAPTURE_HEADERS.status))
}
}
}
}.start()
override fun stopServer(server: EmbeddedServer<*, *>) {
server.stop(0, 10, TimeUnit.SECONDS)

View File

@ -42,6 +42,4 @@ private val ipv4 = Pattern.compile(
"(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\$",
)
fun isIpAddress(address: String): Boolean {
return ipv4.matcher(address).matches() || ipv6.matcher(address).matches()
}
fun isIpAddress(address: String): Boolean = ipv4.matcher(address).matches() || ipv6.matcher(address).matches()

View File

@ -40,7 +40,7 @@ final class OpenTelemetryMeter extends AbstractMeter implements Meter, Removable
switch (measurement.getStatistic()) {
case TOTAL:
// fall through
// fall through
case TOTAL_TIME:
case COUNT:
observableInstruments.add(
@ -63,7 +63,7 @@ final class OpenTelemetryMeter extends AbstractMeter implements Meter, Removable
break;
case DURATION:
// fall through
// fall through
case MAX:
case VALUE:
case UNKNOWN:

View File

@ -74,7 +74,8 @@ if (!(findProperty("testLatestDeps") as Boolean)) {
configurations.configureEach {
if (!name.contains("muzzle")) {
resolutionStrategy.eachDependency {
if (requested.group == "io.netty" && requested.name != "netty-bom" &&
if (requested.group == "io.netty" &&
requested.name != "netty-bom" &&
!requested.name.startsWith("netty-transport-native") &&
!requested.name.startsWith("netty-transport-classes")) {
useVersion("4.1.0.Final")

View File

@ -60,7 +60,7 @@ public abstract class RedissonRequest {
switch (sanitizedStatements.size()) {
case 0:
return null;
// optimize for the most common case
// optimize for the most common case
case 1:
return sanitizedStatements.get(0);
default:

View File

@ -48,8 +48,7 @@ class KotlinSpringDataTest {
Assertions.assertThat(customer?.name).isEqualTo("Name")
}
testing.waitAndAssertTraces({
trace ->
testing.waitAndAssertTraces({ trace ->
trace.hasSpansSatisfyingExactly({
it.hasName("CustomerRepository.findById").hasNoParent()
}, {

View File

@ -23,19 +23,17 @@ import java.nio.charset.StandardCharsets
class PersistenceConfig {
@Bean
fun connectionFactory(): ConnectionFactory? {
return ConnectionFactories.find(
ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "h2")
.option(ConnectionFactoryOptions.PROTOCOL, "mem")
.option(ConnectionFactoryOptions.HOST, "localhost")
.option(ConnectionFactoryOptions.USER, "sa")
.option(ConnectionFactoryOptions.PASSWORD, "")
.option(ConnectionFactoryOptions.DATABASE, "db")
.option(Option.valueOf("DB_CLOSE_DELAY"), "-1")
.build()
)
}
fun connectionFactory(): ConnectionFactory? = ConnectionFactories.find(
ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "h2")
.option(ConnectionFactoryOptions.PROTOCOL, "mem")
.option(ConnectionFactoryOptions.HOST, "localhost")
.option(ConnectionFactoryOptions.USER, "sa")
.option(ConnectionFactoryOptions.PASSWORD, "")
.option(ConnectionFactoryOptions.DATABASE, "db")
.option(Option.valueOf("DB_CLOSE_DELAY"), "-1")
.build()
)
@Bean
fun initializer(connectionFactory: ConnectionFactory): ConnectionFactoryInitializer {