@@ -51,7 +51,7 @@ def sentry_func(*args, **kwargs):
51
51
52
52
configured_time = int (configured_time )
53
53
54
- initial_time = datetime .now ()
54
+ initial_time = datetime .utcnow ()
55
55
56
56
with hub .push_scope () as scope :
57
57
with capture_internal_exceptions ():
@@ -119,7 +119,7 @@ def _make_request_event_processor(configured_timeout, initial_time):
119
119
def event_processor (event , hint ):
120
120
# type: (Event, Hint) -> Optional[Event]
121
121
122
- final_time = datetime .now ()
122
+ final_time = datetime .utcnow ()
123
123
time_diff = final_time - initial_time
124
124
125
125
execution_duration_in_millis = time_diff .microseconds / MILLIS_TO_SECONDS
@@ -136,7 +136,7 @@ def event_processor(event, hint):
136
136
}
137
137
138
138
extra ["google cloud logs" ] = {
139
- "url" : _get_google_cloud_logs_url (initial_time ),
139
+ "url" : _get_google_cloud_logs_url (final_time ),
140
140
}
141
141
142
142
request = event .get ("request" , {})
@@ -150,7 +150,7 @@ def event_processor(event, hint):
150
150
return event_processor
151
151
152
152
153
- def _get_google_cloud_logs_url (initial_time ):
153
+ def _get_google_cloud_logs_url (final_time ):
154
154
# type: (datetime) -> str
155
155
"""
156
156
Generates a Google Cloud Logs console URL based on the environment variables
@@ -159,22 +159,22 @@ def _get_google_cloud_logs_url(initial_time):
159
159
Returns:
160
160
str -- Google Cloud Logs Console URL to logs.
161
161
"""
162
- hour_ago = initial_time - timedelta (hours = 1 )
162
+ hour_ago = final_time - timedelta (hours = 1 )
163
163
164
164
url = (
165
165
"https://console.cloud.google.com/logs/viewer?project={project}&resource=cloud_function"
166
166
"%2Ffunction_name%2F{function_name}%2Fregion%2F{region}&minLogLevel=0&expandAll=false"
167
- "×tamp={initial_time}&customFacets=&limitCustomFacetWidth=true"
168
- "&dateRangeStart={timestamp_start}&dateRangeEnd={timestamp_end}"
169
- "&interval=PT1H&scrollTimestamp={timestamp_current}"
167
+ "×tamp={initial_time}Z &customFacets=&limitCustomFacetWidth=true"
168
+ "&dateRangeStart={timestamp_start}Z &dateRangeEnd={timestamp_end}Z "
169
+ "&interval=PT1H&scrollTimestamp={timestamp_current}Z "
170
170
).format (
171
171
project = environ .get ("GCP_PROJECT" ),
172
172
function_name = environ .get ("FUNCTION_NAME" ),
173
173
region = environ .get ("FUNCTION_REGION" ),
174
- initial_time = initial_time ,
174
+ initial_time = final_time ,
175
175
timestamp_start = hour_ago ,
176
- timestamp_end = initial_time ,
177
- timestamp_current = initial_time ,
176
+ timestamp_end = final_time ,
177
+ timestamp_current = final_time ,
178
178
)
179
179
180
180
return url
0 commit comments