From b3fc653fe0a87c4bf15d72003681040bfb6f9e05 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 30 Nov 2017 11:05:26 -0800 Subject: [PATCH] Log the appengine.googleapis.com/trace_id label for requests (#74) --- CHANGELOG.md | 5 +++++ lib/src/grpc_api_impl/logging_impl.dart | 30 ++++++++++++------------- pubspec.yaml | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb4b19b..a66fe377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.3+1 + +* When logging requests, the `appengine.googleapis.com/trace_id` label + is populated. + ## 0.4.3 * When logging, the following `protoPayload` values are now populated: diff --git a/lib/src/grpc_api_impl/logging_impl.dart b/lib/src/grpc_api_impl/logging_impl.dart index 94bdb8e4..06a5c30e 100644 --- a/lib/src/grpc_api_impl/logging_impl.dart +++ b/lib/src/grpc_api_impl/logging_impl.dart @@ -125,6 +125,20 @@ class GrpcRequestLoggingImpl extends LoggingImpl { final int now = new DateTime.now().toUtc().millisecondsSinceEpoch; final api.Timestamp nowTimestamp = _protobufTimestampFromMilliseconds(now); + final protoPayload = new api.Any() + ..typeUrl = 'type.googleapis.com/google.appengine.logging.v1.RequestLog'; + + final gaeResource = new api.MonitoredResource() + ..type = 'gae_app' + ..labels.addAll(_sharedLoggingService.resourceLabels); + + final logEntry = new api.LogEntry() + ..protoPayload = protoPayload + ..resource = gaeResource + ..timestamp = nowTimestamp + ..severity = _currentSeverity + ..logName = _sharedLoggingService.requestLogName; + final appengineRequestLog = new gae_log.RequestLog() ..appId = 's~${_sharedLoggingService.projectId}' ..versionId = _sharedLoggingService.versionId @@ -141,26 +155,12 @@ class GrpcRequestLoggingImpl extends LoggingImpl { if (_traceId != null) { appengineRequestLog.traceId = _traceId; + _addLabel(logEntry, 'appengine.googleapis.com/trace_id', _traceId); } if (_referrer != null) { appengineRequestLog.referrer = _referrer; } - - final protoPayload = new api.Any() - ..typeUrl = 'type.googleapis.com/google.appengine.logging.v1.RequestLog'; - - final gaeResource = new api.MonitoredResource() - ..type = 'gae_app' - ..labels.addAll(_sharedLoggingService.resourceLabels); - - final logEntry = new api.LogEntry() - ..protoPayload = protoPayload - ..resource = gaeResource - ..timestamp = nowTimestamp - ..severity = _currentSeverity - ..logName = _sharedLoggingService.requestLogName; - _resetState(); if (finish) { diff --git a/pubspec.yaml b/pubspec.yaml index 54148b76..2329babd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: appengine -version: 0.4.3 +version: 0.4.3+1 author: Dart Team description: Support for using Dart as a custom runtime on Google App Engine Flexible Environment homepage: https://github.com/dart-lang/appengine