Auto-format groovy files in Intellij (#5260)
* Auto-format groovy files in Intellij * A bit of clean up
This commit is contained in:
parent
72afa5a8ed
commit
23b33adb0a
|
@ -18,63 +18,63 @@ class SqlStatementSanitizerTest extends Specification {
|
|||
actualSanitized.getFullStatement() == sanitizedSql
|
||||
|
||||
where:
|
||||
originalSql | sanitizedSql
|
||||
originalSql | sanitizedSql
|
||||
// Numbers
|
||||
"SELECT * FROM TABLE WHERE FIELD=1234" | "SELECT * FROM TABLE WHERE FIELD=?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 1234" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD>=-1234" | "SELECT * FROM TABLE WHERE FIELD>=?"
|
||||
"SELECT * FROM TABLE WHERE FIELD<-1234" | "SELECT * FROM TABLE WHERE FIELD<?"
|
||||
"SELECT * FROM TABLE WHERE FIELD <.1234" | "SELECT * FROM TABLE WHERE FIELD <?"
|
||||
"SELECT 1.2" | "SELECT ?"
|
||||
"SELECT -1.2" | "SELECT ?"
|
||||
"SELECT -1.2e-9" | "SELECT ?"
|
||||
"SELECT 2E+9" | "SELECT ?"
|
||||
"SELECT +0.2" | "SELECT ?"
|
||||
"SELECT .2" | "SELECT ?"
|
||||
"7" | "?"
|
||||
".7" | "?"
|
||||
"-7" | "?"
|
||||
"+7" | "?"
|
||||
"SELECT 0x0af764" | "SELECT ?"
|
||||
"SELECT 0xdeadBEEF" | "SELECT ?"
|
||||
"SELECT * FROM \"TABLE\"" | "SELECT * FROM \"TABLE\""
|
||||
"SELECT * FROM TABLE WHERE FIELD=1234" | "SELECT * FROM TABLE WHERE FIELD=?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 1234" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD>=-1234" | "SELECT * FROM TABLE WHERE FIELD>=?"
|
||||
"SELECT * FROM TABLE WHERE FIELD<-1234" | "SELECT * FROM TABLE WHERE FIELD<?"
|
||||
"SELECT * FROM TABLE WHERE FIELD <.1234" | "SELECT * FROM TABLE WHERE FIELD <?"
|
||||
"SELECT 1.2" | "SELECT ?"
|
||||
"SELECT -1.2" | "SELECT ?"
|
||||
"SELECT -1.2e-9" | "SELECT ?"
|
||||
"SELECT 2E+9" | "SELECT ?"
|
||||
"SELECT +0.2" | "SELECT ?"
|
||||
"SELECT .2" | "SELECT ?"
|
||||
"7" | "?"
|
||||
".7" | "?"
|
||||
"-7" | "?"
|
||||
"+7" | "?"
|
||||
"SELECT 0x0af764" | "SELECT ?"
|
||||
"SELECT 0xdeadBEEF" | "SELECT ?"
|
||||
"SELECT * FROM \"TABLE\"" | "SELECT * FROM \"TABLE\""
|
||||
|
||||
// Not numbers but could be confused as such
|
||||
"SELECT A + B" | "SELECT A + B"
|
||||
"SELECT -- comment" | "SELECT -- comment"
|
||||
"SELECT * FROM TABLE123" | "SELECT * FROM TABLE123"
|
||||
"SELECT FIELD2 FROM TABLE_123 WHERE X<>7" | "SELECT FIELD2 FROM TABLE_123 WHERE X<>?"
|
||||
"SELECT A + B" | "SELECT A + B"
|
||||
"SELECT -- comment" | "SELECT -- comment"
|
||||
"SELECT * FROM TABLE123" | "SELECT * FROM TABLE123"
|
||||
"SELECT FIELD2 FROM TABLE_123 WHERE X<>7" | "SELECT FIELD2 FROM TABLE_123 WHERE X<>?"
|
||||
|
||||
// Semi-nonsensical almost-numbers to elide or not
|
||||
"SELECT --83--...--8e+76e3E-1" | "SELECT ?"
|
||||
"SELECT DEADBEEF" | "SELECT DEADBEEF"
|
||||
"SELECT 123-45-6789" | "SELECT ?"
|
||||
"SELECT 1/2/34" | "SELECT ?/?/?"
|
||||
"SELECT --83--...--8e+76e3E-1" | "SELECT ?"
|
||||
"SELECT DEADBEEF" | "SELECT DEADBEEF"
|
||||
"SELECT 123-45-6789" | "SELECT ?"
|
||||
"SELECT 1/2/34" | "SELECT ?/?/?"
|
||||
|
||||
// Basic ' strings
|
||||
"SELECT * FROM TABLE WHERE FIELD = ''" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 'words and spaces'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = ' an escaped '' quote mark inside'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\\\\'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\"inside doubles\"'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\"\$\$\$\$\"'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 'a single \" doublequote inside'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = ''" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 'words and spaces'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = ' an escaped '' quote mark inside'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\\\\'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\"inside doubles\"'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = '\"\$\$\$\$\"'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = 'a single \" doublequote inside'" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
|
||||
// Some databases allow using dollar-quoted strings
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$words and spaces\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$quotes '\" inside\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\"''\"\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\\\\\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$words and spaces\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$quotes '\" inside\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\"''\"\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE WHERE FIELD = \$\$\\\\\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
|
||||
|
||||
// Unicode, including a unicode identifier with a trailing number
|
||||
"SELECT * FROM TABLE\u09137 WHERE FIELD = '\u0194'" | "SELECT * FROM TABLE\u09137 WHERE FIELD = ?"
|
||||
"SELECT * FROM TABLE\u09137 WHERE FIELD = '\u0194'" | "SELECT * FROM TABLE\u09137 WHERE FIELD = ?"
|
||||
|
||||
// whitespace normalization
|
||||
"SELECT * \t\r\nFROM TABLE WHERE FIELD1 = 12344 AND FIELD2 = 5678" | "SELECT * FROM TABLE WHERE FIELD1 = ? AND FIELD2 = ?"
|
||||
"SELECT * \t\r\nFROM TABLE WHERE FIELD1 = 12344 AND FIELD2 = 5678" | "SELECT * FROM TABLE WHERE FIELD1 = ? AND FIELD2 = ?"
|
||||
|
||||
// hibernate/jpa query language
|
||||
"FROM TABLE WHERE FIELD=1234" | "FROM TABLE WHERE FIELD=?"
|
||||
"FROM TABLE WHERE FIELD=1234" | "FROM TABLE WHERE FIELD=?"
|
||||
}
|
||||
|
||||
def "normalize couchbase #originalSql"() {
|
||||
|
|
|
@ -63,7 +63,7 @@ class TracingRequestApiGatewayWrapperTest extends TracingRequestWrapperTestBase
|
|||
@Override
|
||||
String handleRequest(CustomType input, Context context) {
|
||||
if (input.key == "hello") {
|
||||
return "Hello "+input.value
|
||||
return "Hello " + input.value
|
||||
}
|
||||
throw new IllegalStateException("bad request")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -78,7 +78,7 @@ class TestController implements Controller {
|
|||
@Action
|
||||
def child() {
|
||||
HttpServerTest.controller(INDEXED_CHILD) {
|
||||
INDEXED_CHILD.collectSpanAttributes({name -> name == "id" ? params.id : null })
|
||||
INDEXED_CHILD.collectSpanAttributes({ name -> name == "id" ? params.id : null })
|
||||
render INDEXED_CHILD.body
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"] }
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'() {
|
||||
|
|
|
@ -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'() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ import ratpack.test.embed.EmbeddedApp
|
|||
class RatpackFunctionalTest extends MainClassApplicationUnderTest {
|
||||
|
||||
Registry registry
|
||||
@Lazy InMemorySpanExporter spanExporter = registry.get(SpanExporter) as InMemorySpanExporter
|
||||
EmbeddedApp app = EmbeddedApp.of { server ->
|
||||
@Lazy
|
||||
InMemorySpanExporter spanExporter = registry.get(SpanExporter) as InMemorySpanExporter
|
||||
EmbeddedApp app = EmbeddedApp.of { server ->
|
||||
server.handlers { chain ->
|
||||
chain.get("other") { ctx -> ctx.render("hi-other") }
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class ContextPropagationOperatorInstrumentationTest extends AgentInstrumentation
|
|||
setup:
|
||||
def result = Mono.defer({ ->
|
||||
Span span = GlobalOpenTelemetry.getTracer("test").spanBuilder("parent").startSpan()
|
||||
def outer = Mono.defer({ -> new TracedWithSpan().mono(Mono.just("Value") )});
|
||||
def outer = Mono.defer({ -> new TracedWithSpan().mono(Mono.just("Value")) });
|
||||
return ContextPropagationOperator
|
||||
.runWithContext(outer, Context.current().with(span))
|
||||
.doFinally({ i -> span.end() })
|
||||
|
@ -108,7 +108,7 @@ class ContextPropagationOperatorInstrumentationTest extends AgentInstrumentation
|
|||
setup:
|
||||
def result = Flux.defer({ ->
|
||||
Span span = GlobalOpenTelemetry.getTracer("test").spanBuilder("parent").startSpan()
|
||||
def outer = Flux.defer({ -> new TracedWithSpan().flux(Flux.just("Value") )});
|
||||
def outer = Flux.defer({ -> new TracedWithSpan().flux(Flux.just("Value")) });
|
||||
return ContextPropagationOperator
|
||||
.runWithContext(outer, Context.current().with(span))
|
||||
.doFinally({ i -> span.end() })
|
||||
|
|
|
@ -30,7 +30,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
def "Current in non-blocking publisher assembly"() {
|
||||
when:
|
||||
runWithSpan({
|
||||
return publisherSupplier().transform({ publisher -> traceNonBlocking(publisher, "inner")})
|
||||
return publisherSupplier().transform({ publisher -> traceNonBlocking(publisher, "inner") })
|
||||
})
|
||||
|
||||
then:
|
||||
|
@ -61,19 +61,23 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
|
||||
where:
|
||||
paramName | publisherSupplier
|
||||
"basic mono" | { -> Mono.fromCallable({ i ->
|
||||
Span.current().setAttribute("inner", "foo")
|
||||
return 1
|
||||
}) }
|
||||
"basic flux" | { -> Flux.defer({
|
||||
Span.current().setAttribute("inner", "foo")
|
||||
return Flux.just([5,6].toArray())
|
||||
})}
|
||||
"basic mono" | { ->
|
||||
Mono.fromCallable({ i ->
|
||||
Span.current().setAttribute("inner", "foo")
|
||||
return 1
|
||||
})
|
||||
}
|
||||
"basic flux" | { ->
|
||||
Flux.defer({
|
||||
Span.current().setAttribute("inner", "foo")
|
||||
return Flux.just([5, 6].toArray())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
def "Nested non-blocking"() {
|
||||
when:
|
||||
def result = runWithSpan({
|
||||
def result = runWithSpan({
|
||||
Mono.defer({ ->
|
||||
Span.current().setAttribute("middle", "foo")
|
||||
return Mono.fromCallable({ ->
|
||||
|
@ -82,7 +86,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
})
|
||||
.transform({ i -> traceNonBlocking(i, "inner") })
|
||||
})
|
||||
.transform({ m -> traceNonBlocking(m, "middle")})
|
||||
.transform({ m -> traceNonBlocking(m, "middle") })
|
||||
})
|
||||
|
||||
then:
|
||||
|
@ -128,7 +132,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
tracingOperator.resetOnEachOperator()
|
||||
|
||||
def result1 = Mono.fromCallable({ ->
|
||||
assert !Span.current().getSpanContext().isValid() : "current span is not set"
|
||||
assert !Span.current().getSpanContext().isValid(): "current span is not set"
|
||||
return 1
|
||||
})
|
||||
.transform({ i ->
|
||||
|
@ -136,14 +140,15 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
def beforeSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("before").startSpan()
|
||||
|
||||
return ContextPropagationOperator
|
||||
.runWithContext(i, Context.root().with(beforeSpan))
|
||||
.runWithContext(i, Context.root().with(beforeSpan))
|
||||
.doOnEach({ signal ->
|
||||
assert !Span.current().getSpanContext().isValid() : "current span is not set"
|
||||
})}).block()
|
||||
assert !Span.current().getSpanContext().isValid(): "current span is not set"
|
||||
})
|
||||
}).block()
|
||||
|
||||
tracingOperator.registerOnEachOperator()
|
||||
def result2 = Mono.fromCallable({ ->
|
||||
assert Span.current().getSpanContext().isValid() : "current span is set"
|
||||
assert Span.current().getSpanContext().isValid(): "current span is set"
|
||||
return 2
|
||||
})
|
||||
.transform({ i ->
|
||||
|
@ -151,13 +156,14 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
|
|||
def afterSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("after").startSpan()
|
||||
|
||||
return ContextPropagationOperator
|
||||
.runWithContext(i, Context.root().with(afterSpan))
|
||||
.runWithContext(i, Context.root().with(afterSpan))
|
||||
.doOnEach({ signal ->
|
||||
assert Span.current().getSpanContext().isValid() : "current span is set"
|
||||
assert Span.current().getSpanContext().isValid(): "current span is set"
|
||||
if (signal.isOnComplete()) {
|
||||
Span.current().end()
|
||||
}
|
||||
})}).block()
|
||||
})
|
||||
}).block()
|
||||
|
||||
then:
|
||||
result1 == 1
|
||||
|
|
|
@ -38,7 +38,7 @@ class ReactorNettyWithSpanTest extends InstrumentationSpecification implements A
|
|||
|
||||
def httpRequest = Mono.defer({ ->
|
||||
httpClient.get().uri("http://localhost:${server.httpPort()}/success")
|
||||
.responseSingle ({ resp, content ->
|
||||
.responseSingle({ resp, content ->
|
||||
// Make sure to consume content since that's when we close the span.
|
||||
content.map { resp }
|
||||
})
|
||||
|
|
|
@ -195,7 +195,7 @@ abstract class AbstractReactorNettyHttpClientTest extends HttpClientTest<HttpCli
|
|||
given:
|
||||
def uniqueChannelHashes = new HashSet<>()
|
||||
def httpClient = createHttpClient()
|
||||
.doOnConnect({ uniqueChannelHashes.add(it.channelHash())})
|
||||
.doOnConnect({ uniqueChannelHashes.add(it.channelHash()) })
|
||||
def uri = "http://localhost:${server.httpPort()}/success"
|
||||
|
||||
def count = 100
|
||||
|
|
|
@ -13,5 +13,5 @@ class SpringBeanRouterTest extends AbstractSpringServerTest implements AgentTest
|
|||
String getConfigurationName() {
|
||||
return "springBeanRouterConf.xml"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ class SpringRouterTest extends AbstractSpringServerTest implements AgentTestTrai
|
|||
String getConfigurationName() {
|
||||
return "springRouterConf.xml"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestServlet2 {
|
|||
case EXCEPTION:
|
||||
throw new Exception(endpoint.body)
|
||||
case INDEXED_CHILD:
|
||||
INDEXED_CHILD.collectSpanAttributes {name -> req.getParameter(name) }
|
||||
INDEXED_CHILD.collectSpanAttributes { name -> req.getParameter(name) }
|
||||
resp.status = endpoint.status
|
||||
resp.writer.print(endpoint.body)
|
||||
break
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 {
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue