Skip to content

adding sample for tracing custom attributes #51020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

M-Hietala
Copy link
Contributor

adding sample for tracing custom attributes

@Copilot Copilot AI review requested due to automatic review settings July 2, 2025 16:36
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new sample demonstrating how to enrich OpenTelemetry traces with custom attributes via a processor, updates the test project to pull in required tracing packages, and extends the SDK README with a "Tracing" section and sample snippets.

  • Introduce Sample_Telemetry_CustomAttributes.cs showcasing a CustomAttributeProcessor and usage in both async and sync scenarios
  • Update Azure.AI.Projects.Tests.csproj to reference the Console and Azure Monitor OpenTelemetry exporter packages
  • Enhance README.md with a new "Tracing" section containing code snippets for adding custom attributes

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_CustomAttributes.cs Add sample class with custom OpenTelemetry processor and usage examples
sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj Add <PackageReference> entries for tracing exporters
sdk/ai/Azure.AI.Projects/README.md Insert "Tracing" section and snippets for custom attributes
Comments suppressed due to low confidence (6)

sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_CustomAttributes.cs:76

  • This sample test only prints spans to the console—consider adding assertions to verify that the custom tags (e.g., custom.session_id) are actually applied to the Activity.
        public async Task TracingCustomAttributesExample()

sdk/ai/Azure.AI.Projects/README.md:369

  • [nitpick] Consider adding a note about installing the required NuGet packages (e.g., OpenTelemetry.Exporter.Console) before using these samples so users know which dependencies to add.
You can enhance telemetry data by adding custom attributes to activities through implementing a custom processor. This allows you to enrich trace data with application-specific context.

sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_CustomAttributes.cs:7

  • [nitpick] This namespace isn't used in the sample; consider removing the using directive to keep imports clean.
using System.Collections.Generic;

sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_CustomAttributes.cs:9

  • [nitpick] LINQ isn't used in this file; you can remove this using to reduce unnecessary dependencies.
using System.Linq;

sdk/ai/Azure.AI.Projects/tests/Samples/Telemetry/Sample_Telemetry_CustomAttributes.cs:10

  • [nitpick] The System.Threading namespace isn't referenced; consider removing it to simplify imports.
using System.Threading;

sdk/ai/Azure.AI.Projects/tests/Azure.AI.Projects.Tests.csproj:19

  • [nitpick] This package reference isn’t used in the sample (only console exporter is invoked). If you don’t intend to use the Azure Monitor exporter here, you can remove this line.
    <PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants