io.opentelemetry.javaagent.instrumentation.myfaces.RestoreViewExecutorInstrumentation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opentelemetry-javaagent-jsf-myfaces-1.2 Show documentation
Show all versions of opentelemetry-javaagent-jsf-myfaces-1.2 Show documentation
Instrumentation of Java libraries using OpenTelemetry.
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.instrumentation.myfaces;
import static io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge.currentContext;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.jsf.javax.JsfServerSpanNaming;
import javax.faces.context.FacesContext;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
public class RestoreViewExecutorInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher typeMatcher() {
return named("org.apache.myfaces.lifecycle.RestoreViewExecutor");
}
@Override
public void transform(TypeTransformer transformer) {
transformer.applyAdviceToMethod(
named("execute").and(takesArgument(0, named("javax.faces.context.FacesContext"))),
RestoreViewExecutorInstrumentation.class.getName() + "$ExecuteAdvice");
}
@SuppressWarnings("unused")
public static class ExecuteAdvice {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(@Advice.Argument(0) FacesContext facesContext) {
JsfServerSpanNaming.updateViewName(currentContext(), facesContext);
}
}
}