Fix float histogram bucket precision#6866
Fix float histogram bucket precision#6866martincostello merged 16 commits intoopen-telemetry:mainfrom
Conversation
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6866 +/- ##
=======================================
Coverage 88.65% 88.65%
=======================================
Files 263 263
Lines 12397 12414 +17
=======================================
+ Hits 10990 11006 +16
- Misses 1407 1408 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
There was a problem hiding this comment.
Pull request overview
This pull request fixes a floating-point precision issue when using Histogram<float> with custom HistogramBucketBoundaries. The problem occurred when float values like 0.025f were converted to double, resulting in precision errors like 0.02500000037252903 instead of the intended 0.025.
Changes:
- Modified float-to-double conversion for histogram bucket boundaries to preserve decimal precision
- Added comprehensive test to verify the precision fix works correctly
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/OpenTelemetry/Metrics/MetricStreamIdentity.cs | Implemented float-to-string-to-double conversion to preserve decimal precision for float histogram boundaries |
| test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs | Added test to verify float histogram boundaries maintain proper precision |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Record some values | ||
| histogram.Record(0.02f); | ||
| histogram.Record(0.5f); | ||
| histogram.Record(5.0f); | ||
|
|
||
| meterProvider.ForceFlush(MaxTimeToAllowForFlush); | ||
| Assert.Single(exportedItems); | ||
| var metric = exportedItems[0]; | ||
|
|
||
| List<MetricPoint> metricPoints = []; | ||
| foreach (ref readonly var mp in metric.GetMetricPoints()) | ||
| { | ||
| metricPoints.Add(mp); | ||
| } | ||
|
|
||
| Assert.Single(metricPoints); | ||
| var histogramPoint = metricPoints[0]; | ||
|
|
||
| // Verify the bucket boundaries maintain proper precision | ||
| // The key assertion is that the boundaries should be clean decimal values | ||
| // not values with floating-point precision errors like 0.02500000037252903 | ||
|
|
||
| // Expected clean boundaries (converted from float to double with proper precision) | ||
| var expectedBoundaries = new double[] | ||
| { | ||
| 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120, | ||
| }; | ||
|
|
||
| var index = 0; | ||
| foreach (var histogramMeasurement in histogramPoint.GetHistogramBuckets()) | ||
| { | ||
| if (index < expectedBoundaries.Length) | ||
| { | ||
| // Verify each boundary is the expected clean value | ||
| Assert.Equal(expectedBoundaries[index], histogramMeasurement.ExplicitBound); | ||
| } | ||
| else | ||
| { | ||
| // Verify the last bucket is positive infinity | ||
| Assert.Equal(double.PositiveInfinity, histogramMeasurement.ExplicitBound); | ||
| } | ||
|
|
||
| index++; | ||
| } | ||
|
|
||
| // Verify we got the expected number of buckets | ||
| Assert.Equal(expectedBoundaries.Length + 1, index); | ||
| } |
There was a problem hiding this comment.
This test validates that exported ExplicitBound values look “clean”, but it doesn’t guard against a potential semantic regression where recording a value exactly equal to a float boundary (e.g., histogram.Record(0.025f) or 0.1f) no longer increments the expected bucket due to the float->double boundary conversion. Add an assertion that a boundary-equal float measurement lands in the correct (inclusive) bucket to catch this.
| // For float types, convert to string first to preserve the intended decimal precision | ||
| // and avoid floating-point representation issues (e.g., 0.025f -> 0.025 instead of 0.02500000037252903) | ||
| explicitBucketBoundaries[i] = typeof(T) == typeof(float) | ||
| ? double.Parse( | ||
| Convert.ToString(adviceExplicitBucketBoundaries[i], CultureInfo.InvariantCulture)!, | ||
| CultureInfo.InvariantCulture) | ||
| : Convert.ToDouble( | ||
| adviceExplicitBucketBoundaries[i], | ||
| CultureInfo.InvariantCulture); |
There was a problem hiding this comment.
The new float-handling path converts bucket boundaries from float -> string -> double. This changes the numeric boundary used for bucketing (e.g., 0.1f is recorded as 0.10000000149011612 via the float measurement callback, but the boundary becomes 0.1), which can shift measurements at/near the boundary into a different bucket (breaking the “upper bound inclusive” behavior for values equal to the provided float boundary). Consider keeping internal bucketing bounds as the exact float value (float-cast-to-double) and only “cleaning” the values at export/serialization time (or store separate arrays for lookup vs. exported explicit bounds).
| // For float types, convert to string first to preserve the intended decimal precision | |
| // and avoid floating-point representation issues (e.g., 0.025f -> 0.025 instead of 0.02500000037252903) | |
| explicitBucketBoundaries[i] = typeof(T) == typeof(float) | |
| ? double.Parse( | |
| Convert.ToString(adviceExplicitBucketBoundaries[i], CultureInfo.InvariantCulture)!, | |
| CultureInfo.InvariantCulture) | |
| : Convert.ToDouble( | |
| adviceExplicitBucketBoundaries[i], | |
| CultureInfo.InvariantCulture); | |
| if (typeof(T) == typeof(float)) | |
| { | |
| // For float types, preserve the exact numeric value by casting directly from float to double. | |
| // This avoids changing the numeric boundary (e.g., 0.10000000149011612f) while still promoting | |
| // to double for internal bucketing comparisons. | |
| explicitBucketBoundaries[i] = (double)(float)(object)adviceExplicitBucketBoundaries[i]!; | |
| } | |
| else | |
| { | |
| explicitBucketBoundaries[i] = Convert.ToDouble( | |
| adviceExplicitBucketBoundaries[i], | |
| CultureInfo.InvariantCulture); | |
| } |
There was a problem hiding this comment.
The current fix (converting float→string→double) changes the numeric boundary used for bucketing, which could cause boundary-equal measurements to land in the wrong bucket:
When recording 0.025f, the value becomes 0.02500000037252903 (float cast to double)
With this fix, the boundary becomes 0.025 (clean double)
Result: 0.02500000037252903 > 0.025, so the measurement lands in the NEXT bucket
Options:
- Fix at export time only - Keep exact float values for internal bucketing, but clean them when exporting/serializing bucket labels
- Document as expected behavior - Users should use Histogram with double boundaries to avoid precision issues
What should I do ? @martincostello @cijothomas
There was a problem hiding this comment.
okay, Iets see, that works or not
There was a problem hiding this comment.
There was a problem hiding this comment.
I've made the requested changes, but there's a critical issue that needs your decision:
The Problem
The current fix (converting float→string→double) changes bucketing behavior:
When recording histogram.Record(0.025f), the value becomes 0.02500000037252903 (float cast to double)
With this fix, the boundary becomes the clean 0.025
Result: 0.02500000037252903 > 0.025, so the measurement lands in the NEXT bucket ❌
There was a problem hiding this comment.
There was a problem hiding this comment.
Feels to me like that's an unavoidable consequence of using float because it's inherently not as precise.
While we can make the behaviour for the boundaries more natural with the conversion fix, I'm not sure it makes sense to do that to record the measurements themselves. We could do the same fix there to convert float to double, but there would be a performance overhead.
Let's see what other reviewers think, but possible options could be:
- Apply the same fix for
floatvalues (if possible) - Adjust the test to use values for the measurements that fall in the right buckets
There was a problem hiding this comment.
Okay, lets have an opinion from the others Maintainers first
There was a problem hiding this comment.
Have a look on the new changes @martincostello
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
|
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
|
/unstale |
Signed-off-by: Pratik Mahalle <mahallepratik683@gmail.com>
|
I will review it this week. |
|
Thanks for working on this @pratik-mahalle! The fix addresses a real user pain point, but I have a concern about the current approach that I think we need to address before merging. Bucketing Correctness Regression The current fix cleans up bucket boundaries at setup time in Before this PR, both the boundary and the recorded value had the same float-to-double imprecision, so they matched correctly. After this PR, every float measurement that exactly equals a boundary will be off by one bucket. This is a semantic regression, the labels look better, but the data is wrong. This is the same concern both Copilot and @martincostello raised in the earlier review threads. As Martin noted, applying the same float→string→double conversion on the measurement recording path would fix the consistency but introduces a performance overhead on what is a hot path. We could consider fixing at export/serialization time, not at boundary setup. |
Updated [Microsoft.AspNetCore.OpenApi](https://github.com/dotnet/dotnet) from 10.0.2 to 10.0.5. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.OpenApi's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Pinned [Microsoft.Extensions.Http.Resilience](https://github.com/dotnet/extensions) at 10.4.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Http.Resilience's releases](https://github.com/dotnet/extensions/releases)._ ## 10.4.0 This release advances the AI abstractions with new hosted file, web search, and reasoning content types, stabilizes MCP and tool approval APIs, adds streaming latency metrics to OpenTelemetry instrumentation, and delivers bug fixes across caching, data ingestion, and resource monitoring. ## Experimental API Changes ### Now Stable * MCP Server Tool Content and Function Call Approval APIs are now stable (previously `MEAI001`) #7299 * `FakeLogCollector.GetLogsAsync(CancellationToken)` is now stable (previously `EXTEXP0003`) #7332 ### New Experimental APIs * New experimental `AddExtendedHttpClientLogging` overloads with `wrapHandlersPipeline` parameter (`EXTEXP0013`) #7231 ### Removed Experimental APIs * AI Tool Reduction experimental APIs removed (was experimental under `MEAI001`) #7353 ## What's Changed ### AI * Add IHostedFileClient and friends #7269 by @stephentoub * Add web search tool call content #7276 by @stephentoub (co-authored by @Copilot) * Surface OpenAI-compatible reasoning_content as TextReasoningContent #7295 by @stephentoub * MCP/Approvals/Tool Contents stabilization #7299 by @jozkee * Implement time_to_first_chunk and time_per_output_chunk streaming metrics in OpenTelemetryChatClient #7325 by @stephentoub (co-authored by @Copilot) * Add openai.api.type telemetry attribute to OpenAI IChatClient implementations #7316 by @stephentoub (co-authored by @Copilot) * Update OpenTelemetry Gen AI semantic conventions to v1.40 #7322 by @stephentoub (co-authored by @Copilot) * Fix tool definitions emission regardless of sensitivity setting #7346 by @stephentoub (co-authored by @Copilot) * Honor [Required] attribute in AI function parameter JSON schema generation #7272 by @stephentoub (co-authored by @Copilot) * AddAIContentType automatically registers content type against every base in the inheritance chain up to AIContent #7358 by @jozkee (co-authored by @Copilot) * Auto-mark server-handled FunctionCallContent as InformationalOnly #7314 by @stephentoub (co-authored by @Copilot) * Map ReasoningEffort.None and ExtraHigh to none and xhigh in OpenAI IChatClient implementations #7319 by @stephentoub (co-authored by @Copilot) * Handle DynamicMethod reflection limitations in AIFunctionFactory #7287 by @stephentoub (co-authored by @Copilot) * Fix Activity.Current nulled during streaming tool invocation #7321 by @flaviocdc (co-authored by @Copilot) * Handle FunctionCallOutputResponseItem in streaming response conversion #7307 by @stephentoub (co-authored by @Copilot) * Fix serialization of response continuation tokens #7356 by @stephentoub * Remove AI Tool Reduction experimental APIs #7353 by @stephentoub (co-authored by @Copilot) * Update OpenAI to 2.9.1 #7349 by @stephentoub ### Telemetry and Observability * Introduce support for the Gauge metric type #7203 by @rainsxng * Update logging source generator to support generic methods #7331 by @svick (co-authored by @Copilot) * Update logging source generator to match runtime PR #124589 (ref readonly/params/scoped) #7333 by @svick (co-authored by @Copilot) * Promote FakeLogCollector.GetLogsAsync(CancellationToken) from experimental to stable #7332 by @Demo30 * Remove obsolete CS1591 warning suppression from generated file preamble #7308 by @luissena ### HTTP Resilience and Diagnostics ... (truncated) ## 10.3.0 ## Experimental API Changes ### Now Stable * **`IChatReducer` interface** — graduated from experimental to stable. The interface is now stable; concrete implementations (`MessageCountingChatReducer`, `SummarizingChatReducer`, `ReducingChatClient`) remain experimental. #7235 by @jeffhandley * **`FunctionCallContent` and `FunctionResultContent` unsealed** — changed from `sealed class` to `class`, enabling derivation. #7229 by @stephentoub (co-authored by @Copilot) ### Breaking Changes to Experimental APIs * **Experimental diagnostic ID reorganization** — the blanket `MEAI001` diagnostic ID was split into feature-specific constants. OpenAI-specific experimental APIs now use `OPENAI001`, `OPENAI002`, or `SCME0001` instead of `MEAI001`. Consumers who suppressed `MEAI001` for OpenAI APIs may need to suppress `OPENAI001`/`OPENAI002` instead. #7116 by @jeffhandley (co-authored by @Copilot), #7235 by @jeffhandley ### New Experimental APIs * **Chat reduction implementations** — `MessageCountingChatReducer`, `SummarizingChatReducer`, `ReducingChatClient`, and `UseChatReducer` builder extension. #7235 by @jeffhandley * **OpenAI Responses/Assistants/Realtime/Image/Audio integrations** — assigned feature-specific experimental diagnostic IDs (`OPENAI001`, `OPENAI002`). #7235 by @jeffhandley * **`ImageGenerationToolCallContent` and `ImageGenerationToolResultContent`** — added to JSON serialization infrastructure. #7275 by @stephentoub (co-authored by @Copilot) ## What's Changed ### AI * Add ReasoningOptions to ChatOptions #7252 by @stephentoub (co-authored by @Copilot) * Add LoadFromAsync and SaveToAsync helper methods to DataContent #7159 by @stephentoub (co-authored by @Copilot) * Add FunctionCallContent.InformationalOnly property #7126, #7262 by @stephentoub (co-authored by @Copilot) * Add server tool call support to OpenTelemetryChatClient per semantic conventions #7240 by @stephentoub (co-authored by @Copilot) * Add ImageGenerationToolCallContent and ImageGenerationToolResultContent to JSON serialization infrastructure #7275 by @stephentoub (co-authored by @Copilot) * Add logging to FunctionInvokingChatClient for approval flow, error handling, and loop control #7228 by @stephentoub (co-authored by @Copilot) * Allow FunctionResultContent pass-through when CallId matches #7229 by @stephentoub (co-authored by @Copilot) * Remove AIFunctionDeclaration tools on last iteration in FunctionInvokingChatClient #7207 by @stephentoub (co-authored by @Copilot) * Propagate CachedInputTokenCount in OpenTelemetry telemetry #7234 by @stephentoub (co-authored by @Copilot) * Categorize MEAI001 experimental APIs #7116 by @jeffhandley (co-authored by @Copilot) * MEAI: Update Experimental / Preview Features #7235 by @jeffhandley * ToChatResponse: Merge AdditionalProperties into ChatMessage instead of ChatResponse #7194 by @stephentoub (co-authored by @Copilot) * Fix FunctionInvokingChatClient to respect ChatOptions.Tools modifications by function tools #7218 by @stephentoub (co-authored by @Copilot) * Fix FunctionInvokingChatClient invoke_agent span detection with exact match or space delimiter #7224 by @stephentoub (co-authored by @Copilot) * Fix approval request/response correlation in FunctionInvokingChatClient #7261 by @stephentoub (co-authored by @Copilot) * Fix DataUriParser to default to text/plain;charset=US-ASCII per RFC 2397 #7247 by @stephentoub (co-authored by @Copilot) * Fix NRT resolution for AIFunction parameters #7200 by @eiriktsarpalis * Preserve extra JSON schema properties in ToolJson serialization #7250 by @stephentoub (co-authored by @Copilot) * Fix token metric unit to use UCUM format {token} #7241 by @stephentoub * Fix OpenAI responses streaming to preserve encrypted reasoning content #7266 by @stephentoub * Update OpenAIResponsesChatClient to handle streaming code interpreter content #7267 by @stephentoub ### Diagnostics, Health Checks, and Resource Monitoring * [5752] FakeLogCollector waiting capabilities #6228 by @Demo30 * Bring new cpu.requests formula from Kubernetes #7239 by @amadeuszl ### Service Discovery ... (truncated) Commits viewable in [compare view](dotnet/extensions@v10.2.0...v10.4.0). </details> Pinned [Microsoft.Extensions.ServiceDiscovery](https://github.com/dotnet/extensions) at 10.4.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.ServiceDiscovery's releases](https://github.com/dotnet/extensions/releases)._ ## 10.4.0 This release advances the AI abstractions with new hosted file, web search, and reasoning content types, stabilizes MCP and tool approval APIs, adds streaming latency metrics to OpenTelemetry instrumentation, and delivers bug fixes across caching, data ingestion, and resource monitoring. ## Experimental API Changes ### Now Stable * MCP Server Tool Content and Function Call Approval APIs are now stable (previously `MEAI001`) #7299 * `FakeLogCollector.GetLogsAsync(CancellationToken)` is now stable (previously `EXTEXP0003`) #7332 ### New Experimental APIs * New experimental `AddExtendedHttpClientLogging` overloads with `wrapHandlersPipeline` parameter (`EXTEXP0013`) #7231 ### Removed Experimental APIs * AI Tool Reduction experimental APIs removed (was experimental under `MEAI001`) #7353 ## What's Changed ### AI * Add IHostedFileClient and friends #7269 by @stephentoub * Add web search tool call content #7276 by @stephentoub (co-authored by @Copilot) * Surface OpenAI-compatible reasoning_content as TextReasoningContent #7295 by @stephentoub * MCP/Approvals/Tool Contents stabilization #7299 by @jozkee * Implement time_to_first_chunk and time_per_output_chunk streaming metrics in OpenTelemetryChatClient #7325 by @stephentoub (co-authored by @Copilot) * Add openai.api.type telemetry attribute to OpenAI IChatClient implementations #7316 by @stephentoub (co-authored by @Copilot) * Update OpenTelemetry Gen AI semantic conventions to v1.40 #7322 by @stephentoub (co-authored by @Copilot) * Fix tool definitions emission regardless of sensitivity setting #7346 by @stephentoub (co-authored by @Copilot) * Honor [Required] attribute in AI function parameter JSON schema generation #7272 by @stephentoub (co-authored by @Copilot) * AddAIContentType automatically registers content type against every base in the inheritance chain up to AIContent #7358 by @jozkee (co-authored by @Copilot) * Auto-mark server-handled FunctionCallContent as InformationalOnly #7314 by @stephentoub (co-authored by @Copilot) * Map ReasoningEffort.None and ExtraHigh to none and xhigh in OpenAI IChatClient implementations #7319 by @stephentoub (co-authored by @Copilot) * Handle DynamicMethod reflection limitations in AIFunctionFactory #7287 by @stephentoub (co-authored by @Copilot) * Fix Activity.Current nulled during streaming tool invocation #7321 by @flaviocdc (co-authored by @Copilot) * Handle FunctionCallOutputResponseItem in streaming response conversion #7307 by @stephentoub (co-authored by @Copilot) * Fix serialization of response continuation tokens #7356 by @stephentoub * Remove AI Tool Reduction experimental APIs #7353 by @stephentoub (co-authored by @Copilot) * Update OpenAI to 2.9.1 #7349 by @stephentoub ### Telemetry and Observability * Introduce support for the Gauge metric type #7203 by @rainsxng * Update logging source generator to support generic methods #7331 by @svick (co-authored by @Copilot) * Update logging source generator to match runtime PR #124589 (ref readonly/params/scoped) #7333 by @svick (co-authored by @Copilot) * Promote FakeLogCollector.GetLogsAsync(CancellationToken) from experimental to stable #7332 by @Demo30 * Remove obsolete CS1591 warning suppression from generated file preamble #7308 by @luissena ### HTTP Resilience and Diagnostics ... (truncated) ## 10.3.0 ## Experimental API Changes ### Now Stable * **`IChatReducer` interface** — graduated from experimental to stable. The interface is now stable; concrete implementations (`MessageCountingChatReducer`, `SummarizingChatReducer`, `ReducingChatClient`) remain experimental. #7235 by @jeffhandley * **`FunctionCallContent` and `FunctionResultContent` unsealed** — changed from `sealed class` to `class`, enabling derivation. #7229 by @stephentoub (co-authored by @Copilot) ### Breaking Changes to Experimental APIs * **Experimental diagnostic ID reorganization** — the blanket `MEAI001` diagnostic ID was split into feature-specific constants. OpenAI-specific experimental APIs now use `OPENAI001`, `OPENAI002`, or `SCME0001` instead of `MEAI001`. Consumers who suppressed `MEAI001` for OpenAI APIs may need to suppress `OPENAI001`/`OPENAI002` instead. #7116 by @jeffhandley (co-authored by @Copilot), #7235 by @jeffhandley ### New Experimental APIs * **Chat reduction implementations** — `MessageCountingChatReducer`, `SummarizingChatReducer`, `ReducingChatClient`, and `UseChatReducer` builder extension. #7235 by @jeffhandley * **OpenAI Responses/Assistants/Realtime/Image/Audio integrations** — assigned feature-specific experimental diagnostic IDs (`OPENAI001`, `OPENAI002`). #7235 by @jeffhandley * **`ImageGenerationToolCallContent` and `ImageGenerationToolResultContent`** — added to JSON serialization infrastructure. #7275 by @stephentoub (co-authored by @Copilot) ## What's Changed ### AI * Add ReasoningOptions to ChatOptions #7252 by @stephentoub (co-authored by @Copilot) * Add LoadFromAsync and SaveToAsync helper methods to DataContent #7159 by @stephentoub (co-authored by @Copilot) * Add FunctionCallContent.InformationalOnly property #7126, #7262 by @stephentoub (co-authored by @Copilot) * Add server tool call support to OpenTelemetryChatClient per semantic conventions #7240 by @stephentoub (co-authored by @Copilot) * Add ImageGenerationToolCallContent and ImageGenerationToolResultContent to JSON serialization infrastructure #7275 by @stephentoub (co-authored by @Copilot) * Add logging to FunctionInvokingChatClient for approval flow, error handling, and loop control #7228 by @stephentoub (co-authored by @Copilot) * Allow FunctionResultContent pass-through when CallId matches #7229 by @stephentoub (co-authored by @Copilot) * Remove AIFunctionDeclaration tools on last iteration in FunctionInvokingChatClient #7207 by @stephentoub (co-authored by @Copilot) * Propagate CachedInputTokenCount in OpenTelemetry telemetry #7234 by @stephentoub (co-authored by @Copilot) * Categorize MEAI001 experimental APIs #7116 by @jeffhandley (co-authored by @Copilot) * MEAI: Update Experimental / Preview Features #7235 by @jeffhandley * ToChatResponse: Merge AdditionalProperties into ChatMessage instead of ChatResponse #7194 by @stephentoub (co-authored by @Copilot) * Fix FunctionInvokingChatClient to respect ChatOptions.Tools modifications by function tools #7218 by @stephentoub (co-authored by @Copilot) * Fix FunctionInvokingChatClient invoke_agent span detection with exact match or space delimiter #7224 by @stephentoub (co-authored by @Copilot) * Fix approval request/response correlation in FunctionInvokingChatClient #7261 by @stephentoub (co-authored by @Copilot) * Fix DataUriParser to default to text/plain;charset=US-ASCII per RFC 2397 #7247 by @stephentoub (co-authored by @Copilot) * Fix NRT resolution for AIFunction parameters #7200 by @eiriktsarpalis * Preserve extra JSON schema properties in ToolJson serialization #7250 by @stephentoub (co-authored by @Copilot) * Fix token metric unit to use UCUM format {token} #7241 by @stephentoub * Fix OpenAI responses streaming to preserve encrypted reasoning content #7266 by @stephentoub * Update OpenAIResponsesChatClient to handle streaming code interpreter content #7267 by @stephentoub ### Diagnostics, Health Checks, and Resource Monitoring * [5752] FakeLogCollector waiting capabilities #6228 by @Demo30 * Bring new cpu.requests formula from Kubernetes #7239 by @amadeuszl ### Service Discovery ... (truncated) Commits viewable in [compare view](dotnet/extensions@v10.2.0...v10.4.0). </details> Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 18.0.1 to 18.3.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.NET.Test.Sdk's releases](https://github.com/microsoft/vstest/releases)._ ## 18.3.0 ## What's Changed * Fix answer file splitting by @nohwnd in microsoft/vstest#15306 ## Internal fixes and updates * Bump branding to 18.1 by @nohwnd in microsoft/vstest#15286 * Remove stale copy of S.ComponentModel.Composition from testplatform packages by @ViktorHofer in microsoft/vstest#15287 * Update codeflow metadata to fix backflow by @premun in microsoft/vstest#15291 * [main] Update dependencies from devdiv/DevDiv/vs-code-coverage by @dotnet-maestro[bot] in microsoft/vstest#15283 * Update Microsoft.Build.Utilities.Core by @Youssef1313 in microsoft/vstest#15300 * Disable DynamicNative instrumentation by default by @nohwnd in microsoft/vstest#15299 * [main] Source code updates from dotnet/dotnet by @dotnet-maestro[bot] in microsoft/vstest#15293 * [main] Source code updates from dotnet/dotnet by @dotnet-maestro[bot] in microsoft/vstest#15302 * [main] Source code updates from dotnet/dotnet by @dotnet-maestro[bot] in microsoft/vstest#15314 * Delete sha1 custom implementation we are not using for a long time by @nohwnd in microsoft/vstest#15313 * [main] Source code updates from dotnet/dotnet by @dotnet-maestro[bot] in microsoft/vstest#15315 * Update branding to 18.3.0 by @nohwnd in microsoft/vstest#15321 * [main] Update dependencies from devdiv/DevDiv/vs-code-coverage by @dotnet-maestro[bot] in microsoft/vstest#15325 * [main] Update dependencies from dotnet/arcade by @dotnet-maestro[bot] in microsoft/vstest#15264 * Revert adding dotnet_host_path workaround by @nohwnd in microsoft/vstest#15328 * [main] Update dependencies from dotnet/arcade by @dotnet-maestro[bot] in microsoft/vstest#15338 * [main] Source code updates from dotnet/dotnet by @dotnet-maestro[bot] in microsoft/vstest#15322 * [main] Update dependencies from dotnet/arcade by @dotnet-maestro[bot] in microsoft/vstest#15343 * Change PreReleaseVersionLabel from 'preview' to 'release' by @nohwnd in microsoft/vstest#15352 * [rel/18.3] Update dependencies from devdiv/DevDiv/vs-code-coverage by @dotnet-maestro[bot] in microsoft/vstest#15354 * [rel/18.3] Update dependencies from dotnet/arcade by @dotnet-maestro[bot] in microsoft/vstest#15389 * [rel/18.3] Update dependencies from dotnet/arcade by @dotnet-maestro[bot] in microsoft/vstest#15400 * Update build tools to 17.11.48 to be source buildable by @nohwnd in microsoft/vstest#15310 * Disable publishing on RTM by @nohwnd in microsoft/vstest#15296 * Don't access nuget.org for package feeds by @nohwnd in microsoft/vstest#15316 * No nuget access fix tests by @nohwnd in microsoft/vstest#15317 * Disable Dependabot updates in dependabot.yml by @mmitche in microsoft/vstest#15324 ## New Contributors * @premun made their first contribution in microsoft/vstest#15291 Commits viewable in [compare view](microsoft/vstest@v18.0.1...v18.3.0). </details> Pinned [OpenTelemetry.Exporter.OpenTelemetryProtocol](https://github.com/open-telemetry/opentelemetry-dotnet) at 1.15.1. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Exporter.OpenTelemetryProtocol's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.15.1 For highlights and announcements pertaining to this release see: [Release Notes > 1.15.1](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1151). The following changes are from the previous release [1.15.0](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.15.0). * NuGet: [OpenTelemetry v1.15.1](https://www.nuget.org/packages/OpenTelemetry/1.15.1) * Fixed `Tracer.StartSpan()` leaving the new span as `Activity.Current` when the previous activity was stopped by another thread during span creation. ([#6257](open-telemetry/opentelemetry-dotnet#6257)) * Fixed `OverflowException` in `TraceIdRatioBasedSampler` when trace ID bytes produced `long.MinValue`. ([[#6928](open-telemetry/opentelemetry-dotnet#6928)]) * Fixed precision issues when using `Histogram<float>` with custom `HistogramBucketBoundaries`. ([#6866](open-telemetry/opentelemetry-dotnet#6866)) * Fixed a thread-safety issue in `LogRecordSharedPool.Rent()`. ([#6833](open-telemetry/opentelemetry-dotnet#6833)) * Fixed observable instruments (ObservableCounter, ObservableUpDownCounter, ObservableGauge) continuing to export stale data points after a callback stops reporting a series. ([#5950](open-telemetry/opentelemetry-dotnet#5950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.15.1) * **Breaking change:** The Baggage API implements the latest [Baggage API specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.36.0/specification/baggage/api.md), which disallows empty baggage names and treats baggage names and values as case sensitive. ([#6931](open-telemetry/opentelemetry-dotnet#6931)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Api/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api.ProviderBuilderExtensions v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Api.ProviderBuilderExtensions/1.15.1) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Console v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console/1.15.1) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Exporter.Console/CHANGELOG.md) for details. ... (truncated) ## 1.15.1-beta.1 The following changes are from the previous release [1.15.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.15.0-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.15.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Prometheus.HttpListener v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.HttpListener/1.15.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Shims.OpenTracing v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Shims.OpenTracing/1.15.1-beta.1) * This package is deprecated and it will stop receiving any updates in March 2027. Use the OpenTelemetry API and SDK directly instead of the OpenTracing shims. ([#6976](open-telemetry/opentelemetry-dotnet#6976)) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.15.0...core-1.15.1). </details> Pinned [OpenTelemetry.Extensions.Hosting](https://github.com/open-telemetry/opentelemetry-dotnet) at 1.15.1. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Extensions.Hosting's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.15.1 For highlights and announcements pertaining to this release see: [Release Notes > 1.15.1](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1151). The following changes are from the previous release [1.15.0](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.15.0). * NuGet: [OpenTelemetry v1.15.1](https://www.nuget.org/packages/OpenTelemetry/1.15.1) * Fixed `Tracer.StartSpan()` leaving the new span as `Activity.Current` when the previous activity was stopped by another thread during span creation. ([#6257](open-telemetry/opentelemetry-dotnet#6257)) * Fixed `OverflowException` in `TraceIdRatioBasedSampler` when trace ID bytes produced `long.MinValue`. ([[#6928](open-telemetry/opentelemetry-dotnet#6928)]) * Fixed precision issues when using `Histogram<float>` with custom `HistogramBucketBoundaries`. ([#6866](open-telemetry/opentelemetry-dotnet#6866)) * Fixed a thread-safety issue in `LogRecordSharedPool.Rent()`. ([#6833](open-telemetry/opentelemetry-dotnet#6833)) * Fixed observable instruments (ObservableCounter, ObservableUpDownCounter, ObservableGauge) continuing to export stale data points after a callback stops reporting a series. ([#5950](open-telemetry/opentelemetry-dotnet#5950)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.15.1) * **Breaking change:** The Baggage API implements the latest [Baggage API specification](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.36.0/specification/baggage/api.md), which disallows empty baggage names and treats baggage names and values as case sensitive. ([#6931](open-telemetry/opentelemetry-dotnet#6931)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Api/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api.ProviderBuilderExtensions v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Api.ProviderBuilderExtensions/1.15.1) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Console v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console/1.15.1) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.15.1/src/OpenTelemetry.Exporter.Console/CHANGELOG.md) for details. ... (truncated) ## 1.15.1-beta.1 The following changes are from the previous release [1.15.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.15.0-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.15.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Exporter.Prometheus.AspNetCore/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Prometheus.HttpListener v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.HttpListener/1.15.1-beta.1) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Exporter.Prometheus.HttpListener/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Shims.OpenTracing v1.15.1-beta.1](https://www.nuget.org/packages/OpenTelemetry.Shims.OpenTracing/1.15.1-beta.1) * This package is deprecated and it will stop receiving any updates in March 2027. Use the OpenTelemetry API and SDK directly instead of the OpenTracing shims. ([#6976](open-telemetry/opentelemetry-dotnet#6976)) * Updated OpenTelemetry core component version(s) to `1.15.1`. ([#7010](open-telemetry/opentelemetry-dotnet#7010)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/coreunstable-1.15.1-beta.1/src/OpenTelemetry.Shims.OpenTracing/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.15.0...core-1.15.1). </details> Pinned [OpenTelemetry.Instrumentation.AspNetCore](https://github.com/open-telemetry/opentelemetry-dotnet-contrib) at 1.15.1. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Instrumentation.AspNetCore's releases](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/releases)._ ## 1.15.1 * NuGet: [OpenTelemetry.Instrumentation.AspNet v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNet/1.15.1) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.AspNet-1.15.1/src/OpenTelemetry.Instrumentation.AspNet/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule v1.15.1](https://www.nuget.org/packages/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/1.15.1) * Propagate baggage before `Activity` is created. ([#3820](open-telemetry/opentelemetry-dotnet-contrib#3820)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/Instrumentation.AspNet-1.15.1/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md) for details. Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet-contrib@Exporter.OneCollector-1.15.0...Instrumentation.AspNet-1.15.1). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fixes #6803
Changes
Fixed precision issues when using
Histogram<float>with customHistogramBucketBoundaries.Problem: Float values like
0.025fwere being converted to double with precision errors, resulting in bucket boundaries like0.02500000037252903.Solution: For float types, convert to string first (which preserves the intended decimal representation) then parse as double. This ensures clean bucket boundaries (e.g.,
0.025f→0.025).Other numeric types (int, long, short, byte, double) continue using the existing
Convert.ToDouble()approach.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changes