// Need to support adding multiple callbacks to support adding metrics from multiple places:
// 1. Creating HttpRequestMessage
// 2. During HTTP request pipeline in delegating handlers
// 3. In diaganostic event callbacks
public static class HttpOptionsExtensions
{
public static void AddCustomMetricsTagsCallback(
This file contains 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
using System.Diagnostics; | |
using System.Net; | |
var stopwatch = Stopwatch.StartNew(); | |
var endCallback = () => Console.WriteLine($"{stopwatch.ElapsedTicks} - Response ended"); | |
var httpClient = new HttpMessageInvoker(new DetectEndRequestHandler(new SocketsHttpHandler(), endCallback)); | |
Console.WriteLine($"{stopwatch.ElapsedTicks} - Send request"); | |
var response = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, "https://www.google.com"), CancellationToken.None); | |
Console.WriteLine($"{stopwatch.ElapsedTicks} - Response headers received"); |
This file contains 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
BenchmarkDotNet=v0.11.4, OS=Windows 10.0.18363 | |
AMD Ryzen 7 1700, 1 CPU, 16 logical and 8 physical cores | |
.NET Core SDK=3.1.400-preview-015151 | |
[Host] : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), 64bit RyuJIT | |
DefaultJob : .NET Core 2.1.17 (CoreCLR 4.6.28619.01, CoreFX 4.6.28619.01), 64bit RyuJIT | |
Before: | |
| Method | messageCount | Mean | Error | StdDev | Gen 0/1k Op | Gen 1/1k Op | Gen 2/1k Op | Allocated Memory/Op | | |
|--------------------------------------------------------------------- |------------- |--------------:|--------------:|--------------:|------------:|------------:|------------:|--------------------:| |
This file contains 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
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Jobs; | |
using BenchmarkDotNet.Running; | |
using System; | |
using System.Numerics; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
static class Program |
This file contains 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
#region Copyright notice and license | |
// Copyright 2019 The gRPC Authors | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Routing; | |
namespace MvcSandbox | |
{ |
This file contains 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
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks> | |
</PropertyGroup> | |
</Project> |
This file contains 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
[2018-05-21T23:17:57] [TestLifetime] [Information] Starting test "CanCloseStreamMethodEarly_json_ServerSentEvents_default" | |
[0.000s] [ServerLogScope] [Information] Server log scope started. | |
[0.000s] [Microsoft.AspNetCore.SignalR.Client.HubConnection] [Verbose] Waiting on Connection Lock in "StartAsyncCore" ("/_/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs":239). | |
[0.000s] [Microsoft.AspNetCore.SignalR.Client.HubConnection] [Debug] Starting HubConnection. | |
[0.001s] [Microsoft.AspNetCore.Http.Connections.Client.HttpConnection] [Debug] Starting HttpConnection. | |
[0.001s] [Microsoft.AspNetCore.Http.Connections.Client.HttpConnection] [Debug] Establishing connection with server at 'http://127.0.0.1:1903/default'. | |
[0.002s] [Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler] [Verbose] Sending HTTP request "POST" 'http://127.0.0.1:1903/default/negotiate'. | |
[0.004s] [SERVER Microsoft.AspNetCore.Server.Kestrel] [Debug] Connection id "0HLDVE3S42R5H" started. | |
[0.004s] [SERVER Micro |
This file contains 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
$ErrorActionPreference = "Stop" | |
$NewtonsoftJsonPath = Resolve-Path -Path "bin\Newtonsoft.Json.dll" | |
$NewtonsoftJsonSchemaPath = Resolve-Path -Path "bin\Newtonsoft.Json.Schema.dll" | |
Add-Type -Path $NewtonsoftJsonPath | |
Add-Type -Path $NewtonsoftJsonSchemaPath | |
$source = @' | |
public class Validator |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
namespace ConsoleApp1 | |
{ |
NewerOlder