Auto-format groovy files in Intellij (#5260)

* Auto-format groovy files in Intellij

* A bit of clean up
This commit is contained in:
Trask Stalnaker 2022-01-28 09:29:46 -08:00 committed by GitHub
parent 72afa5a8ed
commit 23b33adb0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 138 additions and 115 deletions

View File

@ -7,11 +7,12 @@ package io.opentelemetry.instrumentation.awslambda.v1_0
import com.amazonaws.services.lambda.runtime.Context
import io.opentelemetry.instrumentation.test.LibraryInstrumentationSpecification
import java.util.function.BiFunction
import org.junit.Rule
import org.junit.contrib.java.lang.system.EnvironmentVariables
import spock.lang.Shared
import java.util.function.BiFunction
class TracingRequestWrapperTestBase extends LibraryInstrumentationSpecification {
@Rule

View File

@ -5,9 +5,6 @@
package io.opentelemetry.instrumentation.awslambda.v1_0
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.SERVER
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.RequestHandler
import com.amazonaws.services.lambda.runtime.events.SQSEvent
@ -17,6 +14,9 @@ import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import org.junit.Rule
import org.junit.contrib.java.lang.system.EnvironmentVariables
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.SERVER
class TracingSqsEventWrapperTest extends LibraryInstrumentationSpecification {
@Rule

View File

@ -19,12 +19,13 @@ import com.amazonaws.services.sqs.AmazonSQSAsyncClient
import com.amazonaws.services.sqs.model.GetQueueAttributesRequest
import com.amazonaws.services.sqs.model.PurgeQueueRequest
import com.amazonaws.services.sqs.model.ReceiveMessageRequest
import java.time.Duration
import org.slf4j.LoggerFactory
import org.testcontainers.containers.localstack.LocalStackContainer
import org.testcontainers.containers.output.Slf4jLogConsumer
import org.testcontainers.utility.DockerImageName
import java.time.Duration
class AwsConnector {
private LocalStackContainer localstack

View File

@ -136,8 +136,11 @@ abstract class AbstractAws1ClientTest extends InstrumentationSpecification {
// Some users may implicitly subclass the request object to mimic a fluent style
"Kinesis" | "DeleteStream" | "POST" | "/" | AmazonKinesisClientBuilder.standard() | { c ->
c.deleteStream(new DeleteStreamRequest() {
{ withStreamName("somestream") }
}) } | ["aws.stream.name": "somestream"] | ""
{
withStreamName("somestream")
}
})
} | ["aws.stream.name": "somestream"] | ""
"EC2" | "AllocateAddress" | "POST" | "/" | AmazonEC2ClientBuilder.standard() | { c -> c.allocateAddress() } | [:] | """
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>

View File

@ -7,6 +7,7 @@ import io.dropwizard.Application
import io.dropwizard.Configuration
import io.dropwizard.setup.Bootstrap
import io.dropwizard.setup.Environment
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.Path

View File

@ -4,7 +4,6 @@
*/
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.TimeUnit
import org.elasticsearch.client.Client
import org.elasticsearch.common.io.FileSystemUtils
import org.elasticsearch.common.settings.Settings
@ -17,6 +16,8 @@ import org.elasticsearch.transport.Netty3Plugin
import spock.lang.Shared
import spock.lang.Unroll
import java.util.concurrent.TimeUnit
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.StatusCode.ERROR

View File

@ -4,7 +4,6 @@
*/
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.TimeUnit
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.io.FileSystemUtils
import org.elasticsearch.common.settings.Settings
@ -21,6 +20,8 @@ import org.elasticsearch.transport.client.PreBuiltTransportClient
import spock.lang.Shared
import spock.lang.Unroll
import java.util.concurrent.TimeUnit
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.StatusCode.ERROR

View File

@ -4,7 +4,6 @@
*/
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.TimeUnit
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest
import org.elasticsearch.client.Client
import org.elasticsearch.common.io.FileSystemUtils
@ -18,6 +17,8 @@ import org.elasticsearch.transport.Netty3Plugin
import spock.lang.Shared
import spock.lang.Unroll
import java.util.concurrent.TimeUnit
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.StatusCode.ERROR

View File

@ -4,7 +4,6 @@
*/
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.TimeUnit
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest
import org.elasticsearch.client.transport.TransportClient
import org.elasticsearch.common.io.FileSystemUtils
@ -22,6 +21,8 @@ import org.elasticsearch.transport.client.PreBuiltTransportClient
import spock.lang.Shared
import spock.lang.Unroll
import java.util.concurrent.TimeUnit
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import static io.opentelemetry.api.trace.SpanKind.INTERNAL
import static io.opentelemetry.api.trace.StatusCode.ERROR

View File

@ -6,6 +6,7 @@
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.javaagent.bootstrap.VirtualFieldAccessorMarker
import io.opentelemetry.javaagent.bootstrap.VirtualFieldInstalledMarker
import java.lang.reflect.Field
import java.lang.reflect.Method

View File

@ -42,7 +42,8 @@ abstract class JaxRsClientTest extends HttpClientTest<Invocation.Builder> implem
def response = request.build(method, body).invoke()
try {
response.close()
} catch (IOException ignore) {}
} catch (IOException ignore) {
}
return response.status
} catch (ProcessingException exception) {
throw exception.getCause()

View File

@ -285,7 +285,8 @@ abstract class JaxRsHttpServerTest<S> extends HttpServerTest<S> implements Agent
"$SemanticAttributes.HTTP_CLIENT_IP" TEST_CLIENT_IP
"$SemanticAttributes.HTTP_SERVER_NAME" String
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long } // Optional
// Optional
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
"$SemanticAttributes.HTTP_ROUTE" path
if (fullUrl.getPath().endsWith(ServerEndpoint.CAPTURE_HEADERS.getPath())) {
"http.request.header.x_test_request" { it == ["test"] }

View File

@ -101,7 +101,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
"$SemanticAttributes.HTTP_USER_AGENT" String
"$SemanticAttributes.HTTP_SERVER_NAME" String
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long } // Optional
// Optional
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
"$SemanticAttributes.HTTP_ROUTE" route
}
}

View File

@ -5,15 +5,15 @@
package io.opentelemetry.instrumentation.mongo.v3_1
import static io.opentelemetry.instrumentation.mongo.v3_1.MongoTracingBuilder.DEFAULT_MAX_NORMALIZED_QUERY_LENGTH
import static java.util.Arrays.asList
import org.bson.BsonArray
import org.bson.BsonDocument
import org.bson.BsonInt32
import org.bson.BsonString
import spock.lang.Specification
import static io.opentelemetry.instrumentation.mongo.v3_1.MongoTracingBuilder.DEFAULT_MAX_NORMALIZED_QUERY_LENGTH
import static java.util.Arrays.asList
class MongoDbAttributesExtractorTest extends Specification {
def 'should sanitize statements to json'() {

View File

@ -5,13 +5,13 @@
package io.opentelemetry.instrumentation.mongo.v3_1
import static io.opentelemetry.instrumentation.mongo.v3_1.MongoTracingBuilder.DEFAULT_MAX_NORMALIZED_QUERY_LENGTH
import com.mongodb.event.CommandStartedEvent
import org.bson.BsonDocument
import org.bson.BsonInt32
import spock.lang.Specification
import static io.opentelemetry.instrumentation.mongo.v3_1.MongoTracingBuilder.DEFAULT_MAX_NORMALIZED_QUERY_LENGTH
class MongoSpanNameExtractorTest extends Specification {
def 'test span name with no dbName'() {

View File

@ -5,19 +5,20 @@
package io.opentelemetry.instrumentation.mongo.testing
import static io.opentelemetry.api.trace.SpanKind.CLIENT
import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.sdk.trace.data.SpanData
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import java.util.concurrent.atomic.AtomicInteger
import org.slf4j.LoggerFactory
import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.output.Slf4jLogConsumer
import spock.lang.Shared
import java.util.concurrent.atomic.AtomicInteger
import static io.opentelemetry.api.trace.SpanKind.CLIENT
abstract class AbstractMongoClientTest<T> extends InstrumentationSpecification {
@Shared

View File

@ -7,11 +7,11 @@ import com.rabbitmq.client.ConnectionFactory
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.testcontainers.containers.GenericContainer
import java.time.Duration
import org.testcontainers.containers.output.Slf4jLogConsumer
import org.testcontainers.containers.wait.strategy.Wait
import java.time.Duration
trait WithRabbitMqTrait {
private static final Logger logger = LoggerFactory.getLogger("io.opentelemetry.testing.rabbitmq-container")

View File

@ -18,7 +18,8 @@ import ratpack.test.embed.EmbeddedApp
class RatpackFunctionalTest extends MainClassApplicationUnderTest {
Registry registry
@Lazy InMemorySpanExporter spanExporter = registry.get(SpanExporter) as InMemorySpanExporter
@Lazy
InMemorySpanExporter spanExporter = registry.get(SpanExporter) as InMemorySpanExporter
EmbeddedApp app = EmbeddedApp.of { server ->
server.handlers { chain ->
chain.get("other") { ctx -> ctx.render("hi-other") }

View File

@ -61,14 +61,18 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
where:
paramName | publisherSupplier
"basic mono" | { -> Mono.fromCallable({ i ->
"basic mono" | { ->
Mono.fromCallable({ i ->
Span.current().setAttribute("inner", "foo")
return 1
}) }
"basic flux" | { -> Flux.defer({
})
}
"basic flux" | { ->
Flux.defer({
Span.current().setAttribute("inner", "foo")
return Flux.just([5, 6].toArray())
})}
})
}
}
def "Nested non-blocking"() {
@ -139,7 +143,8 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
.runWithContext(i, Context.root().with(beforeSpan))
.doOnEach({ signal ->
assert !Span.current().getSpanContext().isValid(): "current span is not set"
})}).block()
})
}).block()
tracingOperator.registerOnEachOperator()
def result2 = Mono.fromCallable({ ->
@ -157,7 +162,8 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
if (signal.isOnComplete()) {
Span.current().end()
}
})}).block()
})
}).block()
then:
result1 == 1

View File

@ -5,6 +5,7 @@
import groovy.servlet.AbstractHttpServlet
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import javax.servlet.RequestDispatcher
import javax.servlet.ServletException
import javax.servlet.annotation.WebServlet

View File

@ -3,8 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_PARAMETERS
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import jakarta.servlet.RequestDispatcher
import jakarta.servlet.ServletException
@ -16,6 +14,7 @@ import jakarta.servlet.http.HttpServletResponse
import java.util.concurrent.CountDownLatch
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_PARAMETERS
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.EXCEPTION
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.INDEXED_CHILD

View File

@ -3,12 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import static io.opentelemetry.api.trace.SpanKind.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.PRODUCER
import static org.junit.jupiter.api.Assumptions.assumeTrue
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
abstract class AbstractSpringCloudStreamProducerTest extends InstrumentationSpecification implements WithRabbitProducerConsumerTrait {
private static final boolean HAS_PRODUCER_SPAN = Boolean.getBoolean("otel.instrumentation.spring-integration.producer.enabled")

View File

@ -7,11 +7,12 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.v7_0
import groovy.servlet.AbstractHttpServlet
import io.opentelemetry.instrumentation.test.base.HttpServerTest
import java.util.concurrent.CountDownLatch
import javax.servlet.ServletException
import javax.servlet.annotation.WebServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import java.util.concurrent.CountDownLatch
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.CAPTURE_HEADERS
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR

View File

@ -7,11 +7,12 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.v7_0
import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import org.apache.tomcat.util.threads.TaskQueue
import org.apache.tomcat.util.threads.ThreadPoolExecutor
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean
import org.apache.tomcat.util.threads.TaskQueue
import org.apache.tomcat.util.threads.ThreadPoolExecutor
class ThreadPoolExecutorTest extends AgentInstrumentationSpecification {

View File

@ -11,7 +11,6 @@ import io.opentelemetry.api.trace.SpanKind
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
import org.openqa.selenium.chrome.ChromeOptions
import org.slf4j.Logger
import org.slf4j.LoggerFactory

View File

@ -9,8 +9,8 @@ import io.opentelemetry.javaagent.tooling.muzzle.references.ClassRef
import io.opentelemetry.javaagent.tooling.muzzle.references.Flag
import io.opentelemetry.javaagent.tooling.muzzle.references.Source
import muzzle.HelperReferenceWrapperTestClasses
import org.objectweb.asm.Type
import net.bytebuddy.pool.TypePool
import org.objectweb.asm.Type
import spock.lang.Shared
import spock.lang.Specification

View File

@ -31,6 +31,7 @@ abstract class LibertyServletOnlySmokeTest extends LibertySmokeTest {
@AppServer(version = "20.0.0.12", jdk = "11")
class LibertyServletOnly20Jdk11 extends LibertySmokeTest {
}
@AppServer(version = "21.0.0.10", jdk = "11")
class LibertyServletOnly21Jdk11 extends LibertySmokeTest {
}

View File

@ -6,9 +6,10 @@
package io.opentelemetry.smoketest
import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest
import java.time.Duration
import spock.lang.IgnoreIf
import java.time.Duration
import static io.opentelemetry.smoketest.TestContainerManager.useWindowsContainers
import static java.util.stream.Collectors.toList

View File

@ -705,8 +705,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
}
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP }
@ -722,14 +722,14 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
} else {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
}
if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
} else {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
}
if (httpAttributes.contains(SemanticAttributes.HTTP_SERVER_NAME)) {
"$SemanticAttributes.HTTP_SERVER_NAME" String
@ -770,8 +770,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
}
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP }
@ -787,14 +787,14 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
} else {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
}
if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
} else {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
}
if (httpAttributes.contains(SemanticAttributes.HTTP_ROUTE)) {
// TODO(anuraaga): Revisit this when applying instrumenters to more libraries, Armeria

View File

@ -924,9 +924,7 @@ public abstract class AbstractHttpClientTest<REQUEST> {
}
}
// Optional
// TODO(anuraaga): Move to test knob rather than always treating
// as optional
// TODO(anuraaga): Move to test knob rather than always treating as optional
if (attrs.asMap().containsKey(SemanticAttributes.NET_PEER_IP)) {
if (uri.getHost().equals("192.0.2.1")) {
// NB(anuraaga): This branch seems to currently only be exercised on Java 15.