0

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.

Community
  • 1
  • 1
Ingo
  • 1,552
  • 10
  • 31

1 Answers1

2

The header is added by the application server that sits in front of your instance so you cannot access this header from your code.

You will have to parse the log files, and can consider using log2bq to do this.

John Lowry
  • 249
  • 3
  • 4
  • If I cannot access the headers, is there a way to receive the per URL cost information otherwise? If not will there be Trusted Tester program for something like that? Such an API would not necessarily have to return costs in USD. The main motivation would be to see the trend of "cost" over time and to compare "cost" per URL. – Ingo Apr 19 '13 at 21:50