stagemonitor icon indicating copy to clipboard operation
stagemonitor copied to clipboard

Context path

Open f0def opened this issue 8 years ago • 3 comments

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

f0def avatar Oct 15 '16 13:10 f0def

@felixbarny I would take a look on this issue in the beginning of November.

trampi avatar Oct 20 '16 16:10 trampi

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.

trampi avatar Nov 08 '16 07:11 trampi

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)

f0def avatar Nov 13 '16 07:11 f0def