0

I am trying to implement new metrics in my ASP.NET Core MVC application using .NET 8 and new OpenTelemetry (1.6.0-rc.1).

All works fine except 1 problem - for some reason my application expose only metrics from HomeController, and no metrics from my other controllers.

There is how I've set things up:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry()
  .WithMetrics(builder =>
  {
      builder.AddPrometheusExporter();
      builder.AddAspNetCoreInstrumentation();
      builder.AddPrometheusHttpListener();

      builder.AddMeter("Microsoft.AspNetCore.Hosting",
             "Microsoft.AspNetCore.Server.Kestrel");

      builder.AddView("http-server-request-duration",
        new ExplicitBucketHistogramConfiguration
        {
          Boundaries = new double[] { 0, 0.005, 0.01, 0.025, 0.05,
               0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 }
        });
  });

Home controller:

public class HomeController : Controller
{
    [HttpGet]
    public IActionResult Index()
    {
        return View();
    }
}

Settings controller:

[Authorize]
public class SettingsController : Controller
{
    private readonly IUsersService _accountsService;

    public SettingsController(IUsersService accountsService)
    {
        _accountsService = accountsService;
    }

    public IActionResult Index()
    {
        return View();
    }
}

Part of my metrics

I cant really understand the reason of this problem and hope someone could help me..

Ive tried exactly the same as https://www.youtube.com/watch?v=A2pKhNQoQUU

markalex
  • 8,623
  • 2
  • 7
  • 32
Nikita
  • 1
  • 1
  • @markalex yes, i am expecting to see http requests to all controllers in my app, but when i open (in example) localhost/Settings, this request is not included in metrics – Nikita Aug 27 '23 at 16:58
  • Then scraping is unrelated, and thus configuration of it shouldn't be a part of question: removed it. Also, replace your screenshots of code with actual code: [screenshots are discouraged](https://meta.stackoverflow.com/questions/285551) – markalex Aug 27 '23 at 17:08
  • Or better yet: provide [MCVE], so anybody who wants to help can take your code, compile it, and see what is wrong and how to help. – markalex Aug 27 '23 at 17:10
  • Also, small tangent unrelated to your problem (whatever this problem is): since you configured your containers to be in the same network, you don't need `host.docker.internal`: you can simply put `mppilot.app:5001` into targets. [more here](https://stackoverflow.com/a/40137914/21363224) – markalex Aug 27 '23 at 17:12
  • oh, thanks for the tips! – Nikita Aug 27 '23 at 17:23

0 Answers0