From e664b4f14fa10009c99a8167d2decc48fe84e6d9 Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Fri, 24 Nov 2023 22:38:58 +0000 Subject: [PATCH 1/4] Fix namespace typo and update dependencies --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 7 +- .vscode/launch.json | 2 +- Controllers/HeroController.cs | 82 +++++++------------ Models/Hero.cs | 2 +- Models/HeroContext.cs | 1 - Program.cs | 47 +++++------ Startup.cs | 70 ---------------- appsettings.Development.json | 9 +- appsettings.json | 10 +-- client.http | 16 ++-- interfaces/IHeroRepository.cs | 39 +++++++++ repositories/HeroRepository.cs | 31 +++++++ tour-of-heroes-api.csproj | 18 ++-- ...s-api.sln => tour-of-heroes-dotnet-api.sln | 50 +++++------ 15 files changed, 180 insertions(+), 206 deletions(-) delete mode 100644 Startup.cs create mode 100644 interfaces/IHeroRepository.cs create mode 100644 repositories/HeroRepository.cs rename tour-of-heroes-api.sln => tour-of-heroes-dotnet-api.sln (52%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7b9f7ad..1d820c2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0 +FROM mcr.microsoft.com/devcontainers/dotnet:8.0 # Install SQL Tools: SQLPackage and sqlcmd COPY mssql/installSQLtools.sh installSQLtools.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index df94f27..31a9d25 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,7 +24,8 @@ "password": "P@ssword", "emptyPasswordInput": false, "savePassword": false, - "profileName": "mssql-container" + "profileName": "mssql-container", + "trustServerCertificate": true } ] }, @@ -36,7 +37,9 @@ "humao.rest-client", "hashicorp.terraform", "ms-azuretools.vscode-docker", - "redhat.vscode-yaml" + "redhat.vscode-yaml", + "GitHub.copilot", + "GitHub.copilot-chat" ] } }, diff --git a/.vscode/launch.json b/.vscode/launch.json index d21f4ac..6544aba 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/bin/Debug/net7.0/tour-of-heroes-api.dll", + "program": "${workspaceFolder}/bin/Debug/net8.0/tour-of-heroes-api.dll", "args": [], "cwd": "${workspaceFolder}", "stopAtEntry": false, diff --git a/Controllers/HeroController.cs b/Controllers/HeroController.cs index f9c3002..4e5c034 100644 --- a/Controllers/HeroController.cs +++ b/Controllers/HeroController.cs @@ -1,11 +1,8 @@ using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; using tour_of_heroes_api.Models; -using tour_of_heroes_api.Modesl; +using System.Linq; namespace tour_of_heroes_api.Controllers { @@ -13,98 +10,77 @@ namespace tour_of_heroes_api.Controllers [ApiController] public class HeroController : ControllerBase { - private readonly HeroContext _context; - public HeroController(HeroContext context) + private IHeroRepository _heroRepository; + public HeroController(IHeroRepository heroRepository) { - _context = context; + _heroRepository = heroRepository; } // GET: api/Hero [HttpGet] - public async Task>> GetHeroes() + public ActionResult> GetHeroes() { - // Just for demo purposes 🤓 - var hash = MD5.Create(); - - return await _context.Heroes.ToListAsync(); + var heroes = _heroRepository.GetAll(); + return Ok(heroes); } // GET: api/Hero/5 - [HttpGet("{id}")] - public async Task> GetHero(int id) + [HttpGet("{id}")] + public ActionResult GetHero(int id) { - var hero = await _context.Heroes.FindAsync(id); + var hero = _heroRepository.GetById(id); if (hero == null) { return NotFound(); } - return hero; + return Ok(hero); } // PUT: api/Hero/5 // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPut("{id}")] - public async Task PutHero(int id, Hero hero) + public ActionResult PutHero(int id, Hero hero) { - if (id != hero.Id) - { - return BadRequest(); - } - _context.Entry(hero).State = EntityState.Modified; + var heroToUpdate = _heroRepository.GetById(id); - try + if (heroToUpdate == null) { - await _context.SaveChangesAsync(); - } - catch (DbUpdateConcurrencyException) - { - if (!HeroExists(id)) - { - return NotFound(); - } - else - { - throw; - } + return NotFound(); } + heroToUpdate.Name = hero.Name; + heroToUpdate.AlterEgo = hero.AlterEgo; + heroToUpdate.Description = hero.Description; + + _heroRepository.Update(heroToUpdate); + return NoContent(); + } // POST: api/Hero // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754 [HttpPost] - public async Task> PostHero(Hero hero) + public ActionResult PostHero(Hero hero) { - _context.Heroes.Add(hero); - await _context.SaveChangesAsync(); - return CreatedAtAction(nameof(GetHero), new { id = hero.Id }, hero); + _heroRepository.Add(hero); + + return Ok(hero); + } // DELETE: api/Hero/5 [HttpDelete("{id}")] - public async Task DeleteHero(int id) + public IActionResult DeleteHero(int id) { - var hero = await _context.Heroes.FindAsync(id); - if (hero == null) - { - return NotFound(); - } - - _context.Heroes.Remove(hero); - await _context.SaveChangesAsync(); + _heroRepository.Delete(id); return NoContent(); } - - private bool HeroExists(int id) - { - return _context.Heroes.Any(e => e.Id == id); - } } } diff --git a/Models/Hero.cs b/Models/Hero.cs index 8dba03c..8dc6151 100644 --- a/Models/Hero.cs +++ b/Models/Hero.cs @@ -1,4 +1,4 @@ -namespace tour_of_heroes_api.Modesl +namespace tour_of_heroes_api.Models { public class Hero { diff --git a/Models/HeroContext.cs b/Models/HeroContext.cs index a1fe9a6..b46c97d 100644 --- a/Models/HeroContext.cs +++ b/Models/HeroContext.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using tour_of_heroes_api.Modesl; namespace tour_of_heroes_api.Models { diff --git a/Program.cs b/Program.cs index eba7b0d..2ed78e0 100644 --- a/Program.cs +++ b/Program.cs @@ -1,26 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.DependencyInjection; +using tour_of_heroes_api.Models; -namespace tour_of_heroes_api +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddScoped(); +builder.Services.AddControllers();builder.Services.AddDbContext(opt => opt.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))); +builder.Services.AddSwaggerGen(c => { - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} + c.SwaggerDoc("v1", new() { Title = "tour_of_heroes_api", Version = "v1" }); +}); + +var app = builder.Build(); + +app.UseCors("CorsPolicy"); + +app.UseSwagger(); +app.UseSwaggerUI(); + +app.MapControllers(); + +app.Run(); + diff --git a/Startup.cs b/Startup.cs deleted file mode 100644 index e69a358..0000000 --- a/Startup.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.OpenApi.Models; -using tour_of_heroes_api.Models; -using Microsoft.EntityFrameworkCore; - -namespace tour_of_heroes_api -{ - public class Startup - { - readonly string CorsPolicy = "CorsPolicy"; - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public IConfiguration Configuration { get; } - - // This method gets called by the runtime. Use this method to add services to the container. - public void ConfigureServices(IServiceCollection services) - { - - services.AddCors(options => - { - options.AddPolicy(CorsPolicy, - builder => builder.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader()); - }); - - services.AddControllers() - .AddXmlSerializerFormatters(); // add XML support - - // services.AddDbContext(opt => opt.UseInMemoryDatabase("Heroes")); - services.AddDbContext(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); - - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "tour_of_heroes_api", Version = "v1" }); - }); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - // if (env.IsDevelopment()) - // { - app.UseDeveloperExceptionPage(); - app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "tour_of_heroes_api v1")); - // } - - // app.UseHttpsRedirection(); - - app.UseRouting(); - - app.UseCors(CorsPolicy); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/appsettings.Development.json b/appsettings.Development.json index 9169fcf..875c737 100644 --- a/appsettings.Development.json +++ b/appsettings.Development.json @@ -9,12 +9,5 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://+:5000" - } - } - } + "AllowedHosts": "*" } diff --git a/appsettings.json b/appsettings.json index c1cef48..bae1978 100644 --- a/appsettings.json +++ b/appsettings.json @@ -9,12 +9,6 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*", - "Kestrel": { - "Endpoints": { - "Http": { - "Url": "http://+:5000" - } - } - } + "AllowedHosts": "*" + } diff --git a/client.http b/client.http index 1154290..93dd256 100644 --- a/client.http +++ b/client.http @@ -1,7 +1,7 @@ -GET http://localhost:5000/api/hero HTTP/1.1 +GET http://localhost:5010/api/hero HTTP/1.1 ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -11,7 +11,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -21,7 +21,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -31,7 +31,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -41,7 +41,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -51,7 +51,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { @@ -61,7 +61,7 @@ content-type: application/json } ### -POST http://localhost:5000/api/hero HTTP/1.1 +POST http://localhost:5010/api/hero HTTP/1.1 content-type: application/json { diff --git a/interfaces/IHeroRepository.cs b/interfaces/IHeroRepository.cs new file mode 100644 index 0000000..63b8c8c --- /dev/null +++ b/interfaces/IHeroRepository.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using tour_of_heroes_api.Models; + +/// +/// Represents a repository for managing heroes. +/// +public interface IHeroRepository +{ + /// + /// Retrieves all heroes. + /// + /// An enumerable collection of heroes. + IEnumerable GetAll(); + + /// + /// Retrieves a hero by its ID. + /// + /// The ID of the hero. + /// The hero with the specified ID. + Hero GetById(int id); + + /// + /// Adds a new hero. + /// + /// The hero to add. + void Add(Hero hero); + + /// + /// Updates an existing hero. + /// + /// The hero to update. + void Update(Hero hero); + + /// + /// Deletes a hero by its ID. + /// + /// The ID of the hero to delete. + void Delete(int id); +} \ No newline at end of file diff --git a/repositories/HeroRepository.cs b/repositories/HeroRepository.cs new file mode 100644 index 0000000..6679af8 --- /dev/null +++ b/repositories/HeroRepository.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using tour_of_heroes_api.Models; +using System.Linq; + +public class HeroRepository : IHeroRepository +{ + private readonly HeroContext _context; + public HeroRepository(HeroContext context) => _context = context; + + public IEnumerable GetAll() => _context.Heroes.ToList(); + + public Hero GetById(int id) => _context.Heroes.FirstOrDefault(h => h.Id == id); + + public void Add(Hero hero) + { + _context.Heroes.Add(hero); + _context.SaveChanges(); + } + + public void Delete(int id) + { + _context.Heroes.Remove(GetById(id)); + _context.SaveChanges(); + } + + public void Update(Hero hero) + { + _context.Heroes.Update(hero); + _context.SaveChanges(); + } +} \ No newline at end of file diff --git a/tour-of-heroes-api.csproj b/tour-of-heroes-api.csproj index b3c503b..4e48165 100644 --- a/tour-of-heroes-api.csproj +++ b/tour-of-heroes-api.csproj @@ -1,19 +1,27 @@ - net7.0 + net8.0 + enable + enable tour_of_heroes_api - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + + + + + + + - + diff --git a/tour-of-heroes-api.sln b/tour-of-heroes-dotnet-api.sln similarity index 52% rename from tour-of-heroes-api.sln rename to tour-of-heroes-dotnet-api.sln index 95f4ab8..caf92f3 100644 --- a/tour-of-heroes-api.sln +++ b/tour-of-heroes-dotnet-api.sln @@ -1,25 +1,25 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.810.16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tour-of-heroes-api", "tour-of-heroes-api.csproj", "{227082F8-CBF8-499A-817C-9F395CC0D360}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {227082F8-CBF8-499A-817C-9F395CC0D360}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {227082F8-CBF8-499A-817C-9F395CC0D360}.Debug|Any CPU.Build.0 = Debug|Any CPU - {227082F8-CBF8-499A-817C-9F395CC0D360}.Release|Any CPU.ActiveCfg = Release|Any CPU - {227082F8-CBF8-499A-817C-9F395CC0D360}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AA4AA499-93BE-438D-9EAC-9735FF64C131} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "tour-of-heroes-api", "tour-of-heroes-api.csproj", "{119692C5-9A44-4B95-8261-A83E4CF6C7A3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {119692C5-9A44-4B95-8261-A83E4CF6C7A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {119692C5-9A44-4B95-8261-A83E4CF6C7A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {119692C5-9A44-4B95-8261-A83E4CF6C7A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {119692C5-9A44-4B95-8261-A83E4CF6C7A3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {938373C7-FB29-43F7-B34A-807FC576EA70} + EndGlobalSection +EndGlobal From 896bdba7f6a88c089ef67685208a3ea23859eb3f Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Fri, 24 Nov 2023 22:39:35 +0000 Subject: [PATCH 2/4] Update base image version in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e6f8d5..f424fdb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app EXPOSE 5000 From 2fe9c0f1f5d5db6a5db74df3b5e5ef072d4adc3e Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Sat, 25 Nov 2023 08:00:46 +0000 Subject: [PATCH 3/4] Update dependencies and configure OpenTelemetry for metrics and tracing --- .vscode/launch.json | 3 ++- Dockerfile | 2 +- Program.cs | 52 +++++++++++++++++++++++++++++++++++++++ tour-of-heroes-api.csproj | 10 +++++--- 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6544aba..61174f1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -15,7 +15,8 @@ "stopAtEntry": false, "serverReadyAction": { "action": "openExternally", - "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + "pattern": "\\bNow listening on:\\s+(https?://\\S+)", + "uriFormat": "%s/swagger" }, "env": { "ASPNETCORE_ENVIRONMENT": "Development", diff --git a/Dockerfile b/Dockerfile index f424fdb..16c3a21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ ENV ASPNETCORE_URLS=http://+:5000 RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app USER appuser -FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG TARGETARCH ARG TARGETOS diff --git a/Program.cs b/Program.cs index 2ed78e0..832e812 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using OpenTelemetry.Metrics; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; using tour_of_heroes_api.Models; var builder = WebApplication.CreateBuilder(args); @@ -14,6 +17,52 @@ c.SwaggerDoc("v1", new() { Title = "tour_of_heroes_api", Version = "v1" }); }); +// Open Telemetry configuration +var tracingOtlpEndpoint = builder.Configuration["OTLP_ENDPOINT_URL"]; +var otel = builder.Services.AddOpenTelemetry(); + +// Configure OpenTelemetry Resources with the application name +otel.ConfigureResource(resource => resource + .AddService(serviceName: builder.Environment.ApplicationName)); + +// Add Metrics for ASP.NET Core and our custom metrics and export to Prometheus +otel.WithMetrics(metrics => metrics + // Metrics provider from OpenTelemetry + .AddAspNetCoreInstrumentation() + //.AddMeter(greeterMeter.Name) + // Metrics provides by ASP.NET Core in .NET 8 + .AddMeter("Microsoft.AspNetCore.Hosting") + .AddMeter("Microsoft.AspNetCore.Server.Kestrel") + .AddPrometheusExporter()); + +// Add Tracing for ASP.NET Core and our custom ActivitySource and export to Jaeger +otel.WithTracing(tracing => +{ + tracing.AddAspNetCoreInstrumentation(); + tracing.AddHttpClientInstrumentation(); + //tracing.AddSource(greeterActivitySource.Name); + if (tracingOtlpEndpoint != null) + { + tracing.AddOtlpExporter(otlpOptions => + { + otlpOptions.Endpoint = new Uri(tracingOtlpEndpoint); + }); + } + else + { + tracing.AddConsoleExporter(); + } +}); + +// Add CORS policy +builder.Services.AddCors(options => +{ + options.AddPolicy("CorsPolicy", + builder => builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader()); +}); + var app = builder.Build(); app.UseCors("CorsPolicy"); @@ -23,5 +72,8 @@ app.MapControllers(); +// Configure the Prometheus scraping endpoint +app.MapPrometheusScrapingEndpoint(); + app.Run(); diff --git a/tour-of-heroes-api.csproj b/tour-of-heroes-api.csproj index 4e48165..a572898 100644 --- a/tour-of-heroes-api.csproj +++ b/tour-of-heroes-api.csproj @@ -13,13 +13,17 @@ all - + + + - - + + + + From 6b947c4ffc72972ebfd28d1c2428d5a254eea8e4 Mon Sep 17 00:00:00 2001 From: 0GiS0 Date: Sat, 25 Nov 2023 10:09:11 +0000 Subject: [PATCH 4/4] Add SQL client instrumentation --- Program.cs | 1 + tour-of-heroes-api.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/Program.cs b/Program.cs index 832e812..5029560 100644 --- a/Program.cs +++ b/Program.cs @@ -40,6 +40,7 @@ { tracing.AddAspNetCoreInstrumentation(); tracing.AddHttpClientInstrumentation(); + tracing.AddSqlClientInstrumentation(); //tracing.AddSource(greeterActivitySource.Name); if (tracingOtlpEndpoint != null) { diff --git a/tour-of-heroes-api.csproj b/tour-of-heroes-api.csproj index a572898..a4dc4d4 100644 --- a/tour-of-heroes-api.csproj +++ b/tour-of-heroes-api.csproj @@ -23,6 +23,7 @@ +