Ejemplo n.º 1
0
  def post(self):
    """Handles a new error report via POST."""
    key = self.request.get('key')

    if key != SECRET_KEY:
      self.error(403)
      return

    # Add the task to the instances queue.
    queue.queueException(self.request.body)
Ejemplo n.º 2
0
    def post(self):
        """Handles a new error report via POST."""
        key = self.request.get('key')

        if key != SECRET_KEY:
            self.error(403)
            return

        # Add the task to the instances queue.
        queue.queueException(self.request.body)
Ejemplo n.º 3
0
    def get(self):
        """Handles page get for the error page."""
        for _ in range(10):
            error = random.choice(range(4))
            errorLevel = 'error'
            project = 'frontend'
            try:
                if error == 0:
                    project = 'backend'
                    x = 10 / 0
                elif error == 1:
                    errorLevel = 'warning'
                    json.loads('{"abc", [1, 2')
                elif error == 2:
                    x = {}
                    x = x['y']
                elif error == 3:
                    x = {}
                    x = x['z']

            except (KeyError, ZeroDivisionError, ValueError):
                excInfo = sys.exc_info()
                stack = traceback.format_exc()
                env = random.choice(['dev', 'prod'])
                exception = {
                    'timestamp':
                    time.time(),
                    'project':
                    project,
                    'serverName':
                    '%s %s %d' % (env, project, random.choice(range(3))),
                    'type':
                    excInfo[0].__module__ + '.' + excInfo[0].__name__,
                    'environment':
                    env,
                    'errorLevel':
                    errorLevel,
                    'message':
                    str(excInfo[1]),
                    'logMessage':
                    'Log message goes here',
                    'backtrace':
                    stack,
                    'context': {
                        'userId': random.choice(range(20))
                    }
                }
                queue.queueException(json.dumps(exception))

        self.response.out.write('Done!')
Ejemplo n.º 4
0
  def get(self):
    """Handles page get for the error page."""
    for _ in range(10):
      error = random.choice(range(4))
      errorLevel = 'error'
      project = 'frontend'
      try:
        if error == 0:
          project = 'backend'
          x = 10 / 0
        elif error == 1:
          errorLevel = 'warning'
          json.loads('{"abc", [1, 2')
        elif error == 2:
          x = {}
          x = x['y']
        elif error == 3:
          x = {}
          x = x['z']

      except (KeyError, ZeroDivisionError, ValueError):
        excInfo = sys.exc_info()
        stack = traceback.format_exc()
        env = random.choice(['dev', 'prod'])
        exception = {
          'timestamp': time.time(),
          'project': project,
          'serverName':'%s %s %d' % (env, project, random.choice(range(3))),
          'type': excInfo[0].__module__ + '.' + excInfo[0].__name__,
          'environment': env,
          'errorLevel': errorLevel,
          'message': str(excInfo[1]),
          'logMessage': 'Log message goes here',
          'backtrace': stack,
          'context':{'userId':random.choice(range(20))}
        }
        queue.queueException(json.dumps(exception))

    self.response.out.write('Done!')