Last active
March 20, 2019 14:19
-
-
Save mdindoffer/bc7cf99b5384f7dcbd85db72ad0de192 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package eu.dindoffer.apm.example; | |
import co.elastic.apm.api.ElasticApm; | |
import org.jboss.resteasy.core.ResourceMethodInvoker; | |
import org.jboss.resteasy.core.interception.PostMatchContainerRequestContext; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import javax.ws.rs.container.ContainerRequestContext; | |
import javax.ws.rs.container.ContainerRequestFilter; | |
import javax.ws.rs.ext.Provider; | |
import java.io.IOException; | |
@Provider | |
public class APMRestEasyFilter implements ContainerRequestFilter { | |
private static final Logger LOG = LoggerFactory.getLogger(APMRestEasyFilter.class); | |
@Override | |
public void filter(ContainerRequestContext requestContext) throws IOException { | |
PostMatchContainerRequestContext matchedContext = (PostMatchContainerRequestContext) requestContext; | |
ResourceMethodInvoker resourceMethod = matchedContext.getResourceMethod(); | |
String transactionName = resourceMethod.getResourceClass().getSimpleName() + '#' + resourceMethod.getMethod().getName(); | |
LOG.warn("APMFilter method name {}", transactionName); | |
ElasticApm.currentTransaction().setName(transactionName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment