最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to Integrate Detailed Logging and Tracing for GraphQL in .NETC# with Dynatrace? - Stack Overflow

programmeradmin0浏览0评论

I am using a .NET/C# implementation for GraphQL and I want to capture all logging and tracing information on Dynatrace. When a query or mutation fails, I understand that the response still returns a 200 OK status with a failure message. However, I would like to have these insights reflected in Dynatrace, specifically with the red error indicators, on the main requests even if the request has 200 response but a query or mutation throws GraphQL Exception so I can easily identify a request failed just by looking into it.

I am looking to explore ways to gain more detailed information on any failures in the GraphQL main service using Dynatrace. Here is my current setup: Packages Installed :

OpenTelemetry.Exporter.OpenTelemetryProtocol,

OpenTelemetry.Extensions.Hosting,

OpenTelemetry.Instrumentation.AspNetCore,

OpenTelemetry.Instrumentation.Http

Program.cs

builder
    .Services
    .AddOpenTelemetry()
    .WithTracing(tracingBuilder =>
    {
        tracingBuilder
            .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("SomeService"))
            .AddAspNetCoreInstrumentation()
            .AddHttpClientInstrumentation()
            .AddHotChocolateInstrumentation();
    });

GraphQL Configuration

.AddInstrumentation(x =>
{
    x.Scopes = HotChocolate.Diagnostics.ActivityScopes.All;
    x.IncludeDocument = true;
    x.IncludeDataLoaderKeys = true;
});

I am using a .NET/C# implementation for GraphQL and I want to capture all logging and tracing information on Dynatrace. When a query or mutation fails, I understand that the response still returns a 200 OK status with a failure message. However, I would like to have these insights reflected in Dynatrace, specifically with the red error indicators, on the main requests even if the request has 200 response but a query or mutation throws GraphQL Exception so I can easily identify a request failed just by looking into it.

I am looking to explore ways to gain more detailed information on any failures in the GraphQL main service using Dynatrace. Here is my current setup: Packages Installed :

OpenTelemetry.Exporter.OpenTelemetryProtocol,

OpenTelemetry.Extensions.Hosting,

OpenTelemetry.Instrumentation.AspNetCore,

OpenTelemetry.Instrumentation.Http

Program.cs

builder
    .Services
    .AddOpenTelemetry()
    .WithTracing(tracingBuilder =>
    {
        tracingBuilder
            .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("SomeService"))
            .AddAspNetCoreInstrumentation()
            .AddHttpClientInstrumentation()
            .AddHotChocolateInstrumentation();
    });

GraphQL Configuration

.AddInstrumentation(x =>
{
    x.Scopes = HotChocolate.Diagnostics.ActivityScopes.All;
    x.IncludeDocument = true;
    x.IncludeDataLoaderKeys = true;
});
Share Improve this question edited Mar 12 at 23:28 wax asked Mar 12 at 23:11 waxwax 856 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use the OneAgent SDK to mark traces as failed and provide error information.

Or if you don't want to change your code, you could use Failure detection rules with request attributes to mark them as failed.

发布评论

评论列表(0)

  1. 暂无评论