Rename "integration" to "instrumentation" (#1412)
* Rename integration to instrumentation * Revert doc changes, need to wait for release * spotless
This commit is contained in:
parent
29ec067ef5
commit
57301e3fe7
|
@ -129,20 +129,21 @@ public abstract class Config {
|
|||
}
|
||||
}
|
||||
|
||||
// some integrations have '-' or '_' character in their names -- this does not work well with
|
||||
// some instrumentation names have '-' or '_' character -- this does not work well with
|
||||
// environment variables (where we replace every non-alphanumeric character with '.'), so we're
|
||||
// replacing those with a dot
|
||||
public static String normalizePropertyName(String propertyName) {
|
||||
return PROPERTY_NAME_REPLACEMENTS.matcher(propertyName.toLowerCase()).replaceAll(".");
|
||||
}
|
||||
|
||||
public boolean isIntegrationEnabled(SortedSet<String> integrationNames, boolean defaultEnabled) {
|
||||
public boolean isInstrumentationEnabled(
|
||||
SortedSet<String> instrumentationNames, boolean defaultEnabled) {
|
||||
// If default is enabled, we want to enable individually,
|
||||
// if default is disabled, we want to disable individually.
|
||||
boolean anyEnabled = defaultEnabled;
|
||||
for (String name : integrationNames) {
|
||||
for (String name : instrumentationNames) {
|
||||
boolean configEnabled =
|
||||
getBooleanProperty("otel.integration." + name + ".enabled", defaultEnabled);
|
||||
getBooleanProperty("otel.instrumentation." + name + ".enabled", defaultEnabled);
|
||||
|
||||
if (defaultEnabled) {
|
||||
anyEnabled &= configEnabled;
|
||||
|
|
|
@ -8,18 +8,18 @@ package io.opentelemetry.instrumentation.api.config
|
|||
import spock.lang.Specification
|
||||
|
||||
class ConfigTest extends Specification {
|
||||
def "verify integration config"() {
|
||||
def "verify instrumentation config"() {
|
||||
setup:
|
||||
def config = Config.create([
|
||||
"otel.integration.order.enabled" : "true",
|
||||
"otel.integration.test.prop.enabled" : "true",
|
||||
"otel.integration.disabled.prop.enabled": "false",
|
||||
"otel.integration.test.env.enabled" : "true",
|
||||
"otel.integration.disabled.env.enabled" : "false"
|
||||
"otel.instrumentation.order.enabled" : "true",
|
||||
"otel.instrumentation.test.prop.enabled" : "true",
|
||||
"otel.instrumentation.disabled.prop.enabled": "false",
|
||||
"otel.instrumentation.test.env.enabled" : "true",
|
||||
"otel.instrumentation.disabled.env.enabled" : "false"
|
||||
])
|
||||
|
||||
expect:
|
||||
config.isIntegrationEnabled(integrationNames, defaultEnabled) == expected
|
||||
config.isInstrumentationEnabled(instrumentationNames, defaultEnabled) == expected
|
||||
|
||||
where:
|
||||
names | defaultEnabled | expected
|
||||
|
@ -39,7 +39,7 @@ class ConfigTest extends Specification {
|
|||
["test-prop", "disabled-prop"] | true | false
|
||||
["disabled-env", "test-env"] | true | false
|
||||
|
||||
integrationNames = new TreeSet<String>(names)
|
||||
instrumentationNames = new TreeSet<String>(names)
|
||||
}
|
||||
|
||||
def "should get string property"() {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
package io.opentelemetry.instrumentation.reactor
|
||||
|
||||
import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan
|
||||
|
||||
import io.opentelemetry.OpenTelemetry
|
||||
import io.opentelemetry.instrumentation.test.InstrumentationTestRunner
|
||||
import io.opentelemetry.instrumentation.test.utils.TraceUtils
|
||||
|
@ -17,8 +19,6 @@ import reactor.core.publisher.Flux
|
|||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Shared
|
||||
|
||||
import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan
|
||||
|
||||
class ReactorCoreTest extends InstrumentationTestRunner {
|
||||
|
||||
public static final String EXCEPTION_MESSAGE = "test exception"
|
||||
|
@ -111,7 +111,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {
|
|||
}
|
||||
|
||||
// It's important that we don't attach errors at the Reactor level so that we don't
|
||||
// impact the spans on reactor integrations such as netty and lettuce, as reactor is
|
||||
// impact the spans on reactor instrumentations such as netty and lettuce, as reactor is
|
||||
// more of a context propagation mechanism than something we would be tracking for
|
||||
// errors this is ok.
|
||||
basicSpan(it, 1, "publisher-parent", span(0))
|
||||
|
@ -142,7 +142,7 @@ class ReactorCoreTest extends InstrumentationTestRunner {
|
|||
}
|
||||
|
||||
// It's important that we don't attach errors at the Reactor level so that we don't
|
||||
// impact the spans on reactor integrations such as netty and lettuce, as reactor is
|
||||
// impact the spans on reactor instrumentations such as netty and lettuce, as reactor is
|
||||
// more of a context propagation mechanism than something we would be tracking for
|
||||
// errors this is ok.
|
||||
basicSpan(it, 1, "publisher-parent", span(0))
|
||||
|
|
|
@ -7,44 +7,44 @@ import io.opentelemetry.instrumentation.test.AgentTestRunner
|
|||
|
||||
class AkkaActorTest extends AgentTestRunner {
|
||||
|
||||
// TODO this test doesn't really depend on otel.integration.akka_context_propagation.enabled=true
|
||||
// but setting this property here is needed when running both this test
|
||||
// and AkkaExecutorInstrumentationTest in the run, otherwise get
|
||||
// "class redefinition failed: attempted to change superclass or interfaces"
|
||||
// on whichever test runs second
|
||||
// (related question is what's the purpose of this test if it doesn't depend on any of the
|
||||
// instrumentation in this module, is it just to verify that the instrumentation doesn't break
|
||||
// this scenario?)
|
||||
static {
|
||||
System.setProperty("otel.integration.akka_context_propagation.enabled", "true")
|
||||
}
|
||||
|
||||
def "akka #testMethod"() {
|
||||
setup:
|
||||
AkkaActors akkaTester = new AkkaActors()
|
||||
akkaTester."$testMethod"()
|
||||
|
||||
expect:
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
span(0) {
|
||||
name "parent"
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
name "$expectedGreeting, Akka"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO this test doesn't really depend on otel.instrumentation.akka_context_propagation.enabled=true
|
||||
// but setting this property here is needed when running both this test
|
||||
// and AkkaExecutorInstrumentationTest in the run, otherwise get
|
||||
// "class redefinition failed: attempted to change superclass or interfaces"
|
||||
// on whichever test runs second
|
||||
// (related question is what's the purpose of this test if it doesn't depend on any of the
|
||||
// instrumentation in this module, is it just to verify that the instrumentation doesn't break
|
||||
// this scenario?)
|
||||
static {
|
||||
System.setProperty("otel.instrumentation.akka_context_propagation.enabled", "true")
|
||||
}
|
||||
|
||||
where:
|
||||
testMethod | expectedGreeting
|
||||
"basicTell" | "Howdy"
|
||||
"basicAsk" | "Howdy"
|
||||
"basicForward" | "Hello"
|
||||
}
|
||||
def "akka #testMethod"() {
|
||||
setup:
|
||||
AkkaActors akkaTester = new AkkaActors()
|
||||
akkaTester."$testMethod"()
|
||||
|
||||
expect:
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
span(0) {
|
||||
name "parent"
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
span(1) {
|
||||
name "$expectedGreeting, Akka"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
where:
|
||||
testMethod | expectedGreeting
|
||||
"basicTell" | "Howdy"
|
||||
"basicAsk" | "Howdy"
|
||||
"basicForward" | "Hello"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import spock.lang.Shared
|
|||
class AkkaExecutorInstrumentationTest extends AgentTestRunner {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.akka_context_propagation.enabled", "true")
|
||||
System.setProperty("otel.instrumentation.akka_context_propagation.enabled", "true")
|
||||
}
|
||||
|
||||
@Shared
|
||||
|
|
|
@ -38,176 +38,176 @@ import org.glassfish.grizzly.utils.IdleTimeoutFilter
|
|||
|
||||
class GrizzlyFilterchainServerTest extends HttpServerTest<HttpServer> {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.grizzly.enabled", "true")
|
||||
}
|
||||
static {
|
||||
System.setProperty("otel.instrumentation.grizzly.enabled", "true")
|
||||
}
|
||||
|
||||
private TCPNIOTransport transport
|
||||
private TCPNIOServerConnection serverConnection
|
||||
|
||||
@Override
|
||||
HttpServer startServer(int port) {
|
||||
FilterChain filterChain = setUpFilterChain()
|
||||
setUpTransport(filterChain)
|
||||
|
||||
serverConnection = transport.bind("127.0.0.1", port)
|
||||
transport.start()
|
||||
return null
|
||||
}
|
||||
|
||||
@Override
|
||||
void stopServer(HttpServer httpServer) {
|
||||
transport.shutdownNow()
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean testException() {
|
||||
// justification: grizzly async closes the channel which
|
||||
// looks like a ConnectException to the client when this happens
|
||||
false
|
||||
}
|
||||
|
||||
void setUpTransport(FilterChain filterChain) {
|
||||
TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance()
|
||||
.setOptimizedForMultiplexing(true)
|
||||
|
||||
transportBuilder.setTcpNoDelay(true)
|
||||
transportBuilder.setKeepAlive(false)
|
||||
transportBuilder.setReuseAddress(true)
|
||||
transportBuilder.setServerConnectionBackLog(50)
|
||||
transportBuilder.setServerSocketSoTimeout(80000)
|
||||
|
||||
transport = transportBuilder.build()
|
||||
transport.setProcessor(filterChain)
|
||||
}
|
||||
|
||||
FilterChain setUpFilterChain() {
|
||||
return FilterChainBuilder.stateless()
|
||||
.add(createTransportFilter())
|
||||
.add(createIdleTimeoutFilter())
|
||||
.add(new HttpServerFilter())
|
||||
.add(new LastFilter())
|
||||
.build()
|
||||
}
|
||||
|
||||
TransportFilter createTransportFilter() {
|
||||
return new TransportFilter()
|
||||
}
|
||||
|
||||
IdleTimeoutFilter createIdleTimeoutFilter() {
|
||||
return new IdleTimeoutFilter(new DelayedExecutor(Executors.newCachedThreadPool()), 80000, MILLISECONDS)
|
||||
}
|
||||
|
||||
class LastFilter extends BaseFilter {
|
||||
private TCPNIOTransport transport
|
||||
private TCPNIOServerConnection serverConnection
|
||||
|
||||
@Override
|
||||
NextAction handleRead(final FilterChainContext ctx) throws IOException {
|
||||
if (ctx.getMessage() instanceof HttpContent) {
|
||||
HttpContent httpContent = ctx.getMessage()
|
||||
HttpHeader httpHeader = httpContent.getHttpHeader()
|
||||
if (httpHeader instanceof HttpRequestPacket) {
|
||||
HttpRequestPacket request = (HttpRequestPacket) httpContent.getHttpHeader()
|
||||
ResponseParameters responseParameters = buildResponse(request)
|
||||
HttpResponsePacket.Builder builder = HttpResponsePacket.builder(request)
|
||||
.status(responseParameters.getStatus())
|
||||
.header("Content-Length", valueOf(responseParameters.getResponseBody().length))
|
||||
responseParameters.fillHeaders(builder)
|
||||
HttpResponsePacket responsePacket = builder.build()
|
||||
controller(responseParameters.getEndpoint()) {
|
||||
ctx.write(HttpContent.builder(responsePacket)
|
||||
.content(wrap(ctx.getMemoryManager(), responseParameters.getResponseBody()))
|
||||
.build())
|
||||
}
|
||||
HttpServer startServer(int port) {
|
||||
FilterChain filterChain = setUpFilterChain()
|
||||
setUpTransport(filterChain)
|
||||
|
||||
serverConnection = transport.bind("127.0.0.1", port)
|
||||
transport.start()
|
||||
return null
|
||||
}
|
||||
|
||||
@Override
|
||||
void stopServer(HttpServer httpServer) {
|
||||
transport.shutdownNow()
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean testException() {
|
||||
// justification: grizzly async closes the channel which
|
||||
// looks like a ConnectException to the client when this happens
|
||||
false
|
||||
}
|
||||
|
||||
void setUpTransport(FilterChain filterChain) {
|
||||
TCPNIOTransportBuilder transportBuilder = TCPNIOTransportBuilder.newInstance()
|
||||
.setOptimizedForMultiplexing(true)
|
||||
|
||||
transportBuilder.setTcpNoDelay(true)
|
||||
transportBuilder.setKeepAlive(false)
|
||||
transportBuilder.setReuseAddress(true)
|
||||
transportBuilder.setServerConnectionBackLog(50)
|
||||
transportBuilder.setServerSocketSoTimeout(80000)
|
||||
|
||||
transport = transportBuilder.build()
|
||||
transport.setProcessor(filterChain)
|
||||
}
|
||||
|
||||
FilterChain setUpFilterChain() {
|
||||
return FilterChainBuilder.stateless()
|
||||
.add(createTransportFilter())
|
||||
.add(createIdleTimeoutFilter())
|
||||
.add(new HttpServerFilter())
|
||||
.add(new LastFilter())
|
||||
.build()
|
||||
}
|
||||
|
||||
TransportFilter createTransportFilter() {
|
||||
return new TransportFilter()
|
||||
}
|
||||
|
||||
IdleTimeoutFilter createIdleTimeoutFilter() {
|
||||
return new IdleTimeoutFilter(new DelayedExecutor(Executors.newCachedThreadPool()), 80000, MILLISECONDS)
|
||||
}
|
||||
|
||||
class LastFilter extends BaseFilter {
|
||||
|
||||
@Override
|
||||
NextAction handleRead(final FilterChainContext ctx) throws IOException {
|
||||
if (ctx.getMessage() instanceof HttpContent) {
|
||||
HttpContent httpContent = ctx.getMessage()
|
||||
HttpHeader httpHeader = httpContent.getHttpHeader()
|
||||
if (httpHeader instanceof HttpRequestPacket) {
|
||||
HttpRequestPacket request = (HttpRequestPacket) httpContent.getHttpHeader()
|
||||
ResponseParameters responseParameters = buildResponse(request)
|
||||
HttpResponsePacket.Builder builder = HttpResponsePacket.builder(request)
|
||||
.status(responseParameters.getStatus())
|
||||
.header("Content-Length", valueOf(responseParameters.getResponseBody().length))
|
||||
responseParameters.fillHeaders(builder)
|
||||
HttpResponsePacket responsePacket = builder.build()
|
||||
controller(responseParameters.getEndpoint()) {
|
||||
ctx.write(HttpContent.builder(responsePacket)
|
||||
.content(wrap(ctx.getMemoryManager(), responseParameters.getResponseBody()))
|
||||
.build())
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctx.getStopAction()
|
||||
}
|
||||
}
|
||||
return ctx.getStopAction()
|
||||
}
|
||||
|
||||
ResponseParameters buildResponse(HttpRequestPacket request) {
|
||||
String uri = request.getRequestURI()
|
||||
String requestParams = request.getQueryString()
|
||||
String fullPath = uri + (requestParams != null ? "?" + requestParams : "")
|
||||
ResponseParameters buildResponse(HttpRequestPacket request) {
|
||||
String uri = request.getRequestURI()
|
||||
String requestParams = request.getQueryString()
|
||||
String fullPath = uri + (requestParams != null ? "?" + requestParams : "")
|
||||
|
||||
Map<String, String> headers = new HashMap<>()
|
||||
Map<String, String> headers = new HashMap<>()
|
||||
|
||||
HttpServerTest.ServerEndpoint endpoint
|
||||
switch (fullPath) {
|
||||
case "/success":
|
||||
endpoint = SUCCESS
|
||||
break
|
||||
case "/redirect":
|
||||
endpoint = REDIRECT
|
||||
headers.put("location", REDIRECT.body)
|
||||
break
|
||||
case "/error-status":
|
||||
endpoint = ERROR
|
||||
break
|
||||
case "/exception":
|
||||
throw new Exception(EXCEPTION.body)
|
||||
case "/notFound":
|
||||
endpoint = NOT_FOUND
|
||||
break
|
||||
case "/query?some=query":
|
||||
endpoint = QUERY_PARAM
|
||||
break
|
||||
case "/path/123/param":
|
||||
endpoint = PATH_PARAM
|
||||
break
|
||||
case "/authRequired":
|
||||
endpoint = AUTH_REQUIRED
|
||||
break
|
||||
default:
|
||||
endpoint = NOT_FOUND
|
||||
break
|
||||
}
|
||||
HttpServerTest.ServerEndpoint endpoint
|
||||
switch (fullPath) {
|
||||
case "/success":
|
||||
endpoint = SUCCESS
|
||||
break
|
||||
case "/redirect":
|
||||
endpoint = REDIRECT
|
||||
headers.put("location", REDIRECT.body)
|
||||
break
|
||||
case "/error-status":
|
||||
endpoint = ERROR
|
||||
break
|
||||
case "/exception":
|
||||
throw new Exception(EXCEPTION.body)
|
||||
case "/notFound":
|
||||
endpoint = NOT_FOUND
|
||||
break
|
||||
case "/query?some=query":
|
||||
endpoint = QUERY_PARAM
|
||||
break
|
||||
case "/path/123/param":
|
||||
endpoint = PATH_PARAM
|
||||
break
|
||||
case "/authRequired":
|
||||
endpoint = AUTH_REQUIRED
|
||||
break
|
||||
default:
|
||||
endpoint = NOT_FOUND
|
||||
break
|
||||
}
|
||||
|
||||
int status = endpoint.status
|
||||
String responseBody = endpoint == REDIRECT ? "" : endpoint.body
|
||||
int status = endpoint.status
|
||||
String responseBody = endpoint == REDIRECT ? "" : endpoint.body
|
||||
|
||||
byte[] responseBodyBytes = responseBody.getBytes(defaultCharset())
|
||||
return new ResponseParameters(endpoint, status, responseBodyBytes, headers)
|
||||
}
|
||||
|
||||
class ResponseParameters {
|
||||
Map<String, String> headers
|
||||
HttpServerTest.ServerEndpoint endpoint
|
||||
int status
|
||||
byte[] responseBody
|
||||
|
||||
ResponseParameters(HttpServerTest.ServerEndpoint endpoint,
|
||||
int status,
|
||||
byte[] responseBody,
|
||||
Map<String, String> headers) {
|
||||
this.endpoint = endpoint
|
||||
this.status = status
|
||||
this.responseBody = responseBody
|
||||
this.headers = headers
|
||||
}
|
||||
|
||||
int getStatus() {
|
||||
return status
|
||||
}
|
||||
|
||||
byte[] getResponseBody() {
|
||||
return responseBody
|
||||
}
|
||||
|
||||
HttpServerTest.ServerEndpoint getEndpoint() {
|
||||
return endpoint
|
||||
}
|
||||
|
||||
void fillHeaders(HttpResponsePacket.Builder builder) {
|
||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
||||
builder.header(header.getKey(), header.getValue())
|
||||
byte[] responseBodyBytes = responseBody.getBytes(defaultCharset())
|
||||
return new ResponseParameters(endpoint, status, responseBodyBytes, headers)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
||||
return "HttpCodecFilter.handleRead"
|
||||
}
|
||||
class ResponseParameters {
|
||||
Map<String, String> headers
|
||||
HttpServerTest.ServerEndpoint endpoint
|
||||
int status
|
||||
byte[] responseBody
|
||||
|
||||
ResponseParameters(HttpServerTest.ServerEndpoint endpoint,
|
||||
int status,
|
||||
byte[] responseBody,
|
||||
Map<String, String> headers) {
|
||||
this.endpoint = endpoint
|
||||
this.status = status
|
||||
this.responseBody = responseBody
|
||||
this.headers = headers
|
||||
}
|
||||
|
||||
int getStatus() {
|
||||
return status
|
||||
}
|
||||
|
||||
byte[] getResponseBody() {
|
||||
return responseBody
|
||||
}
|
||||
|
||||
HttpServerTest.ServerEndpoint getEndpoint() {
|
||||
return endpoint
|
||||
}
|
||||
|
||||
void fillHeaders(HttpResponsePacket.Builder builder) {
|
||||
for (Map.Entry<String, String> header : headers.entrySet()) {
|
||||
builder.header(header.getKey(), header.getValue())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
String expectedServerSpanName(String method, ServerEndpoint endpoint) {
|
||||
return "HttpCodecFilter.handleRead"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.glassfish.jersey.server.ResourceConfig
|
|||
class GrizzlyTest extends HttpServerTest<HttpServer> {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.grizzly.enabled", "true")
|
||||
System.setProperty("otel.instrumentation.grizzly.enabled", "true")
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ import spock.lang.Shared
|
|||
class GrizzlyAsyncHttpClientTest extends HttpClientTest {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.grizzly-client.enabled", "true")
|
||||
System.setProperty("otel.instrumentation.grizzly-client.enabled", "true")
|
||||
}
|
||||
|
||||
@AutoCleanup
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Integration for Hibernate between 3.5 and 4.
|
||||
* Has the same logic as the Hibernate 4+ integration, but is copied rather than sharing a codebase. This is because
|
||||
* Instrumentation for Hibernate between 3.5 and 4.
|
||||
* Has the same logic as the Hibernate 4+ instrumentation, but is copied rather than sharing a codebase. This is because
|
||||
* the root interface for Session/StatelessSession - SharedSessionContract - isn't present before version 4. So the
|
||||
* instrumentation isn't able to reference it.
|
||||
*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,6 +3,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan
|
||||
|
||||
import io.opentelemetry.OpenTelemetry
|
||||
import io.opentelemetry.instrumentation.test.AgentTestRunner
|
||||
import io.opentelemetry.instrumentation.test.utils.TraceUtils
|
||||
|
@ -14,8 +16,6 @@ import reactor.core.publisher.Flux
|
|||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Shared
|
||||
|
||||
import static io.opentelemetry.instrumentation.test.utils.TraceUtils.basicSpan
|
||||
|
||||
class ReactorCoreTest extends AgentTestRunner {
|
||||
|
||||
public static final String EXCEPTION_MESSAGE = "test exception"
|
||||
|
@ -114,7 +114,7 @@ class ReactorCoreTest extends AgentTestRunner {
|
|||
}
|
||||
|
||||
// It's important that we don't attach errors at the Reactor level so that we don't
|
||||
// impact the spans on reactor integrations such as netty and lettuce, as reactor is
|
||||
// impact the spans on reactor instrumentations such as netty and lettuce, as reactor is
|
||||
// more of a context propagation mechanism than something we would be tracking for
|
||||
// errors this is ok.
|
||||
basicSpan(it, 1, "publisher-parent", span(0))
|
||||
|
@ -122,9 +122,9 @@ class ReactorCoreTest extends AgentTestRunner {
|
|||
}
|
||||
|
||||
where:
|
||||
paramName | publisherSupplier
|
||||
"mono" | { -> Mono.error(new RuntimeException(EXCEPTION_MESSAGE)) }
|
||||
"flux" | { -> Flux.error(new RuntimeException(EXCEPTION_MESSAGE)) }
|
||||
paramName | publisherSupplier
|
||||
"mono" | { -> Mono.error(new RuntimeException(EXCEPTION_MESSAGE)) }
|
||||
"flux" | { -> Flux.error(new RuntimeException(EXCEPTION_MESSAGE)) }
|
||||
}
|
||||
|
||||
def "Publisher step '#name' test"() {
|
||||
|
@ -145,7 +145,7 @@ class ReactorCoreTest extends AgentTestRunner {
|
|||
}
|
||||
|
||||
// It's important that we don't attach errors at the Reactor level so that we don't
|
||||
// impact the spans on reactor integrations such as netty and lettuce, as reactor is
|
||||
// impact the spans on reactor instrumentations such as netty and lettuce, as reactor is
|
||||
// more of a context propagation mechanism than something we would be tracking for
|
||||
// errors this is ok.
|
||||
basicSpan(it, 1, "publisher-parent", span(0))
|
||||
|
|
|
@ -21,7 +21,7 @@ abstract class JettyServlet3Test extends AbstractServlet3Test<Server, ServletCon
|
|||
|
||||
//We want to test spans produced by servlet instrumentation, not those of jetty
|
||||
static final PREVIOUS_CONFIG = ConfigUtils.updateConfigAndResetInstrumentation {
|
||||
it.setProperty("otel.integration.jetty.enabled", "false")
|
||||
it.setProperty("otel.instrumentation.jetty.enabled", "false")
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,50 +11,50 @@ import org.eclipse.jetty.servlet.ServletHandler
|
|||
|
||||
class JettyServletHandlerTest extends AbstractServlet3Test<Server, ServletHandler> {
|
||||
|
||||
static {
|
||||
//We want to test spans produced by servlet instrumentation, not those of jetty
|
||||
System.setProperty("otel.integration.jetty.enabled", "false")
|
||||
}
|
||||
static {
|
||||
//We want to test spans produced by servlet instrumentation, not those of jetty
|
||||
System.setProperty("otel.instrumentation.jetty.enabled", "false")
|
||||
}
|
||||
|
||||
@Override
|
||||
Server startServer(int port) {
|
||||
Server server = new Server(port)
|
||||
ServletHandler handler = new ServletHandler()
|
||||
server.setHandler(handler)
|
||||
setupServlets(handler)
|
||||
server.addBean(new ErrorHandler() {
|
||||
protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException {
|
||||
Throwable th = (Throwable) request.getAttribute("javax.servlet.error.exception")
|
||||
writer.write(th ? th.message : message)
|
||||
}
|
||||
})
|
||||
server.start()
|
||||
return server
|
||||
}
|
||||
@Override
|
||||
Server startServer(int port) {
|
||||
Server server = new Server(port)
|
||||
ServletHandler handler = new ServletHandler()
|
||||
server.setHandler(handler)
|
||||
setupServlets(handler)
|
||||
server.addBean(new ErrorHandler() {
|
||||
protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException {
|
||||
Throwable th = (Throwable) request.getAttribute("javax.servlet.error.exception")
|
||||
writer.write(th ? th.message : message)
|
||||
}
|
||||
})
|
||||
server.start()
|
||||
return server
|
||||
}
|
||||
|
||||
@Override
|
||||
void addServlet(ServletHandler servletHandler, String path, Class<Servlet> servlet) {
|
||||
servletHandler.addServletWithMapping(servlet, path)
|
||||
}
|
||||
@Override
|
||||
void addServlet(ServletHandler servletHandler, String path, Class<Servlet> servlet) {
|
||||
servletHandler.addServletWithMapping(servlet, path)
|
||||
}
|
||||
|
||||
@Override
|
||||
void stopServer(Server server) {
|
||||
server.stop()
|
||||
server.destroy()
|
||||
}
|
||||
@Override
|
||||
void stopServer(Server server) {
|
||||
server.stop()
|
||||
server.destroy()
|
||||
}
|
||||
|
||||
@Override
|
||||
String getContext() {
|
||||
""
|
||||
}
|
||||
@Override
|
||||
String getContext() {
|
||||
""
|
||||
}
|
||||
|
||||
@Override
|
||||
Class<Servlet> servlet() {
|
||||
TestServlet3.Sync
|
||||
}
|
||||
@Override
|
||||
Class<Servlet> servlet() {
|
||||
TestServlet3.Sync
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean testNotFound() {
|
||||
false
|
||||
}
|
||||
@Override
|
||||
boolean testNotFound() {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,92 +16,92 @@ import javax.servlet.ServletRequest
|
|||
import javax.servlet.ServletResponse
|
||||
|
||||
class FilterTest extends AgentTestRunner {
|
||||
static final PREVIOUS_CONFIG = ConfigUtils.updateConfigAndResetInstrumentation {
|
||||
it.setProperty("otel.integration.servlet-filter.enabled", "true")
|
||||
}
|
||||
|
||||
def cleanupSpec() {
|
||||
ConfigUtils.setConfig(PREVIOUS_CONFIG)
|
||||
}
|
||||
|
||||
def "test doFilter no-parent"() {
|
||||
when:
|
||||
filter.doFilter(null, null, null)
|
||||
|
||||
then:
|
||||
assertTraces(0) {}
|
||||
|
||||
where:
|
||||
filter = new TestFilter()
|
||||
}
|
||||
|
||||
def "test doFilter with parent"() {
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
filter.doFilter(null, null, null)
|
||||
static final PREVIOUS_CONFIG = ConfigUtils.updateConfigAndResetInstrumentation {
|
||||
it.setProperty("otel.instrumentation.servlet-filter.enabled", "true")
|
||||
}
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
basicSpan(it, 0, "parent")
|
||||
span(1) {
|
||||
name "${filter.class.simpleName}.doFilter"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
def cleanupSpec() {
|
||||
ConfigUtils.setConfig(PREVIOUS_CONFIG)
|
||||
}
|
||||
|
||||
def "test doFilter no-parent"() {
|
||||
when:
|
||||
filter.doFilter(null, null, null)
|
||||
|
||||
then:
|
||||
assertTraces(0) {}
|
||||
|
||||
where:
|
||||
filter = new TestFilter()
|
||||
}
|
||||
|
||||
def "test doFilter with parent"() {
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
filter.doFilter(null, null, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
where:
|
||||
filter << [new TestFilter(), new TestFilter() {}]
|
||||
}
|
||||
|
||||
def "test doFilter exception"() {
|
||||
setup:
|
||||
def ex = new Exception("some error")
|
||||
def filter = new TestFilter() {
|
||||
@Override
|
||||
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
filter.doFilter(null, null, null)
|
||||
}
|
||||
|
||||
then:
|
||||
def th = thrown(Exception)
|
||||
th == ex
|
||||
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
basicSpan(it, 0, "parent", null, ex)
|
||||
span(1) {
|
||||
name "${filter.class.simpleName}.doFilter"
|
||||
childOf span(0)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
then:
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
basicSpan(it, 0, "parent")
|
||||
span(1) {
|
||||
name "${filter.class.simpleName}.doFilter"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TestFilter implements Filter {
|
||||
|
||||
@Override
|
||||
void init(FilterConfig filterConfig) throws ServletException {
|
||||
where:
|
||||
filter << [new TestFilter(), new TestFilter() {}]
|
||||
}
|
||||
|
||||
@Override
|
||||
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
def "test doFilter exception"() {
|
||||
setup:
|
||||
def ex = new Exception("some error")
|
||||
def filter = new TestFilter() {
|
||||
@Override
|
||||
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
filter.doFilter(null, null, null)
|
||||
}
|
||||
|
||||
then:
|
||||
def th = thrown(Exception)
|
||||
th == ex
|
||||
|
||||
assertTraces(1) {
|
||||
trace(0, 2) {
|
||||
basicSpan(it, 0, "parent", null, ex)
|
||||
span(1) {
|
||||
name "${filter.class.simpleName}.doFilter"
|
||||
childOf span(0)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void destroy() {
|
||||
static class TestFilter implements Filter {
|
||||
|
||||
@Override
|
||||
void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
}
|
||||
|
||||
@Override
|
||||
void destroy() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,107 +13,107 @@ import javax.servlet.http.HttpServletRequest
|
|||
import javax.servlet.http.HttpServletResponse
|
||||
|
||||
class HttpServletTest extends AgentTestRunner {
|
||||
static final PREVIOUS_CONFIG = ConfigUtils.updateConfigAndResetInstrumentation {
|
||||
it.setProperty("otel.integration.servlet-service.enabled", "true")
|
||||
}
|
||||
|
||||
def specCleanup() {
|
||||
ConfigUtils.setConfig(PREVIOUS_CONFIG)
|
||||
}
|
||||
|
||||
def req = Mock(HttpServletRequest) {
|
||||
getMethod() >> "GET"
|
||||
getProtocol() >> "TEST"
|
||||
}
|
||||
def resp = Mock(HttpServletResponse)
|
||||
|
||||
def "test service no-parent"() {
|
||||
when:
|
||||
servlet.service(req, resp)
|
||||
|
||||
then:
|
||||
assertTraces(0) {}
|
||||
|
||||
where:
|
||||
servlet = new TestServlet()
|
||||
}
|
||||
|
||||
def "test service with parent"() {
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
servlet.service(req, resp)
|
||||
static final PREVIOUS_CONFIG = ConfigUtils.updateConfigAndResetInstrumentation {
|
||||
it.setProperty("otel.instrumentation.servlet-service.enabled", "true")
|
||||
}
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
basicSpan(it, 0, "parent")
|
||||
span(1) {
|
||||
name "HttpServlet.service"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
def specCleanup() {
|
||||
ConfigUtils.setConfig(PREVIOUS_CONFIG)
|
||||
}
|
||||
|
||||
def req = Mock(HttpServletRequest) {
|
||||
getMethod() >> "GET"
|
||||
getProtocol() >> "TEST"
|
||||
}
|
||||
def resp = Mock(HttpServletResponse)
|
||||
|
||||
def "test service no-parent"() {
|
||||
when:
|
||||
servlet.service(req, resp)
|
||||
|
||||
then:
|
||||
assertTraces(0) {}
|
||||
|
||||
where:
|
||||
servlet = new TestServlet()
|
||||
}
|
||||
|
||||
def "test service with parent"() {
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
servlet.service(req, resp)
|
||||
}
|
||||
span(2) {
|
||||
name "${expectedSpanName}.doGet"
|
||||
childOf span(1)
|
||||
attributes {
|
||||
}
|
||||
|
||||
then:
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
basicSpan(it, 0, "parent")
|
||||
span(1) {
|
||||
name "HttpServlet.service"
|
||||
childOf span(0)
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
span(2) {
|
||||
name "${expectedSpanName}.doGet"
|
||||
childOf span(1)
|
||||
attributes {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
where:
|
||||
servlet << [new TestServlet(), new TestServlet() {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
}
|
||||
}]
|
||||
|
||||
expectedSpanName = servlet.class.anonymousClass ? servlet.class.name : servlet.class.simpleName
|
||||
}
|
||||
|
||||
where:
|
||||
servlet << [new TestServlet(), new TestServlet() {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
}
|
||||
}]
|
||||
|
||||
expectedSpanName = servlet.class.anonymousClass ? servlet.class.name : servlet.class.simpleName
|
||||
}
|
||||
|
||||
def "test service exception"() {
|
||||
setup:
|
||||
def ex = new Exception("some error")
|
||||
def servlet = new TestServlet() {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
servlet.service(req, resp)
|
||||
}
|
||||
|
||||
then:
|
||||
def th = thrown(Exception)
|
||||
th == ex
|
||||
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
basicSpan(it, 0, "parent", null, ex)
|
||||
span(1) {
|
||||
name "HttpServlet.service"
|
||||
childOf span(0)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
def "test service exception"() {
|
||||
setup:
|
||||
def ex = new Exception("some error")
|
||||
def servlet = new TestServlet() {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
throw ex
|
||||
}
|
||||
}
|
||||
span(2) {
|
||||
name "${servlet.class.name}.doGet"
|
||||
childOf span(1)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TestServlet extends AbstractHttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
when:
|
||||
runUnderTrace("parent") {
|
||||
servlet.service(req, resp)
|
||||
}
|
||||
|
||||
then:
|
||||
def th = thrown(Exception)
|
||||
th == ex
|
||||
|
||||
assertTraces(1) {
|
||||
trace(0, 3) {
|
||||
basicSpan(it, 0, "parent", null, ex)
|
||||
span(1) {
|
||||
name "HttpServlet.service"
|
||||
childOf span(0)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
}
|
||||
span(2) {
|
||||
name "${servlet.class.name}.doGet"
|
||||
childOf span(1)
|
||||
errored true
|
||||
errorEvent(ex.class, ex.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TestServlet extends AbstractHttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ muzzle {
|
|||
assertInverse = true
|
||||
}
|
||||
|
||||
// FIXME: webmvc depends on web, so we need a separate integration for spring-web specifically.
|
||||
// FIXME: webmvc depends on web, so we need a separate instrumentation for spring-web specifically.
|
||||
fail {
|
||||
group = 'org.springframework'
|
||||
module = 'spring-web'
|
||||
|
@ -38,7 +38,7 @@ dependencies {
|
|||
testImplementation group: 'org.hibernate', name: 'hibernate-validator', version: '5.4.2.Final'
|
||||
|
||||
testImplementation group: 'org.spockframework', name: 'spock-spring', version: "$versions.spock"
|
||||
|
||||
|
||||
testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.17.RELEASE'
|
||||
testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.17.RELEASE'
|
||||
testLibrary group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.5.17.RELEASE'
|
||||
|
|
|
@ -83,7 +83,7 @@ public interface Instrumenter {
|
|||
instrumentationNames.add(instrumentationName);
|
||||
instrumentationPrimaryName = instrumentationName;
|
||||
|
||||
enabled = Config.get().isIntegrationEnabled(instrumentationNames, defaultEnabled());
|
||||
enabled = Config.get().isInstrumentationEnabled(instrumentationNames, defaultEnabled());
|
||||
Map<String, String> contextStore = contextStore();
|
||||
if (!contextStore.isEmpty()) {
|
||||
contextProvider = new FieldBackedProvider(this, contextStore);
|
||||
|
@ -241,7 +241,7 @@ public interface Instrumenter {
|
|||
}
|
||||
|
||||
protected boolean defaultEnabled() {
|
||||
return Config.get().getBooleanProperty("otel.integrations.enabled", true);
|
||||
return Config.get().getBooleanProperty("otel.instrumentations.enabled", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class DefaultInstrumenterTest extends Specification {
|
|||
def "default disabled can override to enabled"() {
|
||||
setup:
|
||||
def previousConfig = ConfigUtils.updateConfig {
|
||||
it.setProperty("otel.integration.test.enabled", "$enabled")
|
||||
it.setProperty("otel.instrumentation.test.enabled", "$enabled")
|
||||
}
|
||||
def target = new TestDefaultInstrumenter("test") {
|
||||
@Override
|
||||
|
@ -88,7 +88,7 @@ class DefaultInstrumenterTest extends Specification {
|
|||
def "configure default sys prop as #value"() {
|
||||
setup:
|
||||
def previousConfig = ConfigUtils.updateConfig {
|
||||
it.setProperty("otel.integrations.enabled", value)
|
||||
it.setProperty("otel.instrumentations.enabled", value)
|
||||
}
|
||||
def target = new TestDefaultInstrumenter("test")
|
||||
target.instrument(new AgentBuilder.Default())
|
||||
|
@ -110,8 +110,8 @@ class DefaultInstrumenterTest extends Specification {
|
|||
def "configure sys prop enabled for #value when default is disabled"() {
|
||||
setup:
|
||||
def previousConfig = ConfigUtils.updateConfig {
|
||||
it.setProperty("otel.integrations.enabled", "false")
|
||||
it.setProperty("otel.integration.${value}.enabled", "true")
|
||||
it.setProperty("otel.instrumentations.enabled", "false")
|
||||
it.setProperty("otel.instrumentation.${value}.enabled", "true")
|
||||
}
|
||||
def target = new TestDefaultInstrumenter(name, altName)
|
||||
target.instrument(new AgentBuilder.Default())
|
||||
|
|
|
@ -30,7 +30,7 @@ import spock.lang.Requires
|
|||
class FieldBackedProviderTest extends AgentTestRunner {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.context-test-instrumentation.enabled", "true")
|
||||
System.setProperty("otel.instrumentation.context-test-instrumentation.enabled", "true")
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -221,7 +221,7 @@ class FieldBackedProviderTest extends AgentTestRunner {
|
|||
class FieldBackedProviderFieldInjectionDisabledTest extends AgentTestRunner {
|
||||
|
||||
static {
|
||||
System.setProperty("otel.integration.context-test-instrumentation.enabled", "true")
|
||||
System.setProperty("otel.instrumentation.context-test-instrumentation.enabled", "true")
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue