Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 22f55d3

Browse files
feat: add a stack_trace field to the Error messages specifying where the error occurred (#113)
- [ ] Regenerate this pull request now. Update the Execution proto with stack_trace field which is populated on output if an error occurs, and the call_log_level field can be specified on input to request that function calls and/or errors for the given execution be logged to Cloud Logging. PiperOrigin-RevId: 407842136 Source-Link: googleapis/googleapis@cd48c16 Source-Link: https://github.com/googleapis/googleapis-gen/commit/eefbcd70342adee1df52e4c595243da751e5b6a9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWVmYmNkNzAzNDJhZGVlMWRmNTJlNGM1OTUyNDNkYTc1MWU1YjZhOSJ9 feat: add call_log_level field to Execution messages doc: clarify requirement to escape strings within JSON arguments
1 parent df0a7e8 commit 22f55d3

File tree

2 files changed

+95
-8
lines changed

2 files changed

+95
-8
lines changed

google/cloud/workflows/executions_v1/types/executions.py

+83-8
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ class Execution(proto.Message):
5757
state (google.cloud.workflows.executions_v1.types.Execution.State):
5858
Output only. Current state of the execution.
5959
argument (str):
60-
Input parameters of the execution represented
61-
as a JSON string. The size limit is 32KB.
60+
Input parameters of the execution represented as a JSON
61+
string. The size limit is 32KB.
62+
63+
*Note*: If you are using the REST API directly to run your
64+
workflow, you must escape any JSON string value of
65+
``argument``. Example:
66+
``'{"argument":"{\"firstName\":\"FIRST\",\"lastName\":\"LAST\"}"}'``
6267
result (str):
6368
Output only. Output of the execution represented as a JSON
6469
string. The value can only be present if the execution's
@@ -70,32 +75,101 @@ class Execution(proto.Message):
7075
workflow_revision_id (str):
7176
Output only. Revision of the workflow this
7277
execution is using.
78+
call_log_level (google.cloud.workflows.executions_v1.types.Execution.CallLogLevel):
79+
The call logging level associated to this
80+
execution.
7381
"""
7482

7583
class State(proto.Enum):
76-
r"""Describes the current state of the execution. More states may
77-
be added in the future.
84+
r"""Describes the current state of the execution. More states
85+
might be added in the future.
7886
"""
7987
STATE_UNSPECIFIED = 0
8088
ACTIVE = 1
8189
SUCCEEDED = 2
8290
FAILED = 3
8391
CANCELLED = 4
8492

93+
class CallLogLevel(proto.Enum):
94+
r"""Describes the level of platform logging to apply to calls and
95+
call responses during workflow executions.
96+
"""
97+
CALL_LOG_LEVEL_UNSPECIFIED = 0
98+
LOG_ALL_CALLS = 1
99+
LOG_ERRORS_ONLY = 2
100+
101+
class StackTraceElement(proto.Message):
102+
r"""A single stack element (frame) where an error occurred.
103+
104+
Attributes:
105+
step (str):
106+
The step the error occurred at.
107+
routine (str):
108+
The routine where the error occurred.
109+
position (google.cloud.workflows.executions_v1.types.Execution.StackTraceElement.Position):
110+
The source position information of the stack
111+
trace element.
112+
"""
113+
114+
class Position(proto.Message):
115+
r"""Position contains source position information about the stack
116+
trace element such as line number, column number and length of
117+
the code block in bytes.
118+
119+
Attributes:
120+
line (int):
121+
The source code line number the current
122+
instruction was generated from.
123+
column (int):
124+
The source code column position (of the line)
125+
the current instruction was generated from.
126+
length (int):
127+
The number of bytes of source code making up
128+
this stack trace element.
129+
"""
130+
131+
line = proto.Field(proto.INT64, number=1,)
132+
column = proto.Field(proto.INT64, number=2,)
133+
length = proto.Field(proto.INT64, number=3,)
134+
135+
step = proto.Field(proto.STRING, number=1,)
136+
routine = proto.Field(proto.STRING, number=2,)
137+
position = proto.Field(
138+
proto.MESSAGE, number=3, message="Execution.StackTraceElement.Position",
139+
)
140+
141+
class StackTrace(proto.Message):
142+
r"""A collection of stack elements (frames) where an error
143+
occurred.
144+
145+
Attributes:
146+
elements (Sequence[google.cloud.workflows.executions_v1.types.Execution.StackTraceElement]):
147+
An array of stack elements.
148+
"""
149+
150+
elements = proto.RepeatedField(
151+
proto.MESSAGE, number=1, message="Execution.StackTraceElement",
152+
)
153+
85154
class Error(proto.Message):
86155
r"""Error describes why the execution was abnormally terminated.
87156
88157
Attributes:
89158
payload (str):
90-
Error payload returned by the execution,
91-
represented as a JSON string.
159+
Error message and data returned represented
160+
as a JSON string.
92161
context (str):
93-
Human readable error context, helpful for
94-
debugging purposes.
162+
Human-readable stack trace string.
163+
stack_trace (google.cloud.workflows.executions_v1.types.Execution.StackTrace):
164+
Stack trace with detailed information of
165+
where error was generated.
95166
"""
96167

97168
payload = proto.Field(proto.STRING, number=1,)
98169
context = proto.Field(proto.STRING, number=2,)
170+
stack_trace = proto.Field(
171+
proto.MESSAGE, number=3, message="Execution.StackTrace",
172+
)
99173

100174
name = proto.Field(proto.STRING, number=1,)
101175
start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
@@ -105,6 +179,7 @@ class Error(proto.Message):
105179
result = proto.Field(proto.STRING, number=6,)
106180
error = proto.Field(proto.MESSAGE, number=7, message=Error,)
107181
workflow_revision_id = proto.Field(proto.STRING, number=8,)
182+
call_log_level = proto.Field(proto.ENUM, number=9, enum=CallLogLevel,)
108183

109184

110185
class ListExecutionsRequest(proto.Message):

tests/unit/gapic/executions_v1/test_executions.py

+12
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ def test_create_execution(
823823
argument="argument_value",
824824
result="result_value",
825825
workflow_revision_id="workflow_revision_id_value",
826+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
826827
)
827828
response = client.create_execution(request)
828829

@@ -838,6 +839,7 @@ def test_create_execution(
838839
assert response.argument == "argument_value"
839840
assert response.result == "result_value"
840841
assert response.workflow_revision_id == "workflow_revision_id_value"
842+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
841843

842844

843845
def test_create_execution_from_dict():
@@ -881,6 +883,7 @@ async def test_create_execution_async(
881883
argument="argument_value",
882884
result="result_value",
883885
workflow_revision_id="workflow_revision_id_value",
886+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
884887
)
885888
)
886889
response = await client.create_execution(request)
@@ -897,6 +900,7 @@ async def test_create_execution_async(
897900
assert response.argument == "argument_value"
898901
assert response.result == "result_value"
899902
assert response.workflow_revision_id == "workflow_revision_id_value"
903+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
900904

901905

902906
@pytest.mark.asyncio
@@ -1049,6 +1053,7 @@ def test_get_execution(
10491053
argument="argument_value",
10501054
result="result_value",
10511055
workflow_revision_id="workflow_revision_id_value",
1056+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
10521057
)
10531058
response = client.get_execution(request)
10541059

@@ -1064,6 +1069,7 @@ def test_get_execution(
10641069
assert response.argument == "argument_value"
10651070
assert response.result == "result_value"
10661071
assert response.workflow_revision_id == "workflow_revision_id_value"
1072+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
10671073

10681074

10691075
def test_get_execution_from_dict():
@@ -1107,6 +1113,7 @@ async def test_get_execution_async(
11071113
argument="argument_value",
11081114
result="result_value",
11091115
workflow_revision_id="workflow_revision_id_value",
1116+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
11101117
)
11111118
)
11121119
response = await client.get_execution(request)
@@ -1123,6 +1130,7 @@ async def test_get_execution_async(
11231130
assert response.argument == "argument_value"
11241131
assert response.result == "result_value"
11251132
assert response.workflow_revision_id == "workflow_revision_id_value"
1133+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
11261134

11271135

11281136
@pytest.mark.asyncio
@@ -1265,6 +1273,7 @@ def test_cancel_execution(
12651273
argument="argument_value",
12661274
result="result_value",
12671275
workflow_revision_id="workflow_revision_id_value",
1276+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
12681277
)
12691278
response = client.cancel_execution(request)
12701279

@@ -1280,6 +1289,7 @@ def test_cancel_execution(
12801289
assert response.argument == "argument_value"
12811290
assert response.result == "result_value"
12821291
assert response.workflow_revision_id == "workflow_revision_id_value"
1292+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
12831293

12841294

12851295
def test_cancel_execution_from_dict():
@@ -1323,6 +1333,7 @@ async def test_cancel_execution_async(
13231333
argument="argument_value",
13241334
result="result_value",
13251335
workflow_revision_id="workflow_revision_id_value",
1336+
call_log_level=executions.Execution.CallLogLevel.LOG_ALL_CALLS,
13261337
)
13271338
)
13281339
response = await client.cancel_execution(request)
@@ -1339,6 +1350,7 @@ async def test_cancel_execution_async(
13391350
assert response.argument == "argument_value"
13401351
assert response.result == "result_value"
13411352
assert response.workflow_revision_id == "workflow_revision_id_value"
1353+
assert response.call_log_level == executions.Execution.CallLogLevel.LOG_ALL_CALLS
13421354

13431355

13441356
@pytest.mark.asyncio

0 commit comments

Comments
 (0)