Hi,

I think RequestData [4] is the right place - or at least the best place we have today :)

If you can do the instrumentation in a way that it does its work only once (the first time), then you might get away without changes in Sling.

If not, maybe enhancing [4] a little bit to detect root servlet vs child servlet and then you can instrument more targeted

Regards
Carsten

On 01.09.2023 22:18, Robert Munteanu wrote:
Hi,

I am interested in finding out what script/servlet was used to serve a
given request. I am doing this for observability reasons, to be able to
report traces via opentelemetry [1] . OTEL works using bytecode
instrumentation, so I'm not worried about how to intercept calls, but
more about how to find out the info with very low performance impact.

I checked the SlingHttpServletRequest and SlingHttpServletResponse APIs
and I see no place where that information is stored.

I traced the request handling starting from the SlingMainServlet [2] ->
SlingRequestProcessorImpl [3] -> RequestData [4] but when the servlet
resolution happens I can't be sure that this is the top-level resource
being resolved.

Does anyone have any ideas about how I can identify the script that is
being used to serve the top-level request? I'd want to avoid:

a) changing code in Sling
b) doing excessive work ( e.g. re-running servlet resolution )

Thanks!

Robert


[1]:
https://github.com/open-telemetry/opentelemetry-java-instrumentation
[2]:
https://github.com/apache/sling-org-apache-sling-engine/blob/98dc1b918958ad32a18b1bd70020d7de78af3d12/src/main/java/org/apache/sling/engine/impl/SlingMainServlet.java#L130-L131
[3]:
https://github.com/apache/sling-org-apache-sling-engine/blob/98dc1b918958ad32a18b1bd70020d7de78af3d12/src/main/java/org/apache/sling/engine/impl/SlingRequestProcessorImpl.java#L231
[4]:
https://github.com/apache/sling-org-apache-sling-engine/blob/98dc1b918958ad32a18b1bd70020d7de78af3d12/src/main/java/org/apache/sling/engine/impl/request/RequestData.java#L244

--
Carsten Ziegeler
Adobe
cziege...@apache.org

Reply via email to