I'm working with OpenTelemetry and trying to encapsulate the logic by internal library which means prevent using OpenTelemetry public API and spread logic between the projects, means there is only one place to do the stuff. I close public usage by <PackageReference Include="OpenTelemetry" Version="1.5.1" PrivateAssets="All" /> everything is fine with regular inheritances which mean I can inherit base logic and provide ability to manipulate it by internal even if it such as marker interface
public class OtlpOptions : OtlpExporterOptions {
}
I think would be great hide the OT api and prowide such as simple common access through the extensions like
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetryTracing().WithOtelExporter().WithConsoleExporter();
builder.Services.AddOpenTelemetryMetrics().WithConsoleExporter();
but the problem that is too many abstraction on it like https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/src/OpenTelemetry.Api/Trace/TracerProviderBuilder.cs and I cannot create marker interface for abstraction class without reference on that abstraction which means encapsulation doesn't work and required particular reference. And I wanna know how to encapsulate the abstraction?
UPD:
It's kind a weird that if I call extension
tpBuilder.WithOtelExporter() it requires reference
other way if I call static method
MyOpenTelemetryExtension.WithOtelExporter(tpBuilder) it is not required reference