Module Expr Str Import alias Import alias Import alias Import alias Import alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore Num ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str If UnaryOpNot NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Return BinOpMod Str TupleLoad NameLoad NameLoad NameLoad decorator_list NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr If Call AttributeLoad NameLoad attr NameLoad body Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd Call NameLoad NameLoad Num Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore SubscriptLoad SubscriptLoad NameLoad Index Num Slice Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad If CompareGt Call NameLoad NameLoad NameLoad body Assign NameStore BinOpMod Str Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index Str Str body Assign NameStore Str orelse Assign NameStore Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Str If NameLoad body Assign NameStore BinOpAdd Str NameLoad Return BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str If AttributeLoad NameLoad attr body Return AttributeLoad NameLoad attr orelse Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str TryExcept body If UnaryOpNot AttributeLoad NameLoad attr body Return Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad NameLoad AttributeLoad NameLoad attr body Return Expr Call AttributeLoad NameLoad attr Num AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword Call AttributeLoad Call AttributeLoad NameLoad attr attr NameLoad keyword SubscriptLoad AttributeLoad NameLoad attr Index Str keyword Call AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Str AugAssignAdd AttributeStore NameLoad attr Num Expr Call AttributeLoad NameLoad attr decorator_list decorator_list FunctionDef arguments args NameParam defaults NameLoad body If UnaryOpNot NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list
N/A N/A A logging handler that records information about unique exceptions.

'Unique' in this case is defined as a given (exception class, location) tuple.
Unique exceptions are logged to the datastore with an example stacktrace and an
approximate count of occurrences, grouped by day and application version.

A cron handler, in google.appengine.ext.ereporter.report_generator, constructs
and emails a report based on the previous day's exceptions.

Example usage:

In your handler script(s), add:

  import logging
  from google.appengine.ext import ereporter

  ereporter.register_logger()

In your app.yaml, add:

  handlers:
  - url: /_ereporter/.*
    script: $PYTHON_LIB/google/appengine/ext/ereporter/report_generator.py
    login: admin

In your cron.yaml, add:

  cron:
  - description: Daily exception report
    url: /_ereporter?sender=you@yourdomain.com
    schedule: every day 00:00

This will cause a daily exception report to be generated and emailed to all
admins, with exception traces grouped by minor version. If you only want to
get exception information for the most recent minor version, add the
'versions=latest' argument to the query string. For other valid query string
arguments, see report_generator.py.

If you anticipate a lot of exception traces (for example, if you're deploying
many minor versions, each of which may have its own set of exceptions), you
can ensure that the traces from the newest minor versions get included by adding
this to your index.yaml:

  indexes:
  - kind: __google_ExceptionRecord
    properties:
    - name: date
    - name: major_version
    - name: minor_version
      direction: desc
 N/A datetime N/A logging N/A os N/A sha N/A traceback N/A urllib google.appengine.api memcache google.appengine.ext db google.appengine.ext webapp N/A MAX_SIGNATURE_LENGTH 256 ExceptionRecord N/A N/A db Model N/A N/A Datastore model for a record of a unique exception. N/A signature N/A N/A db StringProperty required True N/A major_version N/A N/A db StringProperty required True N/A minor_version N/A N/A db IntegerProperty required True N/A date N/A N/A db DateProperty required True N/A count N/A N/A db IntegerProperty required True default 0 N/A stacktrace N/A N/A db TextProperty required True N/A http_method N/A N/A db TextProperty required True N/A url N/A N/A db TextProperty required True N/A handler N/A N/A db TextProperty required True get_key_name N/A N/A cls signature version date N/A None N/A N/A Generates a key name for an exception record.

    Args:
      signature: A signature representing the exception and its site.
      version: The major/minor version of the app the exception occurred in.
      date: The date the exception occurred.

    Returns:
      The unique key name for this exception record.
     N/A N/A date N/A N/A date N/A N/A N/A datetime date today N/A N/A %s@%s:%s N/A signature date version N/A classmethod N/A ExceptionRecordingHandler N/A N/A logging Handler N/A N/A A handler that records exception data to the App Engine datastore. __init__ N/A N/A self log_interval N/A 10 N/A N/A Constructs a new ExceptionRecordingHandler.

    Args:
      log_interval: The minimum interval at which we will log an individual
        exception. This is a per-exception timeout, so doesn't affect the
        aggregate rate of exception logging, only the rate at which we record
        ocurrences of a single exception, to prevent datastore contention.
     N/A N/A self log_interval log_interval N/A N/A N/A N/A logging Handler __init__ self N/A __RelativePath N/A N/A cls path N/A N/A N/A Rewrites a path to be relative to the app's root directory.

    Args:
      path: The path to rewrite.

    Returns:
      The path with the prefix removed, if that prefix matches the app's
        root directory.
     N/A cwd N/A N/A os getcwd N/A N/A N/A path startswith cwd N/A N/A path N/A path N/A N/A N/A len cwd 1 N/A path N/A classmethod __GetSignature N/A N/A cls exc_info N/A N/A N/A Returns a unique signature string for an exception.

    Args:
      exc_info: The exc_info object for an exception.

    Returns:
      A unique signature string for the exception, consisting of fully
      qualified exception name and call site.
     N/A N/A ex_type unused_value trace exc_info N/A frames N/A N/A traceback extract_tb trace N/A fulltype N/A %s.%s N/A N/A ex_type __module__ N/A ex_type __name__ N/A N/A path line_no N/A N/A frames N/A -1 N/A 2 N/A path N/A N/A cls __RelativePath path N/A site N/A %s:%d N/A path line_no N/A signature N/A %s@%s N/A fulltype site N/A N/A N/A len signature MAX_SIGNATURE_LENGTH N/A N/A signature N/A hash:%s N/A N/A N/A N/A sha new signature hexdigest N/A signature N/A classmethod __GetURL N/A N/A cls N/A N/A N/A Returns the URL of the page currently being served.

    Returns:
      The full URL of the page currently being served.
     N/A N/A N/A N/A os environ N/A SERVER_PORT 80 N/A N/A scheme http:// N/A N/A scheme https:// N/A host N/A N/A os environ N/A SERVER_NAME N/A script_name N/A N/A urllib quote N/A N/A os environ N/A SCRIPT_NAME N/A path_info N/A N/A urllib quote N/A N/A os environ N/A PATH_INFO N/A qs N/A N/A N/A os environ get QUERY_STRING N/A qs N/A N/A qs N/A ? qs N/A N/A N/A N/A N/A scheme host script_name path_info qs N/A classmethod __GetFormatter N/A N/A self N/A N/A N/A Returns the log formatter for this handler.

    Returns:
      The log formatter to use.
     N/A N/A self formatter N/A N/A N/A self formatter N/A N/A N/A logging _defaultFormatter N/A emit N/A N/A self record N/A N/A N/A Log an error to the datastore, if applicable.

    Args:
      The logging.LogRecord object.
        See http://docs.python.org/library/logging.html#logging.LogRecord
     N/A N/A N/A N/A N/A record exc_info N/A N/A N/A signature N/A N/A self __GetSignature N/A record exc_info N/A N/A N/A N/A memcache add signature None N/A self log_interval N/A N/A N/A N/A N/A db run_in_transaction_custom_retries 1 N/A self __EmitTx signature N/A record exc_info N/A N/A N/A Exception N/A N/A N/A N/A self handleError record N/A __EmitTx N/A N/A self signature exc_info N/A N/A N/A Run in a transaction to insert or update the record for this transaction.

    Args:
      signature: The signature for this exception.
      exc_info: The exception info record.
     N/A today N/A N/A N/A datetime date today N/A version N/A N/A os environ N/A CURRENT_VERSION_ID N/A N/A major_ver minor_ver N/A N/A version rsplit . 1 N/A minor_ver N/A int minor_ver N/A key_name N/A N/A ExceptionRecord get_key_name signature version N/A exrecord N/A N/A ExceptionRecord get_by_key_name key_name N/A N/A exrecord N/A N/A exrecord N/A ExceptionRecord key_name key_name signature signature major_version major_ver minor_version minor_ver date today stacktrace N/A N/A N/A N/A self __GetFormatter formatException exc_info http_method N/A N/A os environ N/A REQUEST_METHOD url N/A N/A self __GetURL handler N/A N/A self __RelativePath N/A N/A os environ N/A PATH_TRANSLATED N/A N/A exrecord count 1 N/A N/A N/A exrecord put N/A N/A register_logger N/A N/A logger N/A None N/A N/A N/A logger N/A N/A logger N/A N/A logging getLogger N/A handler N/A ExceptionRecordingHandler N/A N/A N/A logger addHandler handler N/A handler N/A