-
Notifications
You must be signed in to change notification settings - Fork 894
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,205 additions
and
89 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
6 changes: 6 additions & 0 deletions
6
instrumentation/jsf/jsf-common/library/jsf-common-library.gradle
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apply from: "$rootDir/gradle/instrumentation-library.gradle" | ||
|
||
dependencies { | ||
compileOnly group: 'jakarta.faces', name: 'jakarta.faces-api', version: '2.3.2' | ||
compileOnly group: 'jakarta.el', name: 'jakarta.el-api', version: '3.0.3' | ||
} |
65 changes: 65 additions & 0 deletions
65
.../jsf/jsf-common/library/src/main/java/io/opentelemetry/instrumentation/jsf/JsfTracer.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.instrumentation.jsf; | ||
|
||
import io.opentelemetry.api.trace.Span; | ||
import io.opentelemetry.context.Context; | ||
import io.opentelemetry.instrumentation.api.servlet.ServletContextPath; | ||
import io.opentelemetry.instrumentation.api.tracer.BaseTracer; | ||
import javax.faces.FacesException; | ||
import javax.faces.component.ActionSource2; | ||
import javax.faces.component.UIViewRoot; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.event.ActionEvent; | ||
|
||
public abstract class JsfTracer extends BaseTracer { | ||
|
||
public Span startSpan(ActionEvent event) { | ||
// https://jakarta.ee/specifications/faces/2.3/apidocs/index.html?javax/faces/component/ActionSource2.html | ||
// ActionSource2 was added in JSF 1.2 and is implemented by components that have an action | ||
// attribute such as a button or a link | ||
if (event.getComponent() instanceof ActionSource2) { | ||
ActionSource2 actionSource = (ActionSource2) event.getComponent(); | ||
if (actionSource.getActionExpression() != null) { | ||
// either an el expression in the form #{bean.method()} or navigation case name | ||
String expressionString = actionSource.getActionExpression().getExpressionString(); | ||
// start span only if expression string is really an expression | ||
if (expressionString.startsWith("#{") || expressionString.startsWith("${")) { | ||
return tracer.spanBuilder(expressionString).startSpan(); | ||
} | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public void updateServerSpanName(Context context, FacesContext facesContext) { | ||
Span serverSpan = getCurrentServerSpan(); | ||
if (serverSpan == null) { | ||
return; | ||
} | ||
|
||
UIViewRoot uiViewRoot = facesContext.getViewRoot(); | ||
if (uiViewRoot == null) { | ||
return; | ||
} | ||
|
||
// JSF spec 7.6.2 | ||
// view id is a context relative path to the web application resource that produces the view, | ||
// such as a JSP page or a Facelets page. | ||
String viewId = uiViewRoot.getViewId(); | ||
serverSpan.updateName(ServletContextPath.prepend(context, viewId)); | ||
} | ||
|
||
@Override | ||
protected Throwable unwrapThrowable(Throwable throwable) { | ||
while (throwable.getCause() != null && throwable instanceof FacesException) { | ||
throwable = throwable.getCause(); | ||
} | ||
|
||
return super.unwrapThrowable(throwable); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
instrumentation/jsf/jsf-testing-common/jsf-testing-common.gradle
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apply from: "$rootDir/gradle/java.gradle" | ||
|
||
dependencies { | ||
api deps.testLogging | ||
|
||
compileOnly group: 'jakarta.faces', name: 'jakarta.faces-api', version: '2.3.2' | ||
compileOnly group: 'jakarta.el', name: 'jakarta.el-api', version: '3.0.3' | ||
|
||
implementation(project(':testing-common')) { | ||
exclude group: 'org.eclipse.jetty', module: 'jetty-server' | ||
} | ||
implementation group: 'org.jsoup', name: 'jsoup', version: '1.13.1' | ||
|
||
def jettyVersion = '9.4.35.v20201120' | ||
api group: 'org.eclipse.jetty', name: 'jetty-annotations', version: jettyVersion | ||
implementation group: 'org.eclipse.jetty', name: 'apache-jsp', version: jettyVersion | ||
implementation group: 'org.glassfish', name: 'jakarta.el', version: '3.0.2' | ||
implementation group: 'jakarta.websocket', name: 'jakarta.websocket-api', version: '1.1.1' | ||
} |
Oops, something went wrong.