Skip to content

Commit 3bd76d4

Browse files
author
Shantanu Dhiman
committed
Changes:
1) Modified log url to include standard format for timestamp to construct log url. 2) Added code in tox.ini file to run test suite for GCP unit test cases.
1 parent 16cf50a commit 3bd76d4

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

sentry_sdk/integrations/gcp.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,21 +160,22 @@ def _get_google_cloud_logs_url(final_time):
160160
str -- Google Cloud Logs Console URL to logs.
161161
"""
162162
hour_ago = final_time - timedelta(hours=1)
163+
formatstring = "%Y-%m-%dT%H:%M:%SZ"
163164

164165
url = (
165166
"https://console.cloud.google.com/logs/viewer?project={project}&resource=cloud_function"
166167
"%2Ffunction_name%2F{function_name}%2Fregion%2F{region}&minLogLevel=0&expandAll=false"
167-
"&timestamp={initial_time}Z&customFacets=&limitCustomFacetWidth=true"
168-
"&dateRangeStart={timestamp_start}Z&dateRangeEnd={timestamp_end}Z"
169-
"&interval=PT1H&scrollTimestamp={timestamp_current}Z"
168+
"&timestamp={initial_time}&customFacets=&limitCustomFacetWidth=true"
169+
"&dateRangeStart={timestamp_start}&dateRangeEnd={timestamp_end}"
170+
"&interval=PT1H&scrollTimestamp={timestamp_current}"
170171
).format(
171172
project=environ.get("GCP_PROJECT"),
172173
function_name=environ.get("FUNCTION_NAME"),
173174
region=environ.get("FUNCTION_REGION"),
174-
initial_time=final_time,
175-
timestamp_start=hour_ago,
176-
timestamp_end=final_time,
177-
timestamp_current=final_time,
175+
initial_time=final_time.strftime(formatstring),
176+
timestamp_start=hour_ago.strftime(formatstring),
177+
timestamp_end=final_time.strftime(formatstring),
178+
timestamp_current=final_time.strftime(formatstring),
178179
)
179180

180181
return url

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ envlist =
4444
# The aws_lambda tests deploy to the real AWS and have their own matrix of Python versions.
4545
py3.7-aws_lambda
4646

47+
py3.7-gcp
48+
4749
{pypy,py2.7,py3.5,py3.6,py3.7,py3.8}-pyramid-{1.6,1.7,1.8,1.9,1.10}
4850

4951
{pypy,py2.7,py3.5,py3.6}-rq-{0.6,0.7,0.8,0.9,0.10,0.11}

0 commit comments

Comments
 (0)