Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

## Unreleased

* Throw NotSupportedException when using `ExceptionProcessor` for Tracing in
Mono Runtime and Native AOT environment because the the dependent
`Marshal.GetExceptionPointers()` API is not supported in these platforms.
([#5347](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5347))

* Fixed an issue where `LogRecord.Attributes` (or `LogRecord.StateValues` alias)
could become out of sync with `LogRecord.State` if either is set directly via
the public setters. This was done to further mitigate issues introduced in
1.5.0 causing attributes added using custom processor(s) to be missing after
upgrading. For details see:
[#5169](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5169)
([#5169](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5169))

* Fixed an issue where `SimpleExemplarReservoir` was not resetting internal
state for cumulative temporality.
Expand Down
18 changes: 6 additions & 12 deletions src/OpenTelemetry/Trace/ExceptionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ internal sealed class ExceptionProcessor : BaseProcessor<Activity>
public ExceptionProcessor()
{
#if NET6_0_OR_GREATER || NETFRAMEWORK
Marshal.GetExceptionPointers(); // attempt to access pointers to test for platform support
this.fnGetExceptionPointers = Marshal.GetExceptionPointers;
#else
// When running on netstandard or similar the Marshal class is not a part of the netstandard API
// but it would still most likely be available in the underlying framework, so use reflection to retrieve it.
try
{
var flags = BindingFlags.Static | BindingFlags.Public;
var method = typeof(Marshal).GetMethod("GetExceptionPointers", flags, null, Type.EmptyTypes, null)
?? throw new InvalidOperationException("Marshal.GetExceptionPointers method could not be resolved reflectively.");
var lambda = Expression.Lambda<Func<IntPtr>>(Expression.Call(method));
this.fnGetExceptionPointers = lambda.Compile();
}
catch (Exception ex)
{
throw new NotSupportedException($"'{typeof(Marshal).FullName}.GetExceptionPointers' is not supported", ex);
}
var flags = BindingFlags.Static | BindingFlags.Public;
var method = typeof(Marshal).GetMethod("GetExceptionPointers", flags, null, Type.EmptyTypes, null)
?? throw new InvalidOperationException("Marshal.GetExceptionPointers method could not be resolved reflectively.");
var lambda = Expression.Lambda<Func<IntPtr>>(Expression.Call(method));
this.fnGetExceptionPointers = lambda.Compile();
#endif
}

Expand Down