Fix server.address telemetry to use host only per OpenTelemetry semantic conventions#6742
Merged
eiriktsarpalis merged 2 commits intomainfrom Aug 22, 2025
Merged
Fix server.address telemetry to use host only per OpenTelemetry semantic conventions#6742eiriktsarpalis merged 2 commits intomainfrom
eiriktsarpalis merged 2 commits intomainfrom
Conversation
…tic conventions Co-authored-by: JamesNK <303201+JamesNK@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [MEAI] server.address in telemetry is wrong
Fix server.address telemetry to use host only per OpenTelemetry semantic conventions
Aug 22, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the implementation of server.address telemetry to comply with OpenTelemetry semantic conventions by using only the host portion of URIs instead of the full URI path.
- Updated telemetry attribute extraction to use
Uri.Hostinstead ofUri.GetLeftPart(UriPartial.Path) - Modified corresponding tests to expect "localhost" instead of "http://localhost:12345/something"
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.AI/ChatCompletion/OpenTelemetryChatClient.cs | Updated server address extraction to use host only |
| src/Libraries/Microsoft.Extensions.AI/Embeddings/OpenTelemetryEmbeddingGenerator.cs | Updated endpoint address extraction to use host only |
| test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/OpenTelemetryChatClientTests.cs | Updated test assertion to expect host-only server address |
| test/Libraries/Microsoft.Extensions.AI.Tests/Embeddings/OpenTelemetryEmbeddingGeneratorTests.cs | Updated test assertion to expect host-only server address |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
JamesNK
approved these changes
Aug 22, 2025
eiriktsarpalis
approved these changes
Aug 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenTelemetry semantic conventions specify that
server.addressshould contain only the host portion of a URI (e.g., "localhost"), but the current implementation was incorrectly including the full URI with scheme, port, and path (e.g., "http://localhost:12345/something").Changes made:
OpenTelemetryChatClientto useUri.Hostinstead ofUri.GetLeftPart(UriPartial.Path)for server address extractionOpenTelemetryEmbeddingGeneratorto useUri.Hostinstead ofUri.GetLeftPart(UriPartial.Path)for endpoint address extractionBefore:
After:
This ensures compliance with the OpenTelemetry semantic conventions for server attributes and provides consistent telemetry data that aligns with observability best practices.
Fixes #6741.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
1oavsblobprodcus350.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)37bvsblobprodcus311.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)6s7vsblobprodcus313.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)8xbvsblobprodcus382.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)ckzvsblobprodcus347.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)e7bvsblobprodcus348.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)i1qvsblobprodcus353.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)k0ivsblobprodcus356.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)l49vsblobprodcus358.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)n3kvsblobprodcus335.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)ofvvsblobprodcus315.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)sqdvsblobprodcus333.vsblob.vsassets.io/home/REDACTED/work/extensions/extensions/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /p:TreatWarningsAsErrors=false /p:ContinuousIntegrationBuild=false /home/REDACTED/work/extensions/extensions/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/extensions/extensions/artifacts/toolset/9.0.0-beta.25415.3.txt(dns block)dotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)v53vsblobprodcus320.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)vwvvsblobprodcus334.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)yluvsblobprodcus367.vsblob.vsassets.iodotnet test test/Libraries/Microsoft.Extensions.AI.Tests/Microsoft.Extensions.AI.Tests.csproj -t(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Microsoft Reviewers: Open in CodeFlow