Skip to content

Commit b3fe081

Browse files
authored
Merge pull request #780 from MicrosoftDocs/taochen/update-workflow-observability-doc
Update workflow observability doc
2 parents bed3e8b + e8ad9c4 commit b3fe081

3 files changed

Lines changed: 48 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Agent Framework integrates with [OpenTelemetry](https://opentelemetry.io/), and
2121

2222
::: zone pivot="programming-language-csharp"
2323

24-
## Enable Observability
24+
## Enable Observability (C#)
2525

2626
To enable observability for your chat client, you need to build the chat client as follows:
2727

@@ -165,7 +165,7 @@ See a full example of an agent with OpenTelemetry enabled in the [Agent Framewor
165165

166166
::: zone pivot="programming-language-python"
167167

168-
## Enable Observability
168+
## Enable Observability (Python)
169169

170170
To enable observability in your python application, in most cases you do not need to install anything extra, by default the following package are installed:
171171

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

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

1314
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.
1415

16+
> [!TIP]
17+
> Observability is a framework-wide feature and is not limited to workflows. For more information, refer to [Agent Observability](../agents/agent-observability.md).
18+
1519
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.
1620

1721
## Enable Observability
1822

19-
Observability is enabled framework-wide by setting the `ENABLE_OTEL=true` environment variable or calling `setup_observability()` at the beginning of your application.
23+
::: zone pivot="programming-language-csharp"
24+
25+
Please refer to [Enabling Observability](../agents/agent-observability.md#enable-observability-c) for instructions on enabling observability in your applications.
26+
27+
::: zone-end
2028

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-
```
29+
::: zone pivot="programming-language-python"
2730

28-
```python
29-
from agent_framework.observability import setup_observability
31+
Please refer to [Enabling Observability](../agents/agent-observability.md#enable-observability-python) for instructions on enabling observability in your applications.
3032

31-
setup_observability(enable_sensitive_data=True)
32-
```
33+
::: zone-end
3334

3435
## Workflow Spans
3536

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)