GoogleCloudPlatform / GoogleCloudPlatform/stackdriver-errors-js

AppEngine Standard - Report API

Offen
#62 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
360
Forks
54
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello there,

As other issues have mentioned, there are some security considerations with regards to hitting the stackdriver API with an API Key. I opted to implement a backend service to forward messages along to the Report API.

AppEngine standard is configured to automatically send log messages to stackdriver, which is super convenient. Unfortunately it's fairly limited to using the [logging API](https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/logging/writing_logs). It works, but records get merged with all the other server side logs, the function name ends up being the endpoint, and httpContext doesn't get captured.

I tried lots of shenanigans with building my own LogRecord object and sending it to the logger, but to no avail.

I could setup API keys and use the google.cloud libbrary to hit the Report API directly, but that defeats the purpose/benefit of using AppEngine standard!

Is there advice on a better API/route to create StackDriver logs from AppEngine standard?

---- EDIT ---
So far this is the best solution I have for an AppEngine Standard + Python 2.7 + Flask blueprint.

I pull out the URL from the context and stuff it into the message.
```
from flask import Blueprint, request
import logging

ERR = Blueprint('Stackdriver', __name__)

@ERR.route('/client_error', methods=['POST'])
def client_error():
json = request.get_json()
msg = "Page: {page}\n{message}".format(
page=json['context']['httpRequest']['url'], message=json['message'])

logging.error(msg)

return ""
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.