Skip to content

Commit

Permalink
big refactoring (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwe1ss authored Dec 12, 2020
1 parent 50a570c commit 2406193
Show file tree
Hide file tree
Showing 35 changed files with 715 additions and 602 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void GlobalSetup()
.AddOpenTracingCoreServices(builder =>
{
builder.AddBenchmarkTracer(Mode);
builder.AddCoreFx();
builder.AddHttpHandler();
})
.BuildServiceProvider();

Expand Down
12 changes: 11 additions & 1 deletion samples/net5.0/OrdersApi/Controllers/OrdersController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Shared;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using OpenTracing;
using OrdersApi.DataStore;
using Shared;

namespace Samples.OrdersApi.Controllers
{
Expand All @@ -24,6 +26,14 @@ public OrdersController(OrdersDbContext dbContext, HttpClient httpClient, ITrace
_tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
}

[HttpGet]
public async Task<IActionResult> Index()
{
var orders = await _dbContext.Orders.ToListAsync();

return Ok(orders.Select(x => new { x.OrderId }).ToList());
}

[HttpPost]
public async Task<IActionResult> Index([FromBody] PlaceOrderCommand cmd)
{
Expand Down
10 changes: 0 additions & 10 deletions samples/net5.0/OrdersApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public static IHostBuilder CreateHostBuilder(string[] args)
// We don't need any tracing data for our health endpoint.
options.Hosting.IgnorePatterns.Add(ctx => ctx.Request.Path == "/health");
});

builder.ConfigureEntityFrameworkCore(options =>
{
options.IgnorePatterns.Add(cmd => cmd.Command.CommandText == "SELECT 1");
});

builder.ConfigureMicrosoftSqlClient(options =>
{
options.IgnorePatterns.Add(cmd => cmd.CommandText == "SELECT 1");
});
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion samples/net5.0/Shared/JaegerServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Jaeger.Senders.Thrift;
using Microsoft.Extensions.Logging;
using OpenTracing;
using OpenTracing.Contrib.NetCore.CoreFx;
using OpenTracing.Contrib.NetCore.Configuration;
using OpenTracing.Util;

namespace Microsoft.Extensions.DependencyInjection
Expand Down
12 changes: 11 additions & 1 deletion samples/netcoreapp2.1/OrdersApi/Controllers/OrdersController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Shared;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using OpenTracing;
using OrdersApi.DataStore;
using Shared;

namespace Samples.OrdersApi.Controllers
{
Expand All @@ -24,6 +26,14 @@ public OrdersController(OrdersDbContext dbContext, HttpClient httpClient, ITrace
_tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
}

[HttpGet]
public async Task<IActionResult> Index()
{
var orders = await _dbContext.Orders.ToListAsync();

return Ok(orders.Select(x => new { x.OrderId }).ToList());
}

[HttpPost]
public async Task<IActionResult> Index([FromBody] PlaceOrderCommand cmd)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Jaeger.Samplers;
using Microsoft.Extensions.Logging;
using OpenTracing;
using OpenTracing.Contrib.NetCore.CoreFx;
using OpenTracing.Contrib.NetCore.Configuration;
using OpenTracing.Util;

namespace Microsoft.Extensions.DependencyInjection
Expand Down
12 changes: 11 additions & 1 deletion samples/netcoreapp3.1/OrdersApi/Controllers/OrdersController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Shared;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using OpenTracing;
using OrdersApi.DataStore;
using Shared;

namespace Samples.OrdersApi.Controllers
{
Expand All @@ -24,6 +26,14 @@ public OrdersController(OrdersDbContext dbContext, HttpClient httpClient, ITrace
_tracer = tracer ?? throw new ArgumentNullException(nameof(tracer));
}

[HttpGet]
public async Task<IActionResult> Index()
{
var orders = await _dbContext.Orders.ToListAsync();

return Ok(orders.Select(x => new { x.OrderId }).ToList());
}

[HttpPost]
public async Task<IActionResult> Index([FromBody] PlaceOrderCommand cmd)
{
Expand Down
10 changes: 0 additions & 10 deletions samples/netcoreapp3.1/OrdersApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ public static IHostBuilder CreateHostBuilder(string[] args)
// We don't need any tracing data for our health endpoint.
options.Hosting.IgnorePatterns.Add(ctx => ctx.Request.Path == "/health");
});

builder.ConfigureEntityFrameworkCore(options =>
{
options.IgnorePatterns.Add(cmd => cmd.Command.CommandText == "SELECT 1");
});

builder.ConfigureMicrosoftSqlClient(options =>
{
options.IgnorePatterns.Add(cmd => cmd.CommandText == "SELECT 1");
});
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Jaeger.Senders.Thrift;
using Microsoft.Extensions.Logging;
using OpenTracing;
using OpenTracing.Contrib.NetCore.CoreFx;
using OpenTracing.Contrib.NetCore.Configuration;
using OpenTracing.Util;

namespace Microsoft.Extensions.DependencyInjection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,37 @@

namespace OpenTracing.Contrib.NetCore.Configuration
{
public class AspNetCoreDiagnosticOptions
public class AspNetCoreDiagnosticOptions : DiagnosticOptions
{
public HostingOptions Hosting { get; } = new HostingOptions();

public AspNetCoreDiagnosticOptions()
{
// We create separate spans for MVC actions & results so we don't need these additional events by default.
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeActionMethod");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeControllerActionMethod");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterControllerActionMethod");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterActionMethod");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnActionExecution");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnActionExecution");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting");

IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext");
IgnoredEvents.Add("Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext");
}
}
}
Loading

0 comments on commit 2406193

Please sign in to comment.