census-instrumentation / opencensus-csharp

Distributed tracing and stats collecting framework
https://opencensus.io
Apache License 2.0
139 stars 32 forks source link

Prometheus exporter: allow to work via the application's port #65

Closed SergeyKanzhelev closed 5 years ago

SergeyKanzhelev commented 5 years ago

In some environments opening separate port for Prometheus exporter will not work. Especially for sandboxed environments like Azure Web Apps. Re-using app's port and allow Prometheus to work as a middleware will help to enable those environments.

orthros commented 5 years ago

I'm looking at this right now.

When you mention "middleware" are you referring to MVC middleware? e.g.

public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.UsePrometheus(new PrometheusMiddlewareOptions(){ Url = new Uri("/metrics") });

        app.UseMvc();
    }
}

I ask, as I have written a version of this, but I am getting compiler warnings that the classes needed to register as MVC middleware (HttpContext, IApplicationBuilder, etc.) are not Common Language Specification compliant. Is this a strict compliance rule for this set of libraries? Have I mis-understood the requirement, or should I make a separate DLL that does not have the [assembly: System.CLSCompliant(true)] directive?

Thank you!

SergeyKanzhelev commented 5 years ago

just remove this directive. I was trying to use it whenever it can be used as it simplifies some cross-.NET- language scenarios. But it is not strictly required.

Thank you for looking into it!

SergeyKanzhelev commented 5 years ago

Moved to OpenTelemetry