Skip to content

Instantly share code, notes, and snippets.

View antonfirsov's full-sized avatar

Anton Firszov antonfirsov

View GitHub Profile
@antonfirsov
antonfirsov / HttpClient-Telemetry-Breaking.MD
Created October 1, 2024 12:49
Telemetry Breaking changes

[Breaking Change]: HttpTelemetry Redacts Query Strings by Default Description: In .NET 9, the default behavior of HttpTelemetry (EventSource "System.Net.Http") has been modified to redact query strings. This change is aimed at enhancing security by preventing the logging of potentially sensitive information contained in query strings. The same opt-out mechanism used for distributed tracing (Activity) and HttpClientFactory logging is applied here. For scenarios where logging query strings is necessary and deemed safe, this behavior can be overridden by enabling the System.Net.Http.DisableUriRedaction AppContext switch or by setting the DOTNET_SYSTEM_NET_HTTP_DISABLEURIREDACTION environment variable. Previous Behavior: Previously, HttpTelemetry logs included query strings by default, which could inadvertently expose sensitive information. New Behavior: With the new change, query strings are redacted from HttpTelemetry logs by default. Developers can enable query string logging global

**** sending Request1 to example.com ****
Activity.TraceId: a204d84ced611be46da0dba9313ac4dc
Activity.SpanId: d3ffeb48a6f38d34
Activity.TraceFlags: Recorded
Activity.ParentSpanId: 11607beab559707f
Activity.ActivitySourceName: System.Net.NameResolution
Activity.DisplayName: System.Net.NameResolution.DsnLookup
Activity.Kind: Client
Activity.StartTime: 2024-06-24T21:43:21.5808535Z
Activity.Duration: 00:00:00.0096843

Bmp - main

Method TestImage Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
'ImageSharp Bmp' Bmp/Car.bmp 86.65 us 24.70 us 1.354 us 0.1221 - - 2 KB

Bmp - PR

Method TestImage Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
using BenchmarkDotNet.Attributes;
using System.Collections.Frozen;
[MemoryDiagnoser]
public class StatusCodeBoxingBenchmarks
{
[Benchmark]
public object Get1_FrozenDictionary()
{
return GetBoxedStatusCode_FrozenDictionary(200);
#define METRICS
using System.Diagnostics.Metrics;
using BenchmarkDotNet.Attributes;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks.Sources;
using System.Net;
#if METRICS
@antonfirsov
antonfirsov / ProtocolExceptions.MD
Last active June 9, 2022 16:42
Exposing HTTP/2 and HTTP/3 protocol error details from `SocketsHttpHandler`

Exposing HTTP/2 and HTTP/3 protocol error details from SocketsHttpHandler

This proposal builds on the decisions made in our QUIC Exceptions Design proposal.

Proposed design

  • Define a new exception type ProtocolException, and embed it as HttpRequestException.InnerException
  • Throw ProtocolException directly from HttpResponse content read streams
  • In case of HTTP/3, embed QuicException as ProtocolException.InnerException
@antonfirsov
antonfirsov / GCMemoryInfoMinimalRepro.csproj
Last active July 8, 2021 11:37
GCMemoryInfoMinimalRepro
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>
</Project>
public class _ExhaustTest : IDisposable
{
public const int ListenerCount = 1000;
public const int ConnectCount = 1024 * 20;
//public const int ConnectCount = 10;
private readonly ITestOutputHelper _output;
private Task[] _listenTasks = new Task[ListenerCount];
private Socket[] _listeners = new Socket[ListenerCount];
@antonfirsov
antonfirsov / Type1.txt
Created March 22, 2021 15:34
HTTP Stress failures
2021-03-18T15:01:04.4504783Z client_1 | System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (server:5001)
2021-03-18T15:01:04.4506315Z
2021-03-18T15:01:04.4508672Z client_1 | ---> System.Net.Sockets.SocketException (10060): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
2021-03-18T15:01:04.4509920Z
2021-03-18T15:01:04.4511533Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs:line 1233
2021-03-18T15:01:04.4512995Z
2021-03-18T15:01:04.4514290Z client_1 | at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.
@antonfirsov
antonfirsov / Backend Utility Class.cs
Created March 18, 2021 14:51
ImageSharp-1577-Repro
public static void TransformImage(ImageEditModel imageEdit, MemoryStream destinationStream)
{
if (destinationStream == null)
{
throw new ArgumentNullException(nameof(destinationStream));
}
var sourceImage = Image.Load(imageEdit.SourceStream);
var blur = imageEdit.History.Where(h => h.Tool == ImageTool.Blur).FirstOrDefault();