opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

All infrastructure for LogRecord is internal

Open jeremy-morren opened this issue 8 months ago • 2 comments

Package

OpenTelemetry

Is your feature request related to a problem?

All infrastructure (pool, constructors) for LogRecord is internal. This makes it impossible without reflection to create any kind of logging infrastructure that emits LogRecord.

What is the expected behavior?

At minimum, make LogRecord constructor public. https://github.com/open-telemetry/opentelemetry-dotnet/blob/a8f1076e4d3703c20bb3e0267d454caf5c305cb7/src/OpenTelemetry/Logs/LogRecord.cs#L32

Create public property for ScopeProvider, which cannot be set at all right now.

public IExternalScopeProvider? ScopeProvider
{
    get => this.ILoggerData.ScopeProvider;
    set => this.ILoggerData.ScopeProvider = value;
}

Which alternative solutions or features have you considered?

Make an implementation of ILogRecordPool public so that Rent() and Return methods can be used.

jeremy-morren avatar Mar 14 '25 00:03 jeremy-morren

Hi @jeremy-morren, I'm trying to understand this issue. Can you please share more details about your workflow, what you're trying to accomplish?

I don't have full context on the LogRecord implementation, but my understanding is that users would interact with the ILogger APIs. We're not likely to make the full implementation public, but if there's a specific scenario that you can't accomplish that would help us scope to what's needed.

TimothyMothra avatar Mar 18 '25 17:03 TimothyMothra

The problem with it being internal is that you have quite a few show stopper bugs and making everything internal means you're forcing everyone to either compile their own version or use horrible reflection hacks. It also prevents anyone from fully implementing their own LogRecord pool or Exporter or ExportProcessor. Making it public doesn't mean its "part of the API" not sure why you think that. You even have comments in your code about people accessing the LogRecord constructor with reflection so try not to change it. You simply state the official supported use is through the ILogger API and changes to underlying object can occur. Many (I dare say most) projects work that way.

MarcCain-Scott avatar Apr 07 '25 08:04 MarcCain-Scott