You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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, Action
1) + 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, Action
1) + 0x3c2024-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.
The text was updated successfully, but these errors were encountered: