fix(deps): update dependency com.diffplug.spotless:spotless-plugin-gradle to v6.22.0 (#9577)
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:
parent
485aa01c70
commit
ff5e0a41b7
|
@ -54,7 +54,7 @@ dependencies {
|
||||||
implementation("org.apache.maven:maven-aether-provider:3.3.9")
|
implementation("org.apache.maven:maven-aether-provider:3.3.9")
|
||||||
|
|
||||||
// When updating, update above in plugins too
|
// When updating, update above in plugins too
|
||||||
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.21.0")
|
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
|
||||||
implementation("com.google.guava:guava:32.1.2-jre")
|
implementation("com.google.guava:guava:32.1.2-jre")
|
||||||
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
|
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
|
||||||
implementation("com.github.johnrengelman:shadow:8.1.1")
|
implementation("com.github.johnrengelman:shadow:8.1.1")
|
||||||
|
|
|
@ -74,7 +74,9 @@ spotless {
|
||||||
// depends on ktlint_standard_wrapping
|
// depends on ktlint_standard_wrapping
|
||||||
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
|
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
|
||||||
// also very hard to find out where this happens
|
// also very hard to find out where this happens
|
||||||
"ktlint_standard_wrapping" to "disabled"
|
"ktlint_standard_wrapping" to "disabled",
|
||||||
|
// we use variable names like v1_10Deps
|
||||||
|
"ktlint_standard_property-naming" to "disabled"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.21.0"
|
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.22.0"
|
||||||
classpath "gradle.plugin.com.github.johnrengelman:shadow:8.0.0"
|
classpath "gradle.plugin.com.github.johnrengelman:shadow:8.0.0"
|
||||||
classpath "io.opentelemetry.instrumentation:gradle-plugins:1.31.0-alpha-SNAPSHOT"
|
classpath "io.opentelemetry.instrumentation:gradle-plugins:1.31.0-alpha-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,13 +62,15 @@ val launcher = javaToolchains.launcherFor {
|
||||||
|
|
||||||
class CompilerArgumentsProvider : CommandLineArgumentProvider {
|
class CompilerArgumentsProvider : CommandLineArgumentProvider {
|
||||||
override fun asArguments(): Iterable<String> = listOf(
|
override fun asArguments(): Iterable<String> = listOf(
|
||||||
"test.gwt.Greeting", // gwt module
|
// gwt module
|
||||||
|
"test.gwt.Greeting",
|
||||||
"-war", layout.buildDirectory.dir("testapp/war").get().asFile.absolutePath,
|
"-war", layout.buildDirectory.dir("testapp/war").get().asFile.absolutePath,
|
||||||
"-logLevel", "INFO",
|
"-logLevel", "INFO",
|
||||||
"-localWorkers", "2",
|
"-localWorkers", "2",
|
||||||
"-compileReport",
|
"-compileReport",
|
||||||
"-extra", layout.buildDirectory.dir("testapp/extra").get().asFile.absolutePath,
|
"-extra", layout.buildDirectory.dir("testapp/extra").get().asFile.absolutePath,
|
||||||
"-draftCompile", // makes compile a bit faster
|
// makes compile a bit faster
|
||||||
|
"-draftCompile",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,20 +460,20 @@ class KotlinCoroutinesInstrumentationTest {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val ANIMAL: ContextKey<String> = ContextKey.named("animal")
|
private val animalKey: ContextKey<String> = ContextKey.named("animal")
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@ArgumentsSource(DispatchersSource::class)
|
@ArgumentsSource(DispatchersSource::class)
|
||||||
fun `context contains expected value`(dispatcher: DispatcherWrapper) {
|
fun `context contains expected value`(dispatcher: DispatcherWrapper) {
|
||||||
runTest(dispatcher) {
|
runTest(dispatcher) {
|
||||||
val context1 = Context.current().with(ANIMAL, "cat")
|
val context1 = Context.current().with(animalKey, "cat")
|
||||||
runBlocking(context1.asContextElement()) {
|
runBlocking(context1.asContextElement()) {
|
||||||
assertThat(Context.current().get(ANIMAL)).isEqualTo("cat")
|
assertThat(Context.current().get(animalKey)).isEqualTo("cat")
|
||||||
assertThat(coroutineContext.getOpenTelemetryContext().get(ANIMAL)).isEqualTo("cat")
|
assertThat(coroutineContext.getOpenTelemetryContext().get(animalKey)).isEqualTo("cat")
|
||||||
tracedChild("nested1")
|
tracedChild("nested1")
|
||||||
withContext(context1.with(ANIMAL, "dog").asContextElement()) {
|
withContext(context1.with(animalKey, "dog").asContextElement()) {
|
||||||
assertThat(Context.current().get(ANIMAL)).isEqualTo("dog")
|
assertThat(Context.current().get(animalKey)).isEqualTo("dog")
|
||||||
assertThat(coroutineContext.getOpenTelemetryContext().get(ANIMAL)).isEqualTo("dog")
|
assertThat(coroutineContext.getOpenTelemetryContext().get(animalKey)).isEqualTo("dog")
|
||||||
tracedChild("nested2")
|
tracedChild("nested2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,16 +641,15 @@ class KotlinCoroutinesInstrumentationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
class DispatchersSource : ArgumentsProvider {
|
class DispatchersSource : ArgumentsProvider {
|
||||||
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> =
|
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> = Stream.of(
|
||||||
Stream.of(
|
// Wrap dispatchers since it seems that ParameterizedTest tries to automatically close
|
||||||
// Wrap dispatchers since it seems that ParameterizedTest tries to automatically close
|
// Closeable arguments with no way to avoid it.
|
||||||
// Closeable arguments with no way to avoid it.
|
arguments(DispatcherWrapper(Dispatchers.Default)),
|
||||||
arguments(DispatcherWrapper(Dispatchers.Default)),
|
arguments(DispatcherWrapper(Dispatchers.IO)),
|
||||||
arguments(DispatcherWrapper(Dispatchers.IO)),
|
arguments(DispatcherWrapper(Dispatchers.Unconfined)),
|
||||||
arguments(DispatcherWrapper(Dispatchers.Unconfined)),
|
arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())),
|
||||||
arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())),
|
arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())),
|
||||||
arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())),
|
)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DispatcherWrapper(val dispatcher: CoroutineDispatcher) {
|
class DispatcherWrapper(val dispatcher: CoroutineDispatcher) {
|
||||||
|
|
|
@ -58,9 +58,7 @@ class KtorServerTracing private constructor(
|
||||||
this.statusExtractor = extractor
|
this.statusExtractor = extractor
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSpanKindExtractor(
|
fun setSpanKindExtractor(extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>) {
|
||||||
extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>
|
|
||||||
) {
|
|
||||||
this.spanKindExtractor = extractor
|
this.spanKindExtractor = extractor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,13 @@ class KtorClientTracingBuilder {
|
||||||
this.openTelemetry = openTelemetry
|
this.openTelemetry = openTelemetry
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCapturedRequestHeaders(vararg headers: String) =
|
fun setCapturedRequestHeaders(vararg headers: String) = setCapturedRequestHeaders(headers.asList())
|
||||||
setCapturedRequestHeaders(headers.asList())
|
|
||||||
|
|
||||||
fun setCapturedRequestHeaders(headers: List<String>) {
|
fun setCapturedRequestHeaders(headers: List<String>) {
|
||||||
httpAttributesExtractorBuilder.setCapturedRequestHeaders(headers)
|
httpAttributesExtractorBuilder.setCapturedRequestHeaders(headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCapturedResponseHeaders(vararg headers: String) =
|
fun setCapturedResponseHeaders(vararg headers: String) = setCapturedResponseHeaders(headers.asList())
|
||||||
setCapturedResponseHeaders(headers.asList())
|
|
||||||
|
|
||||||
fun setCapturedResponseHeaders(headers: List<String>) {
|
fun setCapturedResponseHeaders(headers: List<String>) {
|
||||||
httpAttributesExtractorBuilder.setCapturedResponseHeaders(headers)
|
httpAttributesExtractorBuilder.setCapturedResponseHeaders(headers)
|
||||||
|
@ -49,8 +47,7 @@ class KtorClientTracingBuilder {
|
||||||
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods)
|
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addAttributesExtractors(vararg extractors: AttributesExtractor<in HttpRequestData, in HttpResponse>) =
|
fun addAttributesExtractors(vararg extractors: AttributesExtractor<in HttpRequestData, in HttpResponse>) = addAttributesExtractors(extractors.asList())
|
||||||
addAttributesExtractors(extractors.asList())
|
|
||||||
|
|
||||||
fun addAttributesExtractors(extractors: Iterable<AttributesExtractor<in HttpRequestData, in HttpResponse>>) {
|
fun addAttributesExtractors(extractors: Iterable<AttributesExtractor<in HttpRequestData, in HttpResponse>>) {
|
||||||
additionalExtractors += extractors
|
additionalExtractors += extractors
|
||||||
|
@ -61,9 +58,7 @@ class KtorClientTracingBuilder {
|
||||||
*
|
*
|
||||||
* @param emitExperimentalHttpClientMetrics `true` if the experimental HTTP client metrics are to be emitted.
|
* @param emitExperimentalHttpClientMetrics `true` if the experimental HTTP client metrics are to be emitted.
|
||||||
*/
|
*/
|
||||||
fun setEmitExperimentalHttpClientMetrics(
|
fun setEmitExperimentalHttpClientMetrics(emitExperimentalHttpClientMetrics: Boolean) {
|
||||||
emitExperimentalHttpClientMetrics: Boolean
|
|
||||||
) {
|
|
||||||
this.emitExperimentalHttpClientMetrics = emitExperimentalHttpClientMetrics
|
this.emitExperimentalHttpClientMetrics = emitExperimentalHttpClientMetrics
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,23 +11,17 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttribut
|
||||||
|
|
||||||
internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter<HttpRequestData, HttpResponse> {
|
internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter<HttpRequestData, HttpResponse> {
|
||||||
|
|
||||||
override fun getUrlFull(request: HttpRequestData) =
|
override fun getUrlFull(request: HttpRequestData) = request.url.toString()
|
||||||
request.url.toString()
|
|
||||||
|
|
||||||
override fun getHttpRequestMethod(request: HttpRequestData) =
|
override fun getHttpRequestMethod(request: HttpRequestData) = request.method.value
|
||||||
request.method.value
|
|
||||||
|
|
||||||
override fun getHttpRequestHeader(request: HttpRequestData, name: String) =
|
override fun getHttpRequestHeader(request: HttpRequestData, name: String) = request.headers.getAll(name).orEmpty()
|
||||||
request.headers.getAll(name).orEmpty()
|
|
||||||
|
|
||||||
override fun getHttpResponseStatusCode(request: HttpRequestData, response: HttpResponse, error: Throwable?) =
|
override fun getHttpResponseStatusCode(request: HttpRequestData, response: HttpResponse, error: Throwable?) = response.status.value
|
||||||
response.status.value
|
|
||||||
|
|
||||||
override fun getHttpResponseHeader(request: HttpRequestData, response: HttpResponse, name: String) =
|
override fun getHttpResponseHeader(request: HttpRequestData, response: HttpResponse, name: String) = response.headers.getAll(name).orEmpty()
|
||||||
response.headers.getAll(name).orEmpty()
|
|
||||||
|
|
||||||
override fun getNetworkProtocolName(request: HttpRequestData?, response: HttpResponse?): String? =
|
override fun getNetworkProtocolName(request: HttpRequestData?, response: HttpResponse?): String? = response?.version?.name
|
||||||
response?.version?.name
|
|
||||||
|
|
||||||
override fun getNetworkProtocolVersion(request: HttpRequestData?, response: HttpResponse?): String? {
|
override fun getNetworkProtocolVersion(request: HttpRequestData?, response: HttpResponse?): String? {
|
||||||
val version = response?.version ?: return null
|
val version = response?.version ?: return null
|
||||||
|
|
|
@ -59,9 +59,7 @@ class KtorServerTracing private constructor(
|
||||||
this.statusExtractor = extractor
|
this.statusExtractor = extractor
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setSpanKindExtractor(
|
fun setSpanKindExtractor(extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>) {
|
||||||
extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>
|
|
||||||
) {
|
|
||||||
this.spanKindExtractor = extractor
|
this.spanKindExtractor = extractor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,11 @@ abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest<HttpRequestBu
|
||||||
|
|
||||||
abstract fun HttpClientConfig<*>.installTracing()
|
abstract fun HttpClientConfig<*>.installTracing()
|
||||||
|
|
||||||
override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap<String, String>) =
|
override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap<String, String>) = HttpRequestBuilder(uri.toURL()).apply {
|
||||||
HttpRequestBuilder(uri.toURL()).apply {
|
method = HttpMethod.parse(requestMethod)
|
||||||
method = HttpMethod.parse(requestMethod)
|
|
||||||
|
|
||||||
requestHeaders.forEach { (header, value) -> headers.append(header, value) }
|
requestHeaders.forEach { (header, value) -> headers.append(header, value) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendRequest(request: HttpRequestBuilder, method: String, uri: URI, headers: MutableMap<String, String>) = runBlocking {
|
override fun sendRequest(request: HttpRequestBuilder, method: String, uri: URI, headers: MutableMap<String, String>) = runBlocking {
|
||||||
client.request(request).status.value
|
client.request(request).status.value
|
||||||
|
|
|
@ -9,17 +9,28 @@ import java.util.regex.Pattern
|
||||||
|
|
||||||
// Source: Regular Expressions Cookbook 2nd edition - 8.17.
|
// Source: Regular Expressions Cookbook 2nd edition - 8.17.
|
||||||
// Matching IPv6 Addresses
|
// Matching IPv6 Addresses
|
||||||
private val ipv6 = Pattern.compile( // Non Compressed
|
private val ipv6 = Pattern.compile(
|
||||||
"^(?:(?:(?:[A-F0-9]{1,4}:){6}" + // Compressed with at most 6 colons
|
// Non Compressed
|
||||||
"|(?=(?:[A-F0-9]{0,4}:){0,6}" + // and 4 bytes and anchored
|
"^(?:(?:(?:[A-F0-9]{1,4}:){6}" +
|
||||||
"(?:[0-9]{1,3}\\.){3}[0-9]{1,3}(?![:.\\w]))" + // and at most 1 double colon
|
// Compressed with at most 6 colons
|
||||||
"(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)" + // Compressed with 7 colons and 5 numbers
|
"|(?=(?:[A-F0-9]{0,4}:){0,6}" +
|
||||||
"|::(?:[A-F0-9]{1,4}:){5})" + // 255.255.255.
|
// and 4 bytes and anchored
|
||||||
"(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}" + // 255
|
"(?:[0-9]{1,3}\\.){3}[0-9]{1,3}(?![:.\\w]))" +
|
||||||
"(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" + // Standard
|
// and at most 1 double colon
|
||||||
"|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}" + // Compressed with at most 7 colons and anchored
|
"(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)" +
|
||||||
"|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}(?![:.\\w]))" + // and at most 1 double colon
|
// Compressed with 7 colons and 5 numbers
|
||||||
"(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)" + // Compressed with 8 colons
|
"|::(?:[A-F0-9]{1,4}:){5})" +
|
||||||
|
// 255.255.255.
|
||||||
|
"(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}" +
|
||||||
|
// 255
|
||||||
|
"(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" +
|
||||||
|
// Standard
|
||||||
|
"|(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}" +
|
||||||
|
// Compressed with at most 7 colons and anchored
|
||||||
|
"|(?=(?:[A-F0-9]{0,4}:){0,7}[A-F0-9]{0,4}(?![:.\\w]))" +
|
||||||
|
// and at most 1 double colon
|
||||||
|
"(([0-9A-F]{1,4}:){1,7}|:)((:[0-9A-F]{1,4}){1,7}|:)" +
|
||||||
|
// Compressed with 8 colons
|
||||||
"|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7})(?![:.\\w])\$",
|
"|(?:[A-F0-9]{1,4}:){7}:|:(:[A-F0-9]{1,4}){7})(?![:.\\w])\$",
|
||||||
Pattern.CASE_INSENSITIVE,
|
Pattern.CASE_INSENSITIVE,
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,17 +13,17 @@ import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ContextExtensionInstrumentationTest {
|
class ContextExtensionInstrumentationTest {
|
||||||
private val ANIMAL: ContextKey<String> = ContextKey.named("animal")
|
private val animalKey: ContextKey<String> = ContextKey.named("animal")
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `is instrumented`() {
|
fun `is instrumented`() {
|
||||||
val context1 = Context.root().with(ANIMAL, "cat")
|
val context1 = Context.root().with(animalKey, "cat")
|
||||||
val contextElement = context1.asContextElement()
|
val contextElement = context1.asContextElement()
|
||||||
// check that the context element is from the opentelemetry-extension-kotlin that is shaded
|
// check that the context element is from the opentelemetry-extension-kotlin that is shaded
|
||||||
// inside the agent
|
// inside the agent
|
||||||
assertThat(contextElement.javaClass.name).startsWith("io.opentelemetry.javaagent.shaded")
|
assertThat(contextElement.javaClass.name).startsWith("io.opentelemetry.javaagent.shaded")
|
||||||
val context2 = contextElement.getOpenTelemetryContext()
|
val context2 = contextElement.getOpenTelemetryContext()
|
||||||
assertThat(context2.get(ANIMAL)).isEqualTo("cat")
|
assertThat(context2.get(animalKey)).isEqualTo("cat")
|
||||||
// instrumentation does not preserve context identity due to conversion between application and
|
// instrumentation does not preserve context identity due to conversion between application and
|
||||||
// agent context
|
// agent context
|
||||||
assert(context1 != context2) { "Not instrumented" }
|
assert(context1 != context2) { "Not instrumented" }
|
||||||
|
|
Loading…
Reference in New Issue