Skip to content

.Net: Added traces for Agent invocations#10387

Merged
dmytrostruk merged 9 commits intomicrosoft:mainfrom
dmytrostruk:tracing-in-agents
Feb 4, 2025
Merged

.Net: Added traces for Agent invocations#10387
dmytrostruk merged 9 commits intomicrosoft:mainfrom
dmytrostruk:tracing-in-agents

Conversation

@dmytrostruk
Copy link
Copy Markdown
Member

Motivation and Context

Resolves: #10174

This PR instruments Agent invocation operation with traces and adds an example with tracing enabled using Console and Application Insights.

Trace operation and attribute names are based on the work in following PR about adding AI Agent Semantic Convention to OpenTelemetry (currently in-progress): open-telemetry/semantic-conventions#1739.

Examples from Application Insights:

End-to-end transaction:
image

Traces:
image

Trace attributes related to Agent:
image

Contribution Checklist

@dmytrostruk dmytrostruk self-assigned this Feb 4, 2025
@dmytrostruk dmytrostruk requested a review from a team as a code owner February 4, 2025 04:47
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code documentation labels Feb 4, 2025
@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 4, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 4, 2025
@crickman crickman added the agents label Feb 4, 2025
Comment thread dotnet/src/InternalUtilities/src/Diagnostics/ActivityExtensions.cs
Comment thread dotnet/src/Agents/AzureAI/AzureAIAgent.cs
Comment thread dotnet/src/InternalUtilities/src/Diagnostics/ActivityExtensions.cs
@markwallace-microsoft markwallace-microsoft added the kernel Issues or pull requests impacting the core kernel label Feb 4, 2025
@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 4, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 4, 2025
@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 4, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 4, 2025
@dmytrostruk dmytrostruk added this pull request to the merge queue Feb 4, 2025
Merged via the queue into microsoft:main with commit 1e15f6c Feb 4, 2025
@dmytrostruk dmytrostruk deleted the tracing-in-agents branch February 4, 2025 22:44
github-merge-queue Bot pushed a commit that referenced this pull request Feb 5, 2025
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Python parity with this PR:
#10387

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Update agent invoke span name and add attributes.

This is a breaking change: users who are currently relying on the span
name in their queries will need to update their queries to use the new
name or match new patterns. This is an experimental feature so breaking
changes are expected.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Resolves: microsoft#10174

This PR instruments Agent invocation operation with traces and adds an
example with tracing enabled using Console and Application Insights.

Trace operation and attribute names are based on the work in following
PR about adding AI Agent Semantic Convention to OpenTelemetry (currently
in-progress):
open-telemetry/semantic-conventions#1739.

Examples from Application Insights:

End-to-end transaction:

![image](https://github.com/user-attachments/assets/80647a3e-d2a4-4c08-8e3f-029727cb91ed)

Traces:

![image](https://github.com/user-attachments/assets/9f51c94c-3020-4106-af10-32e2a6cad023)

Trace attributes related to Agent:

![image](https://github.com/user-attachments/assets/c178bd84-812a-46cd-a8e1-f507238e7fa1)


### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Python parity with this PR:
microsoft#10387

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Update agent invoke span name and add attributes.

This is a breaking change: users who are currently relying on the span
name in their queries will need to update their queries to use the new
name or match new patterns. This is an experimental feature so breaking
changes are expected.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

New Feature: Agent Names captured in traces and logs to aggregate per agent stats

5 participants