Skip to content

GenevaExporter uses Expression.Lambda from System.Linq.Expressions - AOT size and performance concerns #1814

@eerhardt

Description

@eerhardt

When using the GenevaExporter in a native AOT application, it is bringing in System.Linq.Expressions, which adds size to the app, but also any Linq.Expressions are interpreted at runtime (since IL can't be generated).

See the following:

          @eerhardt GenevaExporter also uses `Expression.Lambda` from [System.Linq.Expressions](https://learn.microsoft.com/en-us/dotnet/api/system.linq.expressions?view=net-8.0). Did we not have a Trim/AOT issue when using that?

static ReentrantExportProcessor()
{
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
var ctor = typeof(Batch<T>).GetConstructor(flags, null, new Type[] { typeof(T) }, null);
var value = Expression.Parameter(typeof(T), null);
var lambda = Expression.Lambda<Func<T, Batch<T>>>(Expression.New(ctor, value), value);
CreateBatch = lambda.Compile();
}

Originally posted by @utpilla in #1666 (comment)

We should decide how to fix this. Options I see are:

  1. Make Batch<T>(T item) ctor public, and GenevaExporter can just call it.
  2. Use Reflection directly when RuntimeFeature.IsDynamicCodeCompiled is false.
  3. Address this comment in the code and make this class go away:

// This export processor exports without synchronization.
// Once OpenTelemetry .NET officially support this,
// we can get rid of this class.
// This is currently only used in ETW export, where we know
// that the underlying system is safe under concurrent calls.
internal class ReentrantExportProcessor<T> : BaseExportProcessor<T>

cc @utpilla @CodeBlanch

Metadata

Metadata

Assignees

Labels

comp:exporter.genevaThings related to OpenTelemetry.Exporter.GenevaenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions