Tracking of artifact hits for REST paths

Hi, as you might know, currently moqui is not tracking artifact hits for REST paths, this is explicitly disabled in the code (RestApi class) with a comment: “for now don’t track/count artifact hits for REST path”.
We have some cases where we expose some API endpoints and would like to measure the response times, and with the latest changes in the moqui-metrics component this would be trivial to do using artifact hits (it is actually using a Entity ECA to count hits and durations).
Is there any reason not to enable it, and would it be preferable to disable some specific API calls (like /rest/s1/moiterp/session/userOrgInfo and /rest/s1/mantle/my/noticeCounts)?

1 Like

This sounds like a great idea thanks for bringing this up.

I would say that the main reason why Moqui doesn’t automatically track API endpoints by default is because if you look at almost any production Moqui install, the most used used tables are ArtifactHit and ArtifactHitBin and depending on your system you may not want to keep track.

There are a couple options:
a. keep the functionality as is, but allow for configuration to allow rest api endpoints / files to track rest endpoints
b. set an environment variable / configuration to allow keeping track rest api calls in the artifact hits
c. a combination of the two

I think I’d prefer a for upstream changes.

One pattern that might work well is to enable it but with configuration like others that are similar, ie a global setting for all REST paths in an attribute in the Moqui Conf XML file + an attribute for each service rest endpoint to disable individual ones (and yes, some should have stats tracking disabled OOTB like mantle/my/noticeCounts

1 Like

That sounds like a good plan to me.