Skip to content

[dotnet-port-api] Port feature-usage user-agent telemetry #893

Description

@github-actions

Summary

Ported the .NET feature-usage User-Agent telemetry from microsoft/agent-framework#7709 (commit 43b3ce6027c49bdbcd422dc3959e0bbe28cb833f) into the Go SDK. This adds a public telemetry.FeatureUsage API for process-wide feature tracking, threads feature-usage configuration through the OpenAI and Foundry providers, and aligns provider User-Agent behavior so approved Azure OpenAI and Foundry requests can emit the (feat=v1...) token while stale feature tokens are stripped when they should not be sent.

Ported .NET PRs

Breaking Changes

Yes. The OpenAI provider previously prepended agent-framework-go/... to requests sent to any configured endpoint. It now only emits the Agent Framework User-Agent prefix and feature token for approved Azure OpenAI origins, matching the upstream .NET behavior; unapproved/custom OpenAI origins keep the OpenAI SDK User-Agent without the Agent Framework prefix. This is acceptable in the beta Go SDK because it improves parity with the upstream contract and narrows telemetry to the intended destinations.

Tests and Examples

  • go test ./telemetry ./internal/telemetry ./provider/openaiprovider ./provider/foundryprovider
  • Added feature-usage API tests plus OpenAI and Foundry User-Agent coverage for approved and unapproved origins

Notes

  • This PR intentionally keeps the port narrow: it adds the public feature-usage API and wires the existing Go OpenAI/Foundry User-Agent surfaces that correspond to the selected upstream change.
  • Broader feature-index adoption across additional Go packages can follow separately if maintainers want the full .NET registry coverage beyond the currently affected providers.

Generated by .NET to Go API Porting Agent · gpt54 · 378.4 AIC · ⌖ 21.2 AIC · ⊞ 24.4K ·


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch copilot/dotnet-port-api-feature-usage-382d915f78f1d7f6.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (500 of 997 lines)
From 25e77472f25c43c540ddc258e95a0afba66545d6 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 24 Aug 2026 05:47:11 +0000
Subject: [PATCH] [dotnet-port-api] Port feature-usage user-agent telemetry

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 internal/telemetry/telemetry.go           | 111 +++++++++++--
 internal/telemetry/telemetry_test.go      | 101 ++++++++++++
 provider/foundryprovider/agent.go         |  11 ++
 provider/foundryprovider/agent_test.go    |  24 +++
 provider/foundryprovider/helpers_test.go  |  42 +++++
 provider/openaiprovider/chat.go           |  21 ++-
 provider/openaiprovider/chat_test.go      |  79 ++++++++-
 provider/openaiprovider/responses.go      |   3 +
 provider/openaiprovider/responses_test.go |  46 +++++-
 telemetry/feature_usage.go                | 185 ++++++++++++++++++++++
 telemetry/feature_usage_test.go           |  98 ++++++++++++
 11 files changed, 706 insertions(+), 15 deletions(-)
 create mode 100644 telemetry/feature_usage.go
 create mode 100644 telemetry/feature_usage_test.go

diff --git a/internal/telemetry/telemetry.go b/internal/telemetry/telemetry.go
index 6b91f1849..685ae8c98 100644
--- a/internal/telemetry/telemetry.go
+++ b/internal/telemetry/telemetry.go
@@ -3,13 +3,18 @@
 package telemetry
 
 import (
+	"context"
 	"maps"
 	"net/http"
+	"net/url"
 	"os"
 	"runtime/debug"
 	"slices"
 	"strings"
 	"sync"
+
+	"github.com/microsoft/agent-framework-go/agent"
+	publictelemetry "github.com/microsoft/agent-framework-go/telemetry"
 )
 
 const (
@@ -21,12 +26,36 @@ const (
 	hostedUserAgentPrefix            = "foundry-hosting"
 )
 
+type BaseUserAgentScope int
+
+const (
+	BaseUserAgentScopeApprovedOrigins BaseUserAgentScope = iota
+	BaseUserAgentScopeAllRequests
+)
+
+type FeatureUsageConfig struct {
+	Index                int
+	BaseUserAgentScope   BaseUserAgentScope
+	ApprovedHostSuffixes []string
+}
+
+type featureUsageOpt struct{ F
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions