Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Log the appengine.googleapis.com/trace_id label for requests (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Nov 30, 2017
1 parent 3c21d96 commit b3fc653
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
30 changes: 15 additions & 15 deletions lib/src/grpc_api_impl/logging_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appengine
version: 0.4.3
version: 0.4.3+1
author: Dart Team <[email protected]>
description: Support for using Dart as a custom runtime on Google App Engine Flexible Environment
homepage: https://github.com/dart-lang/appengine
Expand Down

0 comments on commit b3fc653

Please sign in to comment.