I want to keep track of the cpm_usd value of all requests that arrive on my GAE frontend instances. I see the cpm_usd headers in the logs of my application. But is there a way to access those numbers at runtime in order to graph them? I want to create a near real-time cost metric for every endpoint.
- /rest/foo1: $0.000011
- /rest/foo2: $0.000013
- /rest/bar1: $0.000014
- /rest/bar2: $0.000016
Is there a trusted tester program to do this? If not, is there another way to do this which does not involve parsing my log files? Or can I only get those numbers by parsing the logs in the background?
Updates
As described here, I tried adding a sitebricks request filter which intercepts the {add,set}Header() calls.
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, new HttpServletResponseWrapper((HttpServletResponse) response) {
@Override
public void setHeader(String name, String value) {
if ("X-AppEngine-Estimated-CPM-US-Dollars".equals(name)) {
// log request costs
}
super.setHeader(name, value);
}
@Override
public void addHeader(String name, String value) {
if ("X-AppEngine-Estimated-CPM-US-Dollars".equals(name)) {
// log request costs
}
super.addHeader(name, value);
}
});
}
I assume that the header either has a different name or GAE sets headers differently. In either case, I never see the cost header being caught.