Hello

śr., 17 paź 2018 o 08:44 Lukasz Lech <l.l...@ringler.ch> napisał(a):

> OK thank you, I’ll try that way.
>
>
>
> So I need either to implement a bundle that will get the names of other
> bundles it should register metrics for, or I should build metrics in
> specific bundles, and in case I’d like to have karaf-wide Prometheus
> metrics collection I’d need to modify WebContainer implementation?
>

if you want global filters or prometheus integration (I imagine it like
single endpoint, like /health or /metrics or something) you could try doing
something container (jetty/undertow/tomcat) specific. Tomcat has valves,
jetty and undertow have handlers - you can look at the code to check how
for example NSCA logging interceptor/handler/valve is implemented.


>
>
> Are there any plans to provide build-in Prometheus metrics collection in
> pax-web?
>

You could even provide a solution for pax-web ;) For now pax-web isn't
prometheus-aware, but I could imagine some kind of integration.

regards
Grzegorz Grzybek


>
>
> Best regards,
>
> Lukasz Lech
>
>
>
>
>
> *From:* ops4j@googlegroups.com [mailto:ops4j@googlegroups.com] *On Behalf
> Of *Grzegorz Grzybek
> *Sent:* Mittwoch, 17. Oktober 2018 08:14
> *To:* ops4j@googlegroups.com
> *Subject:* Re: [PAX-WEB] WebContainer - registering ServletFilter -
> confusion
>
>
>
> Hello
>
>
>
> First, the most important line in your code is:
>
>
>
> WebContainer webContainer = (WebContainer) context.getService(reference);
>
>
>
> And especially "context" you're using. pax-web in general and 
> "registerFilter()"
> method in particular is an attempt to implement concepts from javax.servlet
> specification (concepts from WEB-INF/web.xml) in OSGi.
>
> Short - you're registering filter in different context than the one you
> have your servlets you want to filter. Even in JavaEE you can't have a
> filter that's filtering servlets in different contexts.
>
>
>
> You can however grab a BundleContext from different bundle - just get the
> single (or even more) Bundle from context.getBundles() by symbolic name for
> example and get its context - then grab WebContainer service from this
> context instead of the context you're given in BundleActivator.start().
>
>
>
> regards
>
> Grzegorz Grzybek
>
>
>
> wt., 16 paź 2018 o 15:05 Lukasz Lech <l.l...@ringler.ch> napisał(a):
>
> Hello,
>
>
>
> I’m trying to register io.prometheus.client.filter.MetricsFilter for
> Prometheus metrics.
>
>
>
> I’m trying to call registerFilter() with many possible url patterns, but
> none seem to have any affect:
>
>
>
>   @Override
>
>   public void start(BundleContext context) throws Exception
>
>   {
>
>     webContainerTracker = new WebContainerTracker(context);
>
>     webContainerTracker.open();
>
>   }
>
>
>
>   @Override
>
>   public Object addingService(ServiceReference reference)
>
>   {
>
>     WebContainer webContainer = (WebContainer)
> context.getService(reference);
>
>     this.metricsFilter = new MetricsFilter();
>
>     webContainer.registerFilter(metricsFilter, new String[]{"/", "*",
> "/*"}, null, null, false, null);
>
>     return webContainer;
>
>   }
>
>
>
> Expected behavior:
>
> Any request to Karaf, including opening WebConsole, would land me in
> MetricsFilter.doFilter breakpoint
>
> Observed behavior:
>
> Nothing, even init() method is not called.
>
>
>
> Do wildcards are supported by WebContainer for registering filters? Or not
> every request goes through that filters, and I’d need to register filter on
> jetty directly? (how?, Jetty seems not to be exposed in OSGi context).
>
>
>
> I’m using JaxRS-Publisher that registers servlets using
> HttpService.addServlet() (and WebContainer is the only available
> implementation).
>
>
>
> WebConsole also uses WebContainer, so I assume, it must register servlets
> also using that method.
>
>
>
> Where is the problem? What I’m doing wrong?
>
>
>
> Best regards,
>
> Lukasz Lech
>
>
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - ops4j@googlegroups.com
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ops4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to