// // Copyright 2018, OpenTelemetry 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 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // using System; using OpenTelemetry.Collector.AspNetCore.Implementation; using OpenTelemetry.Trace; namespace OpenTelemetry.Collector.AspNetCore { /// /// Requests collector. /// public class AspNetCoreCollector : IDisposable { private readonly DiagnosticSourceSubscriber diagnosticSourceSubscriber; /// /// Initializes a new instance of the class. /// /// Tracer to record traced with. public AspNetCoreCollector(Tracer tracer) : this(tracer, new AspNetCoreCollectorOptions()) { } /// /// Initializes a new instance of the class. /// /// Tracer to record traced with. /// Configuration options for ASP.NET Core collector. public AspNetCoreCollector(Tracer tracer, AspNetCoreCollectorOptions options) { this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber(new HttpInListener("Microsoft.AspNetCore", tracer, options), null); this.diagnosticSourceSubscriber.Subscribe(); } /// public void Dispose() { this.diagnosticSourceSubscriber?.Dispose(); } } }