Configuring Java GAE Appstats for cron job
Asked Answered
S

1

16

I configured my web.xml to enable appstats for my cron job. My cron job is handled by a servlet at the URL http://myapp.appspot.com/cron/myjob and executed once an hour.

When I access the appstats admin interface at the URL http://myapp.appspot.com/appstats/stats. I can see stats about /appstats URLs but not about /cron URLs. I was expecting appstats to record events everytime the cron job has been executed. Here is my web.xml:

<web-app>
    <!-- Servlets -->
    <filter>
        <filter-name>guiceFilter</filter-name>
        <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>guiceFilter</filter-name>
        <url-pattern>*</url-pattern>
    </filter-mapping>
    <!-- AppStats -->
    <filter>
        <filter-name>appstats</filter-name>
        <filter-class>com.google.appengine.tools.appstats.AppstatsFilter</filter-class>
        <init-param>
            <param-name>logMessage</param-name>
            <param-value>Appstats available: /appstats/details?time={ID}</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>appstats</filter-name>
        <url-pattern>/cron/*</url-pattern>
    </filter-mapping>
    <!-- AppStats Servlet -->    
    <servlet>
        <servlet-name>appstats</servlet-name>
        <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>appstats</servlet-name>
        <url-pattern>/appstats/*</url-pattern>
    </servlet-mapping>
<!--     <security-constraint>
        <web-resource-collection>
            <url-pattern>/appstats/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
        </auth-constraint>
    </security-constraint>  -->
    <!-- Default page to serve -->
</web-app>

Solution: I fixed it by putting the AppStats filter before the Guice filter

Sanguineous answered 23/8, 2011 at 23:5 Comment(3)
Nice work. Could you please close this question as answered? ThanksPolston
@Sanguineous please close this question as anwered. :)Cariotta
If you found a solution, @Sydney, you should post a self-answer.Faultfinding
S
1

I fixed it by putting the AppStats filter before the Guice filter

Sanguineous answered 11/12, 2015 at 5:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.