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

@ -18,63 +18,63 @@ class SqlStatementSanitizerTest extends Specification {
actualSanitized.getFullStatement() == sanitizedSql actualSanitized.getFullStatement() == sanitizedSql
where: where:
originalSql | sanitizedSql originalSql | sanitizedSql
// Numbers // 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 * 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.2" | "SELECT ?" "SELECT -1.2" | "SELECT ?"
"SELECT -1.2e-9" | "SELECT ?" "SELECT -1.2e-9" | "SELECT ?"
"SELECT 2E+9" | "SELECT ?" "SELECT 2E+9" | "SELECT ?"
"SELECT +0.2" | "SELECT ?" "SELECT +0.2" | "SELECT ?"
"SELECT .2" | "SELECT ?" "SELECT .2" | "SELECT ?"
"7" | "?" "7" | "?"
".7" | "?" ".7" | "?"
"-7" | "?" "-7" | "?"
"+7" | "?" "+7" | "?"
"SELECT 0x0af764" | "SELECT ?" "SELECT 0x0af764" | "SELECT ?"
"SELECT 0xdeadBEEF" | "SELECT ?" "SELECT 0xdeadBEEF" | "SELECT ?"
"SELECT * FROM \"TABLE\"" | "SELECT * FROM \"TABLE\"" "SELECT * FROM \"TABLE\"" | "SELECT * FROM \"TABLE\""
// Not numbers but could be confused as such // Not numbers but could be confused as such
"SELECT A + B" | "SELECT A + B" "SELECT A + B" | "SELECT A + B"
"SELECT -- comment" | "SELECT -- comment" "SELECT -- comment" | "SELECT -- comment"
"SELECT * FROM TABLE123" | "SELECT * FROM TABLE123" "SELECT * FROM TABLE123" | "SELECT * FROM TABLE123"
"SELECT FIELD2 FROM TABLE_123 WHERE X<>7" | "SELECT FIELD2 FROM TABLE_123 WHERE X<>?" "SELECT FIELD2 FROM TABLE_123 WHERE X<>7" | "SELECT FIELD2 FROM TABLE_123 WHERE X<>?"
// Semi-nonsensical almost-numbers to elide or not // Semi-nonsensical almost-numbers to elide or not
"SELECT --83--...--8e+76e3E-1" | "SELECT ?" "SELECT --83--...--8e+76e3E-1" | "SELECT ?"
"SELECT DEADBEEF" | "SELECT DEADBEEF" "SELECT DEADBEEF" | "SELECT DEADBEEF"
"SELECT 123-45-6789" | "SELECT ?" "SELECT 123-45-6789" | "SELECT ?"
"SELECT 1/2/34" | "SELECT ?/?/?" "SELECT 1/2/34" | "SELECT ?/?/?"
// Basic ' strings // Basic ' strings
"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 = '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 = ' 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 = '\\\\'" | "SELECT * FROM TABLE WHERE FIELD = ?"
"SELECT * FROM TABLE WHERE FIELD = '\"inside doubles\"'" | "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 = '\"\$\$\$\$\"'" | "SELECT * FROM TABLE WHERE FIELD = ?"
"SELECT * FROM TABLE WHERE FIELD = 'a single \" doublequote inside'" | "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 // Some databases allow using dollar-quoted strings
"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 = \$\$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 = \$\$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 = \$\$\\\\\$\$" | "SELECT * FROM TABLE WHERE FIELD = ?"
// Unicode, including a unicode identifier with a trailing number // 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 // 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 // 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"() { def "normalize couchbase #originalSql"() {

View File

@ -63,7 +63,7 @@ class TracingRequestApiGatewayWrapperTest extends TracingRequestWrapperTestBase
@Override @Override
String handleRequest(CustomType input, Context context) { String handleRequest(CustomType input, Context context) {
if (input.key == "hello") { if (input.key == "hello") {
return "Hello "+input.value return "Hello " + input.value
} }
throw new IllegalStateException("bad request") throw new IllegalStateException("bad request")
} }

View File

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

View File

@ -5,9 +5,6 @@
package io.opentelemetry.instrumentation.awslambda.v1_0 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.Context
import com.amazonaws.services.lambda.runtime.RequestHandler import com.amazonaws.services.lambda.runtime.RequestHandler
import com.amazonaws.services.lambda.runtime.events.SQSEvent 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.Rule
import org.junit.contrib.java.lang.system.EnvironmentVariables 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 { class TracingSqsEventWrapperTest extends LibraryInstrumentationSpecification {
@Rule @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.GetQueueAttributesRequest
import com.amazonaws.services.sqs.model.PurgeQueueRequest import com.amazonaws.services.sqs.model.PurgeQueueRequest
import com.amazonaws.services.sqs.model.ReceiveMessageRequest import com.amazonaws.services.sqs.model.ReceiveMessageRequest
import java.time.Duration
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import org.testcontainers.containers.localstack.LocalStackContainer import org.testcontainers.containers.localstack.LocalStackContainer
import org.testcontainers.containers.output.Slf4jLogConsumer import org.testcontainers.containers.output.Slf4jLogConsumer
import org.testcontainers.utility.DockerImageName import org.testcontainers.utility.DockerImageName
import java.time.Duration
class AwsConnector { class AwsConnector {
private LocalStackContainer localstack 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 // Some users may implicitly subclass the request object to mimic a fluent style
"Kinesis" | "DeleteStream" | "POST" | "/" | AmazonKinesisClientBuilder.standard() | { c -> "Kinesis" | "DeleteStream" | "POST" | "/" | AmazonKinesisClientBuilder.standard() | { c ->
c.deleteStream(new DeleteStreamRequest() { c.deleteStream(new DeleteStreamRequest() {
{ withStreamName("somestream") } {
}) } | ["aws.stream.name": "somestream"] | "" withStreamName("somestream")
}
})
} | ["aws.stream.name": "somestream"] | ""
"EC2" | "AllocateAddress" | "POST" | "/" | AmazonEC2ClientBuilder.standard() | { c -> c.allocateAddress() } | [:] | """ "EC2" | "AllocateAddress" | "POST" | "/" | AmazonEC2ClientBuilder.standard() | { c -> c.allocateAddress() } | [:] | """
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,7 @@ class TestController implements Controller {
@Action @Action
def child() { def child() {
HttpServerTest.controller(INDEXED_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 render INDEXED_CHILD.body
} }
} }

View File

@ -6,6 +6,7 @@
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
import io.opentelemetry.javaagent.bootstrap.VirtualFieldAccessorMarker import io.opentelemetry.javaagent.bootstrap.VirtualFieldAccessorMarker
import io.opentelemetry.javaagent.bootstrap.VirtualFieldInstalledMarker import io.opentelemetry.javaagent.bootstrap.VirtualFieldInstalledMarker
import java.lang.reflect.Field import java.lang.reflect.Field
import java.lang.reflect.Method 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() def response = request.build(method, body).invoke()
try { try {
response.close() response.close()
} catch (IOException ignore) {} } catch (IOException ignore) {
}
return response.status return response.status
} catch (ProcessingException exception) { } catch (ProcessingException exception) {
throw exception.getCause() 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_CLIENT_IP" TEST_CLIENT_IP
"$SemanticAttributes.HTTP_SERVER_NAME" String "$SemanticAttributes.HTTP_SERVER_NAME" String
"$SemanticAttributes.NET_TRANSPORT" IP_TCP "$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 "$SemanticAttributes.HTTP_ROUTE" path
if (fullUrl.getPath().endsWith(ServerEndpoint.CAPTURE_HEADERS.getPath())) { if (fullUrl.getPath().endsWith(ServerEndpoint.CAPTURE_HEADERS.getPath())) {
"http.request.header.x_test_request" { it == ["test"] } "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_USER_AGENT" String
"$SemanticAttributes.HTTP_SERVER_NAME" String "$SemanticAttributes.HTTP_SERVER_NAME" String
"$SemanticAttributes.NET_TRANSPORT" IP_TCP "$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 "$SemanticAttributes.HTTP_ROUTE" route
} }
} }

View File

@ -5,15 +5,15 @@
package io.opentelemetry.instrumentation.mongo.v3_1 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.BsonArray
import org.bson.BsonDocument import org.bson.BsonDocument
import org.bson.BsonInt32 import org.bson.BsonInt32
import org.bson.BsonString import org.bson.BsonString
import spock.lang.Specification 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 { class MongoDbAttributesExtractorTest extends Specification {
def 'should sanitize statements to json'() { def 'should sanitize statements to json'() {

View File

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

View File

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

View File

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

View File

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

View File

@ -75,7 +75,7 @@ class ContextPropagationOperatorInstrumentationTest extends AgentInstrumentation
setup: setup:
def result = Mono.defer({ -> def result = Mono.defer({ ->
Span span = GlobalOpenTelemetry.getTracer("test").spanBuilder("parent").startSpan() 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 return ContextPropagationOperator
.runWithContext(outer, Context.current().with(span)) .runWithContext(outer, Context.current().with(span))
.doFinally({ i -> span.end() }) .doFinally({ i -> span.end() })
@ -108,7 +108,7 @@ class ContextPropagationOperatorInstrumentationTest extends AgentInstrumentation
setup: setup:
def result = Flux.defer({ -> def result = Flux.defer({ ->
Span span = GlobalOpenTelemetry.getTracer("test").spanBuilder("parent").startSpan() 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 return ContextPropagationOperator
.runWithContext(outer, Context.current().with(span)) .runWithContext(outer, Context.current().with(span))
.doFinally({ i -> span.end() }) .doFinally({ i -> span.end() })

View File

@ -30,7 +30,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
def "Current in non-blocking publisher assembly"() { def "Current in non-blocking publisher assembly"() {
when: when:
runWithSpan({ runWithSpan({
return publisherSupplier().transform({ publisher -> traceNonBlocking(publisher, "inner")}) return publisherSupplier().transform({ publisher -> traceNonBlocking(publisher, "inner") })
}) })
then: then:
@ -61,19 +61,23 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
where: where:
paramName | publisherSupplier paramName | publisherSupplier
"basic mono" | { -> Mono.fromCallable({ i -> "basic mono" | { ->
Span.current().setAttribute("inner", "foo") Mono.fromCallable({ i ->
return 1 Span.current().setAttribute("inner", "foo")
}) } return 1
"basic flux" | { -> Flux.defer({ })
Span.current().setAttribute("inner", "foo") }
return Flux.just([5,6].toArray()) "basic flux" | { ->
})} Flux.defer({
Span.current().setAttribute("inner", "foo")
return Flux.just([5, 6].toArray())
})
}
} }
def "Nested non-blocking"() { def "Nested non-blocking"() {
when: when:
def result = runWithSpan({ def result = runWithSpan({
Mono.defer({ -> Mono.defer({ ->
Span.current().setAttribute("middle", "foo") Span.current().setAttribute("middle", "foo")
return Mono.fromCallable({ -> return Mono.fromCallable({ ->
@ -82,7 +86,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
}) })
.transform({ i -> traceNonBlocking(i, "inner") }) .transform({ i -> traceNonBlocking(i, "inner") })
}) })
.transform({ m -> traceNonBlocking(m, "middle")}) .transform({ m -> traceNonBlocking(m, "middle") })
}) })
then: then:
@ -128,7 +132,7 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
tracingOperator.resetOnEachOperator() tracingOperator.resetOnEachOperator()
def result1 = Mono.fromCallable({ -> 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 return 1
}) })
.transform({ i -> .transform({ i ->
@ -136,14 +140,15 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
def beforeSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("before").startSpan() def beforeSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("before").startSpan()
return ContextPropagationOperator return ContextPropagationOperator
.runWithContext(i, Context.root().with(beforeSpan)) .runWithContext(i, Context.root().with(beforeSpan))
.doOnEach({ signal -> .doOnEach({ signal ->
assert !Span.current().getSpanContext().isValid() : "current span is not set" assert !Span.current().getSpanContext().isValid(): "current span is not set"
})}).block() })
}).block()
tracingOperator.registerOnEachOperator() tracingOperator.registerOnEachOperator()
def result2 = Mono.fromCallable({ -> def result2 = Mono.fromCallable({ ->
assert Span.current().getSpanContext().isValid() : "current span is set" assert Span.current().getSpanContext().isValid(): "current span is set"
return 2 return 2
}) })
.transform({ i -> .transform({ i ->
@ -151,13 +156,14 @@ class ReactorCoreTest extends AbstractReactorCoreTest implements LibraryTestTrai
def afterSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("after").startSpan() def afterSpan = GlobalOpenTelemetry.getTracer("test").spanBuilder("after").startSpan()
return ContextPropagationOperator return ContextPropagationOperator
.runWithContext(i, Context.root().with(afterSpan)) .runWithContext(i, Context.root().with(afterSpan))
.doOnEach({ signal -> .doOnEach({ signal ->
assert Span.current().getSpanContext().isValid() : "current span is set" assert Span.current().getSpanContext().isValid(): "current span is set"
if (signal.isOnComplete()) { if (signal.isOnComplete()) {
Span.current().end() Span.current().end()
} }
})}).block() })
}).block()
then: then:
result1 == 1 result1 == 1

View File

@ -38,7 +38,7 @@ class ReactorNettyWithSpanTest extends InstrumentationSpecification implements A
def httpRequest = Mono.defer({ -> def httpRequest = Mono.defer({ ->
httpClient.get().uri("http://localhost:${server.httpPort()}/success") 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. // Make sure to consume content since that's when we close the span.
content.map { resp } content.map { resp }
}) })

View File

@ -195,7 +195,7 @@ abstract class AbstractReactorNettyHttpClientTest extends HttpClientTest<HttpCli
given: given:
def uniqueChannelHashes = new HashSet<>() def uniqueChannelHashes = new HashSet<>()
def httpClient = createHttpClient() def httpClient = createHttpClient()
.doOnConnect({ uniqueChannelHashes.add(it.channelHash())}) .doOnConnect({ uniqueChannelHashes.add(it.channelHash()) })
def uri = "http://localhost:${server.httpPort()}/success" def uri = "http://localhost:${server.httpPort()}/success"
def count = 100 def count = 100

View File

@ -13,5 +13,5 @@ class SpringBeanRouterTest extends AbstractSpringServerTest implements AgentTest
String getConfigurationName() { String getConfigurationName() {
return "springBeanRouterConf.xml" return "springBeanRouterConf.xml"
} }
} }

View File

@ -13,5 +13,5 @@ class SpringRouterTest extends AbstractSpringServerTest implements AgentTestTrai
String getConfigurationName() { String getConfigurationName() {
return "springRouterConf.xml" return "springRouterConf.xml"
} }
} }

View File

@ -43,7 +43,7 @@ class TestServlet2 {
case EXCEPTION: case EXCEPTION:
throw new Exception(endpoint.body) throw new Exception(endpoint.body)
case INDEXED_CHILD: case INDEXED_CHILD:
INDEXED_CHILD.collectSpanAttributes {name -> req.getParameter(name) } INDEXED_CHILD.collectSpanAttributes { name -> req.getParameter(name) }
resp.status = endpoint.status resp.status = endpoint.status
resp.writer.print(endpoint.body) resp.writer.print(endpoint.body)
break break

View File

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

View File

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

View File

@ -3,12 +3,12 @@
* SPDX-License-Identifier: Apache-2.0 * 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.CONSUMER
import static io.opentelemetry.api.trace.SpanKind.PRODUCER import static io.opentelemetry.api.trace.SpanKind.PRODUCER
import static org.junit.jupiter.api.Assumptions.assumeTrue import static org.junit.jupiter.api.Assumptions.assumeTrue
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
abstract class AbstractSpringCloudStreamProducerTest extends InstrumentationSpecification implements WithRabbitProducerConsumerTrait { abstract class AbstractSpringCloudStreamProducerTest extends InstrumentationSpecification implements WithRabbitProducerConsumerTrait {
private static final boolean HAS_PRODUCER_SPAN = Boolean.getBoolean("otel.instrumentation.spring-integration.producer.enabled") 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 groovy.servlet.AbstractHttpServlet
import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.instrumentation.test.base.HttpServerTest
import java.util.concurrent.CountDownLatch
import javax.servlet.ServletException import javax.servlet.ServletException
import javax.servlet.annotation.WebServlet import javax.servlet.annotation.WebServlet
import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse 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.CAPTURE_HEADERS
import static io.opentelemetry.instrumentation.test.base.HttpServerTest.ServerEndpoint.ERROR 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.api.trace.SpanKind
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification 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.CountDownLatch
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
import org.apache.tomcat.util.threads.TaskQueue
import org.apache.tomcat.util.threads.ThreadPoolExecutor
class ThreadPoolExecutorTest extends AgentInstrumentationSpecification { 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.AgentInstrumentationSpecification
import io.opentelemetry.instrumentation.test.asserts.TraceAssert import io.opentelemetry.instrumentation.test.asserts.TraceAssert
import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait import io.opentelemetry.instrumentation.test.base.HttpServerTestTrait
import org.openqa.selenium.chrome.ChromeOptions import org.openqa.selenium.chrome.ChromeOptions
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory 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.Flag
import io.opentelemetry.javaagent.tooling.muzzle.references.Source import io.opentelemetry.javaagent.tooling.muzzle.references.Source
import muzzle.HelperReferenceWrapperTestClasses import muzzle.HelperReferenceWrapperTestClasses
import org.objectweb.asm.Type
import net.bytebuddy.pool.TypePool import net.bytebuddy.pool.TypePool
import org.objectweb.asm.Type
import spock.lang.Shared import spock.lang.Shared
import spock.lang.Specification import spock.lang.Specification

View File

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

View File

@ -6,9 +6,10 @@
package io.opentelemetry.smoketest package io.opentelemetry.smoketest
import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest import io.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest
import java.time.Duration
import spock.lang.IgnoreIf import spock.lang.IgnoreIf
import java.time.Duration
import static io.opentelemetry.smoketest.TestContainerManager.useWindowsContainers import static io.opentelemetry.smoketest.TestContainerManager.useWindowsContainers
import static java.util.stream.Collectors.toList 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)) { if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) } "$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else { } else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional // Optional
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
} }
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP } "$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)) { if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
} else { } else {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional // Optional
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
} }
if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) { if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
} else { } else {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional // Optional
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
} }
if (httpAttributes.contains(SemanticAttributes.HTTP_SERVER_NAME)) { if (httpAttributes.contains(SemanticAttributes.HTTP_SERVER_NAME)) {
"$SemanticAttributes.HTTP_SERVER_NAME" String "$SemanticAttributes.HTTP_SERVER_NAME" String
@ -770,8 +770,8 @@ abstract class HttpServerTest<SERVER> extends InstrumentationSpecification imple
if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) { if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP)) {
"$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) } "$SemanticAttributes.NET_PEER_IP" { it == peerIp(endpoint) }
} else { } else {
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
// Optional // Optional
"$SemanticAttributes.NET_PEER_IP" { it == null || it == peerIp(endpoint) }
} }
"$SemanticAttributes.HTTP_CLIENT_IP" { it == null || it == TEST_CLIENT_IP } "$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)) { if (httpAttributes.contains(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
} else { } else {
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional // Optional
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" { it == null || it instanceof Long }
} }
if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) { if (httpAttributes.contains(SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH)) {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long
} else { } else {
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
// Optional // Optional
"$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" { it == null || it instanceof Long }
} }
if (httpAttributes.contains(SemanticAttributes.HTTP_ROUTE)) { if (httpAttributes.contains(SemanticAttributes.HTTP_ROUTE)) {
// TODO(anuraaga): Revisit this when applying instrumenters to more libraries, Armeria // 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 (attrs.asMap().containsKey(SemanticAttributes.NET_PEER_IP)) {
if (uri.getHost().equals("192.0.2.1")) { if (uri.getHost().equals("192.0.2.1")) {
// NB(anuraaga): This branch seems to currently only be exercised on Java 15. // NB(anuraaga): This branch seems to currently only be exercised on Java 15.