Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
</AssemblyAttribute>
</ItemGroup>

<!-- Not supported due to extensive use of reflection https://github.com/grafana/grafana-opentelemetry-dotnet/issues/97 -->
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<IsAotCompatible>false</IsAotCompatible>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.AWS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSLambdaInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.AWSLambda;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AspNetCoreInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.AspNetCore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AspNetInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.AspNet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class CassandraInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.Cassandra;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class ElasticsearchClientInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.ElasticsearchClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class EntityFrameworkCoreInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.EntityFrameworkCore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class HangfireInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.Hangfire;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class MySqlDataInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.MySqlData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
#endif
internal sealed class OwinInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.Owin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class QuartzInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.Quartz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class StackExchangeRedisInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.StackExchangeRedis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This instrumentation uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class WcfInitializer : InstrumentationInitializer
{
public override Instrumentation Id { get; } = Instrumentation.Wcf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static class MeterProviderBuilderExtensions
/// <param name="builder">A <see cref="MeterProviderBuilder"/></param>
/// <param name="configure">A callback for customizing default Grafana OpenTelemetry settings</param>
/// <returns>A modified <see cref="MeterProviderBuilder"/> </returns>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Grafana OpenTelemetry distribution for .NET does not support native AoT.")]
#endif
public static MeterProviderBuilder UseGrafana(this MeterProviderBuilder builder, Action<GrafanaOpenTelemetrySettings> configure = default)
{
GrafanaOpenTelemetrySettings settings = new GrafanaOpenTelemetrySettings();
Expand Down Expand Up @@ -66,6 +69,9 @@ internal static MeterProviderBuilder AddInstrumentations(this MeterProviderBuild
return builder;
}

#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This functionality uses reflection to discover and instantiate resource detectors, which is not compatible with native AoT compilation."

This would match the pattern used in the public API methods and provide clearer context.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This functionality uses reflection to discover and instantiate resource detectors, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal static MeterProviderBuilder AddResourceDetectors(this MeterProviderBuilder builder, HashSet<ResourceDetector> resourceDetectors)
{
if (resourceDetectors == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSEBSDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AWSEBS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSEC2DetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AWSEC2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSECSDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AWSECS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AWSEKSDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AWSEKS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AzureAppServiceDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AzureAppService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
#endif
internal sealed class AzureContainerAppsDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AzureContainerApps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class AzureVMDetectorInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.AzureVM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
#endif
internal sealed class ContainerResourceInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.Container;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class HostResourceInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.Host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class OperatingSystemResourceInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.OperatingSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
#endif
internal sealed class ProcessResourceInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.Process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation."

This would provide clearer context about the limitation.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This resource detector uses reflection for type discovery, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal sealed class ProcessRuntimeResourceInitializer : ResourceDetectorInitializer
{
public override ResourceDetector Id { get; } = ResourceDetector.ProcessRuntime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace Grafana.OpenTelemetry
{
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
#endif
internal abstract class ResourceDetectorInitializer
{
public static readonly ResourceDetectorInitializer[] Initializers =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public static class TracerProviderBuilderExtensions
/// <param name="builder">A <see cref="TracerProviderBuilder"/></param>
/// <param name="configure">A callback for customizing default Grafana OpenTelemetry settings</param>
/// <returns>A modified <see cref="TracerProviderBuilder"/> </returns>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Grafana OpenTelemetry distribution for .NET does not support native AoT.")]
#endif
public static TracerProviderBuilder UseGrafana(this TracerProviderBuilder builder, Action<GrafanaOpenTelemetrySettings> configure = default)
{
GrafanaOpenTelemetrySettings settings = new GrafanaOpenTelemetrySettings();
Expand Down Expand Up @@ -66,6 +69,9 @@ internal static TracerProviderBuilder AddInstrumentations(this TracerProviderBui
return builder;
}

#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message "Types might be removed" is vague and doesn't provide actionable information to developers. Consider using a more descriptive message that explains why this code is incompatible with native AoT.

For example: "This functionality uses reflection to discover and instantiate resource detectors, which is not compatible with native AoT compilation."

This would match the pattern used in the public API methods and provide clearer context.

Suggested change
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Types might be removed")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("This functionality uses reflection to discover and instantiate resource detectors, which is not compatible with native AoT compilation.")]

Copilot uses AI. Check for mistakes.
#endif
internal static TracerProviderBuilder AddResourceDetectors(this TracerProviderBuilder builder, HashSet<ResourceDetector> resourceDetectors)
{
if (resourceDetectors == null)
Expand Down
3 changes: 3 additions & 0 deletions src/Grafana.OpenTelemetry/OpenTelemetryBuilderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static class OpenTelemetryBuilderExtension
/// <param name="builder">A <see cref="IOpenTelemetryBuilder"/></param>
/// <param name="configure">A callback for customizing default Grafana OpenTelemetry settings</param>
/// <returns>A modified <see cref="IOpenTelemetryBuilder"/> </returns>
#if NET8_0_OR_GREATER
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Grafana OpenTelemetry distribution for .NET does not support native AoT.")]
#endif
public static IOpenTelemetryBuilder UseGrafana(this IOpenTelemetryBuilder builder, Action<GrafanaOpenTelemetrySettings> configure = default)
{
return builder
Expand Down
Loading