Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default skip pattern for MP metrics, openapi, health #95

Merged
merged 3 commits into from
Sep 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spec/src/main/asciidoc/microprofile-opentracing.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ Configuration of the skip pattern leverages MicroProfile Config specification.
The skip pattern is specified as a string with key `mp.opentracing.server.skip-pattern` which has to be
compliant with `java.util.regex.Pattern`. An example skip pattern might be `mp.opentracing.server.skip-pattern=/health|/metrics.*`

The default value of the skip pattern excludes tracing for default endpoints defined by MicroProfile Health, Metrics and OpenAPI specification.

=== Enabling explicit distributed tracing code instrumentation

An annotation is provided to define explicit Span creation. This works on top of the "no-action" setup described in <<no-instrumentation>>.
Expand Down
7 changes: 7 additions & 0 deletions tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,12 @@
<artifactId>resteasy-jackson-provider</artifactId>
<version>3.1.4.Final</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.eclipse.microprofile.config.spi.ConfigSource;
Expand All @@ -30,6 +33,7 @@
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.Assert;
import org.testng.annotations.Test;

/**
Expand Down Expand Up @@ -118,4 +122,94 @@ private void testExplicitlyTraced() {
TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testHealthNotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%shealth", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testOpenAPINotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%sopenapi", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testMetricsNotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%smetrics", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testMetricsBaseNotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%smetrics/base", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testMetricsVendorNotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%smetrics/vendor", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}

@Test
@RunAsClient
private void testMetricsApplicationNotTraced() {
Client client = ClientBuilder.newClient();
String url = String.format("%smetrics/application", deploymentURL.toString());
debug("Executing " + url);

WebTarget target = client.target(url);
Response response = target.request().get();
Assert.assertEquals(200, response.getStatus());

TestSpanTree spans = executeRemoteWebServiceTracerTree();
assertEqualTrees(spans, new TestSpanTree());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.eclipse.microprofile.opentracing.tck.application;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author Pavol Loffay
*/
@WebServlet(value = "/health")
public class HealthServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.setStatus(200);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.eclipse.microprofile.opentracing.tck.application;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author Pavol Loffay
*/
@WebServlet(value = "/metrics/*")
public class MetricsServlet extends HttpServlet {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. I test metrics exclusion by adding this servlet


@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.setStatus(200);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2017 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.eclipse.microprofile.opentracing.tck.application;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* @author Pavol Loffay
*/
@WebServlet(value = "/openapi")
public class OpenAPIServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
resp.setStatus(200);
}
}