Skip to content

Commit 88b4a63

Browse files
committed
Update workflow observability doc
1 parent bed3e8b commit 88b4a63

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

agent-framework/user-guide/workflows/observability.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,13 @@ ms.service: agent-framework
1212

1313
Observability provides insights into the internal state and behavior of workflows during execution. This includes logging, metrics, and tracing capabilities that help monitor and debug workflows.
1414

15+
> [!TIP] Observability is a framework-wide feature and is not limited to workflows. For more information, refer to [Agent Observability](../agents/agent-observability.md).
16+
1517
Aside from the standard [GenAI telemetry](https://opentelemetry.io/docs/specs/semconv/gen-ai/), Agent Framework Workflows emits additional spans, logs, and metrics to provide deeper insights into workflow execution. These observability features help developers understand the flow of messages, the performance of executors, and any errors that may occur.
1618

1719
## Enable Observability
1820

19-
Observability is enabled framework-wide by setting the `ENABLE_OTEL=true` environment variable or calling `setup_observability()` at the beginning of your application.
20-
21-
```env
22-
# This is not required if you run `setup_observability()` in your code
23-
ENABLE_OTEL=true
24-
# Sensitive data (e.g., message content) will be included in logs and traces if this is set to true
25-
ENABLE_SENSITIVE_DATA=true
26-
```
27-
28-
```python
29-
from agent_framework.observability import setup_observability
30-
31-
setup_observability(enable_sensitive_data=True)
32-
```
21+
Please refer to [Enabling Observability](../agents/agent-observability#enable-observability) for instructions on enabling observability in your applications.
3322

3423
## Workflow Spans
3524

agent-framework/user-guide/workflows/visualization.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Microsoft Agent Framework Workflows - Visualization
33
description: In-depth look at Visualization in Microsoft Agent Framework Workflows.
4+
zone_pivot_groups: programming-languages
45
author: TaoChenOSU
56
ms.topic: tutorial
67
ms.author: taochen
@@ -12,6 +13,37 @@ ms.service: agent-framework
1213

1314
Sometimes a workflow that has multiple executors and complex interactions can be hard to understand from just reading the code. Visualization can help you see the structure of the workflow more clearly, so that you can verify that it has the intended design.
1415

16+
::: zone pivot="programming-language-csharp"
17+
18+
Workflow visualization can be achieved via extension methods on the `Workflow` class: `ToMermaidString()`, and `ToDotString()`, which generate Mermaid diagram format and Graphviz DOT format respectively.
19+
20+
```csharp
21+
using Microsoft.Agents.AI.Workflows;
22+
23+
// Create a workflow with a fan-out and fan-in pattern
24+
var workflow = new WorkflowBuilder()
25+
.SetStartExecutor(dispatcher)
26+
.AddFanOutEdges(dispatcher, [researcher, marketer, legal])
27+
.AddFanInEdges([researcher, marketer, legal], aggregator)
28+
.Build();
29+
30+
// Mermaid diagram
31+
Console.WriteLine(workflow.ToMermaidString());
32+
33+
// DiGraph string
34+
Console.WriteLine(workflow.ToDotString());
35+
```
36+
37+
To create an image file from the DOT format, you can use GraphViz tools with the following command:
38+
39+
```bash
40+
dotnet run | tail -n +20 | dot -Tpng -o workflow.png
41+
```
42+
43+
::: zone-end
44+
45+
::: zone pivot="programming-language-python"
46+
1547
Workflow visualization is done via a `WorkflowViz` object that can be instantiated with a `Workflow` object. The `WorkflowViz` object can then generate visualizations in different formats, such as Graphviz DOT format or Mermaid diagram format.
1648

1749
> [!TIP]
@@ -45,6 +77,8 @@ print(viz.to_digraph())
4577
print(viz.export(format="svg"))
4678
```
4779

80+
::: zone-end
81+
4882
The exported diagram will look similar to the following for the example workflow:
4983

5084
```mermaid

0 commit comments

Comments
 (0)