Off the top of my head… Seems possible (likely?) that no tuples arrived between enabling the StreamScope and calling getSamples(). Samples aren’t captured until the StreamScope is enabled and ultimately the servlet will have to periodically call getSamples().
Note, StreamScope.java has doc that may help clarify things beyond what’s in StreamScopeMXBean doc. Yup, DevelopmentProvider injects StreamScope oplets alongside of the injected Metric oplets. Both are presented as little grey boxes in a stream and you can hover on them. — Dale > On Sep 27, 2016, at 4:50 PM, Susan Cline <[email protected]> wrote: > > ... > Here is the simple code in the servlet: > > StreamScopeMXBean sScopeBean = > StreamScopeUtil.getStreamScope(jobId, opletId, Integer.parseInt(outputPort)); > if (sScopeBean != null) { > sScopeBean.setEnabled(true); > System.out.println("is streamScopeMXBean > enabled? " + sScopeBean.isEnabled()); > > String sampleScope = sScopeBean.getSamples(); > System.out.println("sampleScope: " + > sampleScope); > Gson gson = new Gson(); > response.setContentType("application/json"); > response.setCharacterEncoding("UTF-8"); > > response.getWriter().write(gson.toJson(sampleScope)); > } > > The output to the command line is: > > is streamScopeMXBean enabled? true > sampleScope: []
