Skip to content

Commit

Permalink
Fix tracing logic
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Costanzo <ian@anon-solutions.ca>
  • Loading branch information
ianco committed Apr 14, 2020
1 parent e60b6c3 commit 9c36717
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aries_cloudagent/utils/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def tracing_enabled(context, message) -> bool:
return True
elif isinstance(message, dict):
# if there is a trace decorator on the messages then continue to trace
if message.get("~trace") or message.get("trace"):
if message.get("~trace"):
return True
if message.get("trace"):
return message.get("trace")
elif isinstance(message, str):
if "~trace" in message or "trace" in message:
if "~trace" in message:
return True
if "trace" in message:
msg = json.loads(message)
return msg.get("trace")
elif isinstance(message, OutboundMessage):
if message.payload and isinstance(message.payload, AgentMessage):
if message.payload._trace:
Expand Down
4 changes: 4 additions & 0 deletions demo/EFK-stack/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
sorted_events = sorted(events, key = lambda i: i['timestamp'])

threads = {}
thread_count = 0
agents = {}
with open('agent-events.csv', 'w', newline='') as csvfile:
spamwriter = csv.writer(csvfile)
Expand All @@ -47,8 +48,11 @@
print(i, delta_thread)
else:
delta_thread = 0
thread_count = thread_count + 1
threads[x["thread_id"]] = x["timestamp"]
i = i + 1
spamwriter.writerow(
[i, x["str_time"], x["timestamp"], x["handler"], x["ellapsed_milli"], x["thread_id"], x["msg_id"], x["outcome"], x["traced_type"], delta_agent, delta_thread]
)

print("Total threads=", thread_count)

0 comments on commit 9c36717

Please sign in to comment.