Как сделать так, чтобы журналы приложений были вложены в журналы запросов в app engine flex? - PullRequest
0 голосов
/ 15 октября 2018

У меня есть модуль, работающий в App Engine Classic, и другой модуль, работающий в App Engine Flexible.При просмотре журналов, запущенных в App Engine Classic, записи журналов вкладываются в каждый запрос.

Однако при просмотре журналов, запущенных в App Engine Flexible, они не являются вложенными.Кажется, что каждая запись журнала не связана с запросом.Это очень затрудняет определение того, какой журнал связан с каким запросом.

Я пытался следовать этим инструкциям в google docs:

In the App Engine flexible environment, app logs can be correlated with a particular request. Following are the requirements:

The "parent" log entry must include a value for httpRequest.requestUrl.
The "child" log entry must have a different log name than the parent. Typically, the child log entry is an app log entry in the app log, whereas the parent log entry is in the request log. The values for resource.type, resource.labels, and trace must be the same in the parent and its child(ren).
The child log entry's timestamp must be within the time interval covered by the parent request. It must be earlier than parent.timestamp and later than parent.timestamp - parent.httpRequest.latency.

Я пытался использовать LoggerEnhancer, чтобы добиться этого, выполнивследующее:

public class Enhancer extends TraceLoggingEnhancer {

  @Override
  public void enhanceLogEntry(LogEntry.Builder logEntry) {
    // add additional labels
    logEntry.addLabel("appengine.googleapis.com/trace_id",getCurrentTraceId());
  }  
}

но звучит так, будто надежды нет, кто-нибудь может мне помочь примером или чем-то еще?

...