Skip to content

Commit

Permalink
fix(deps): update dependency com.diffplug.spotless:spotless-plugin-gr…
Browse files Browse the repository at this point in the history
…adle to v6.22.0 (#9577)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lauri Tulmin <[email protected]>
  • Loading branch information
renovate[bot] and laurit authored Sep 29, 2023
1 parent 485aa01 commit ff5e0a4
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 68 deletions.
2 changes: 1 addition & 1 deletion conventions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.21.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
implementation("com.google.guava:guava:32.1.2-jre")
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18")
implementation("com.github.johnrengelman:shadow:8.1.1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ spotless {
// depends on ktlint_standard_wrapping
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
// 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"
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/distro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
}
}
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 "io.opentelemetry.instrumentation:gradle-plugins:1.31.0-alpha-SNAPSHOT"
}
Expand Down
6 changes: 4 additions & 2 deletions instrumentation/gwt-2.0/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ val launcher = javaToolchains.launcherFor {

class CompilerArgumentsProvider : CommandLineArgumentProvider {
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,
"-logLevel", "INFO",
"-localWorkers", "2",
"-compileReport",
"-extra", layout.buildDirectory.dir("testapp/extra").get().asFile.absolutePath,
"-draftCompile", // makes compile a bit faster
// makes compile a bit faster
"-draftCompile",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,20 +460,20 @@ class KotlinCoroutinesInstrumentationTest {
)
}

private val ANIMAL: ContextKey<String> = ContextKey.named("animal")
private val animalKey: ContextKey<String> = ContextKey.named("animal")

@ParameterizedTest
@ArgumentsSource(DispatchersSource::class)
fun `context contains expected value`(dispatcher: DispatcherWrapper) {
runTest(dispatcher) {
val context1 = Context.current().with(ANIMAL, "cat")
val context1 = Context.current().with(animalKey, "cat")
runBlocking(context1.asContextElement()) {
assertThat(Context.current().get(ANIMAL)).isEqualTo("cat")
assertThat(coroutineContext.getOpenTelemetryContext().get(ANIMAL)).isEqualTo("cat")
assertThat(Context.current().get(animalKey)).isEqualTo("cat")
assertThat(coroutineContext.getOpenTelemetryContext().get(animalKey)).isEqualTo("cat")
tracedChild("nested1")
withContext(context1.with(ANIMAL, "dog").asContextElement()) {
assertThat(Context.current().get(ANIMAL)).isEqualTo("dog")
assertThat(coroutineContext.getOpenTelemetryContext().get(ANIMAL)).isEqualTo("dog")
withContext(context1.with(animalKey, "dog").asContextElement()) {
assertThat(Context.current().get(animalKey)).isEqualTo("dog")
assertThat(coroutineContext.getOpenTelemetryContext().get(animalKey)).isEqualTo("dog")
tracedChild("nested2")
}
}
Expand Down Expand Up @@ -641,16 +641,15 @@ class KotlinCoroutinesInstrumentationTest {
}

class DispatchersSource : ArgumentsProvider {
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> =
Stream.of(
// Wrap dispatchers since it seems that ParameterizedTest tries to automatically close
// Closeable arguments with no way to avoid it.
arguments(DispatcherWrapper(Dispatchers.Default)),
arguments(DispatcherWrapper(Dispatchers.IO)),
arguments(DispatcherWrapper(Dispatchers.Unconfined)),
arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())),
arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())),
)
override fun provideArguments(context: ExtensionContext?): Stream<out Arguments> = Stream.of(
// Wrap dispatchers since it seems that ParameterizedTest tries to automatically close
// Closeable arguments with no way to avoid it.
arguments(DispatcherWrapper(Dispatchers.Default)),
arguments(DispatcherWrapper(Dispatchers.IO)),
arguments(DispatcherWrapper(Dispatchers.Unconfined)),
arguments(DispatcherWrapper(threadPool.asCoroutineDispatcher())),
arguments(DispatcherWrapper(singleThread.asCoroutineDispatcher())),
)
}

class DispatcherWrapper(val dispatcher: CoroutineDispatcher) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ class KtorServerTracing private constructor(
this.statusExtractor = extractor
}

fun setSpanKindExtractor(
extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>
) {
fun setSpanKindExtractor(extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>) {
this.spanKindExtractor = extractor
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ class KtorClientTracingBuilder {
this.openTelemetry = openTelemetry
}

fun setCapturedRequestHeaders(vararg headers: String) =
setCapturedRequestHeaders(headers.asList())
fun setCapturedRequestHeaders(vararg headers: String) = setCapturedRequestHeaders(headers.asList())

fun setCapturedRequestHeaders(headers: List<String>) {
httpAttributesExtractorBuilder.setCapturedRequestHeaders(headers)
}

fun setCapturedResponseHeaders(vararg headers: String) =
setCapturedResponseHeaders(headers.asList())
fun setCapturedResponseHeaders(vararg headers: String) = setCapturedResponseHeaders(headers.asList())

fun setCapturedResponseHeaders(headers: List<String>) {
httpAttributesExtractorBuilder.setCapturedResponseHeaders(headers)
Expand All @@ -49,8 +47,7 @@ class KtorClientTracingBuilder {
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods)
}

fun addAttributesExtractors(vararg extractors: AttributesExtractor<in HttpRequestData, in HttpResponse>) =
addAttributesExtractors(extractors.asList())
fun addAttributesExtractors(vararg extractors: AttributesExtractor<in HttpRequestData, in HttpResponse>) = addAttributesExtractors(extractors.asList())

fun addAttributesExtractors(extractors: Iterable<AttributesExtractor<in HttpRequestData, in HttpResponse>>) {
additionalExtractors += extractors
Expand All @@ -61,9 +58,7 @@ class KtorClientTracingBuilder {
*
* @param emitExperimentalHttpClientMetrics `true` if the experimental HTTP client metrics are to be emitted.
*/
fun setEmitExperimentalHttpClientMetrics(
emitExperimentalHttpClientMetrics: Boolean
) {
fun setEmitExperimentalHttpClientMetrics(emitExperimentalHttpClientMetrics: Boolean) {
this.emitExperimentalHttpClientMetrics = emitExperimentalHttpClientMetrics
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,17 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttribut

internal object KtorHttpClientAttributesGetter : HttpClientAttributesGetter<HttpRequestData, HttpResponse> {

override fun getUrlFull(request: HttpRequestData) =
request.url.toString()
override fun getUrlFull(request: HttpRequestData) = request.url.toString()

override fun getHttpRequestMethod(request: HttpRequestData) =
request.method.value
override fun getHttpRequestMethod(request: HttpRequestData) = request.method.value

override fun getHttpRequestHeader(request: HttpRequestData, name: String) =
request.headers.getAll(name).orEmpty()
override fun getHttpRequestHeader(request: HttpRequestData, name: String) = request.headers.getAll(name).orEmpty()

override fun getHttpResponseStatusCode(request: HttpRequestData, response: HttpResponse, error: Throwable?) =
response.status.value
override fun getHttpResponseStatusCode(request: HttpRequestData, response: HttpResponse, error: Throwable?) = response.status.value

override fun getHttpResponseHeader(request: HttpRequestData, response: HttpResponse, name: String) =
response.headers.getAll(name).orEmpty()
override fun getHttpResponseHeader(request: HttpRequestData, response: HttpResponse, name: String) = response.headers.getAll(name).orEmpty()

override fun getNetworkProtocolName(request: HttpRequestData?, response: HttpResponse?): String? =
response?.version?.name
override fun getNetworkProtocolName(request: HttpRequestData?, response: HttpResponse?): String? = response?.version?.name

override fun getNetworkProtocolVersion(request: HttpRequestData?, response: HttpResponse?): String? {
val version = response?.version ?: return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ class KtorServerTracing private constructor(
this.statusExtractor = extractor
}

fun setSpanKindExtractor(
extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>
) {
fun setSpanKindExtractor(extractor: (SpanKindExtractor<ApplicationRequest>) -> SpanKindExtractor<ApplicationRequest>) {
this.spanKindExtractor = extractor
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ abstract class AbstractKtorHttpClientTest : AbstractHttpClientTest<HttpRequestBu

abstract fun HttpClientConfig<*>.installTracing()

override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap<String, String>) =
HttpRequestBuilder(uri.toURL()).apply {
method = HttpMethod.parse(requestMethod)
override fun buildRequest(requestMethod: String, uri: URI, requestHeaders: MutableMap<String, String>) = HttpRequestBuilder(uri.toURL()).apply {
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 {
client.request(request).status.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@ import java.util.regex.Pattern

// Source: Regular Expressions Cookbook 2nd edition - 8.17.
// Matching IPv6 Addresses
private val ipv6 = Pattern.compile( // Non Compressed
"^(?:(?:(?:[A-F0-9]{1,4}:){6}" + // Compressed with at most 6 colons
"|(?=(?:[A-F0-9]{0,4}:){0,6}" + // and 4 bytes and anchored
"(?:[0-9]{1,3}\\.){3}[0-9]{1,3}(?![:.\\w]))" + // and at most 1 double colon
"(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)" + // Compressed with 7 colons and 5 numbers
"|::(?:[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
private val ipv6 = Pattern.compile(
// Non Compressed
"^(?:(?:(?:[A-F0-9]{1,4}:){6}" +
// Compressed with at most 6 colons
"|(?=(?:[A-F0-9]{0,4}:){0,6}" +
// and 4 bytes and anchored
"(?:[0-9]{1,3}\\.){3}[0-9]{1,3}(?![:.\\w]))" +
// and at most 1 double colon
"(([0-9A-F]{1,4}:){0,5}|:)((:[0-9A-F]{1,4}){1,5}:|:)" +
// Compressed with 7 colons and 5 numbers
"|::(?:[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])\$",
Pattern.CASE_INSENSITIVE,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test

class ContextExtensionInstrumentationTest {
private val ANIMAL: ContextKey<String> = ContextKey.named("animal")
private val animalKey: ContextKey<String> = ContextKey.named("animal")

@Test
fun `is instrumented`() {
val context1 = Context.root().with(ANIMAL, "cat")
val context1 = Context.root().with(animalKey, "cat")
val contextElement = context1.asContextElement()
// check that the context element is from the opentelemetry-extension-kotlin that is shaded
// inside the agent
assertThat(contextElement.javaClass.name).startsWith("io.opentelemetry.javaagent.shaded")
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
// agent context
assert(context1 != context2) { "Not instrumented" }
Expand Down

0 comments on commit ff5e0a4

Please sign in to comment.