Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not support trimming or native aot in dotnet 8 #97

Open
MartinCarpentier opened this issue May 12, 2024 · 0 comments
Open

Does not support trimming or native aot in dotnet 8 #97

MartinCarpentier opened this issue May 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@MartinCarpentier
Copy link

MartinCarpentier commented May 12, 2024

Bug Report

  • Grafana.OpenTelemetry 0.8.1-beta

  • net8.0 with asp.net

Symptom

When adding UseGrafana on the OpenTelemetry providers on trimmed or native aot compiled applications, the app fails during startup with the following exception.

2024-05-12 17:02:06 Unhandled Exception: System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.
2024-05-12 17:02:06 at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled() + 0x27
2024-05-12 17:02:06 at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() + 0x2e
2024-05-12 17:02:06 at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions, Type) + 0x2d
2024-05-12 17:02:06 at System.Text.Json.JsonSerializer.GetTypeInfoT + 0x2b
2024-05-12 17:02:06 at Grafana.OpenTelemetry.TracerProviderBuilderExtensions.UseGrafana(TracerProviderBuilder, Action1) + 0x98 2024-05-12 17:02:06 at TestService.Program.<>c__DisplayClass1_0.<Main>b__2(TracerProviderBuilder tracing) + 0x58 2024-05-12 17:02:06 at OpenTelemetry.OpenTelemetryBuilderSdkExtensions.WithTracing(IOpenTelemetryBuilder, Action1) + 0x3c
2024-05-12 17:02:06 at TestService.Program.Main(String[] args) + 0x14c
2024-05-12 17:02:06 at TestService!+0xacf63c

What is the expected behavior?

That it works and does not fail

What is the actual behavior?

It fails as shown above.

Reproduce

From program.cs in an asp.net application with dotnet 8

...
builder.Logging.AddOpenTelemetry(options =>
{
options
.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService(serviceName))
.UseGrafana(config =>
{
config.ServiceName = serviceName;
});
});
builder.Services.AddOpenTelemetry()
.ConfigureResource(resource => resource.AddService(serviceName))
.WithTracing(tracing => tracing
.AddAspNetCoreInstrumentation()
.UseGrafana(config =>
{
config.ServiceName = serviceName;
}))
.WithMetrics(metrics => metrics
.AddAspNetCoreInstrumentation()
.AddRuntimeInstrumentation()
.AddProcessInstrumentation()
.UseGrafana(config =>
{
config.ServiceName = serviceName;
}));
...

Additional Context

Add any other context about the problem here.

@MartinCarpentier MartinCarpentier added the bug Something isn't working label May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant