Skip to content

Instantly share code, notes, and snippets.

@mdindoffer
Last active March 20, 2019 14:19
Show Gist options
  • Save mdindoffer/bc7cf99b5384f7dcbd85db72ad0de192 to your computer and use it in GitHub Desktop.
Save mdindoffer/bc7cf99b5384f7dcbd85db72ad0de192 to your computer and use it in GitHub Desktop.
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