stagemonitor
stagemonitor copied to clipboard
Context path
Hi, can you explain how can I specify context path?
nginx proxy request to my application, application located at http://localhost/my-app/
But BoomerangJsHtmlInjector#buildBoomerangTemplate
draw script as:
<script>
BOOMR.init({
beacon_url: '/stagemonitor/public/rum',
log: null
});
BOOMR.addVar("requestId", "26c44da0-4d4f-49d7-9159-3835b67404f7");
BOOMR.addVar("requestName", "Root");
BOOMR.addVar("serverTime", 3);
</script></body>
This cause 404
error then page tryed to retrieve http://localhost/stagemonitor/public/static/rum/boomerang-56c823668fc.min.js
because correct url is http://localhost/my-app/stagemonitor/public/static/rum/boomerang-56c823668fc.min.js
Thanks
@felixbarny I would take a look on this issue in the beginning of November.
Hi there, just wanted to inform you that I have not forgotten this one and will have a look, but can at the moment not state a specific date.
I managed this like:
in WebPlugin
added
private final ConfigurationOption<String> contextPath = ConfigurationOption.stringOption()
.key("stagemonitor.web.contextPath")
.dynamic(true)
.label("Specified context path")
.description("It allows you to explicitly specify the context path.")
.defaultValue(null)
.configurationCategory(WEB_PLUGIN)
.build();
and
public String getContextPath() {
return contextPath.getValue();
}
In BoomerangJsHtmlInjector
changed to:
@Override
public void init(HtmlInjector.InitArguments initArguments) {
this.configuration = initArguments.getConfiguration();
this.webPlugin = initArguments.getConfiguration().getConfig(WebPlugin.class);
String contextPath = (webPlugin.getContextPath() == null)
? initArguments.getServletContext().getContextPath()
: webPlugin.getContextPath();
this.boomerangTemplate = buildBoomerangTemplate(contextPath);
}
private String buildBoomerangTemplate(String contextPath) {
String beaconUrl = webPlugin.isRealUserMonitoringEnabled() ?
" beacon_url: " + "'" + contextPath + "stagemonitor/public/rum'" + ",\n" : "";
return "<script src=\"" + contextPath + "stagemonitor/public/static/rum/" + BOOMERANG_FILENAME + "\"></script>\n" +
"<script>\n" +
" BOOMR.init({\n" +
beaconUrl +
" log: null\n" +
" });\n" +
" BOOMR.addVar(\"requestId\", \"${requestId}\");\n" +
" BOOMR.addVar(\"requestName\", \"${requestName}\");\n" +
" BOOMR.addVar(\"serverTime\", ${serverTime});\n" +
"</script>";
}
And then add jvm argument -Dstagemonitor.web.contextPath=
(empty string)