From 4b81f0dd9afe3eb44b902e8bc861f0f5f56704ba Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 09:08:46 +0000 Subject: [PATCH 01/37] wip: Align with OTEL spec --- .../src/Diagnostics/ActivityEnricher.cs | 195 ++++++++---- .../ActivityDataLoaderDiagnosticListener.cs | 4 +- .../src/Diagnostics/SemanticConventions.cs | 124 ++++++++ ...onTests.Allow_document_to_be_captured.snap | 38 ++- ...r_error_that_deletes_the_whole_result.snap | 38 ++- ...or_that_deletes_the_whole_result_deep.snap | 12 +- ...e_operation_display_name_with_1_field.snap | 34 ++- ...tion_display_name_with_1_field_and_op.snap | 38 ++- ...e_operation_display_name_with_3_field.snap | 46 ++- ...e_operation_display_name_with_4_field.snap | 52 +++- ...peration_name_is_used_as_request_name.snap | 38 ++- ...lidation_activity_has_an_error_status.snap | 14 +- ...ntationTests.Track_data_loader_events.snap | 111 ------- ...ts.Track_data_loader_events_with_keys.snap | 111 ------- ...rack_events_of_a_simple_query_default.snap | 12 +- ...ack_events_of_a_simple_query_detailed.snap | 34 ++- ...umentationTests.Http_Get_SDL_download.snap | 2 +- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 26 +- ...s.Http_Post_SingleRequest_GetHeroName.snap | 26 +- ...ost_SingleRequest_GetHeroName_Default.snap | 14 +- ....Http_Post_add_query_to_http_activity.snap | 38 ++- ...p_Post_add_variables_to_http_activity.snap | 38 ++- ...s.Http_Post_capture_deferred_response.snap | 32 +- ...t_ensure_list_path_is_correctly_built.snap | 50 +++- ...mentationTests.Http_Post_parser_error.snap | 2 +- ...not_automatically_added_to_activities.snap | 38 ++- ...onTests.Http_Post_with_extensions_map.snap | 38 ++- ...g_error_when_rename_root_is_activated.snap | 2 +- ...n_error_when_rename_root_is_activated.snap | 4 +- .../FusionActivityEnricher.cs | 282 ++++++++++++++---- .../Fusion.Diagnostics/SemanticConventions.cs | 114 +++++++ .../v16/migrating/migrate-from-15-to-16.md | 21 ++ 32 files changed, 1226 insertions(+), 402 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events_with_keys.snap create mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 41b16cac147..3c6c7f8e672 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -72,7 +72,7 @@ public virtual void EnrichExecuteHttpRequest( UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } - activity.SetTag("graphql.http.kind", kind); + activity.SetTag(GraphQL.Http.Kind, kind); var isDefault = false; if (!(context.Items.TryGetValue(SchemaName, out var value) @@ -82,8 +82,9 @@ public virtual void EnrichExecuteHttpRequest( isDefault = true; } - activity.SetTag("graphql.schema.name", schemaName); - activity.SetTag("graphql.schema.isDefault", isDefault); + // TODO: Is this needed? + activity.SetTag(GraphQL.Schema.Name, schemaName); + activity.SetTag(GraphQL.Schema.IsDefault, isDefault); } public virtual void EnrichSingleRequest( @@ -91,18 +92,18 @@ public virtual void EnrichSingleRequest( GraphQLRequest request, Activity activity) { - activity.SetTag("graphql.http.request.type", "single"); + activity.SetTag(GraphQL.Http.Request.Type, "single"); if (request.DocumentId is not null && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - activity.SetTag("graphql.http.request.query.id", request.DocumentId.Value); + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - activity.SetTag("graphql.http.request.query.hash", request.DocumentHash.Value); + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null @@ -114,13 +115,13 @@ public virtual void EnrichSingleRequest( _queryCache.Add(request.Document, query); } - activity.SetTag("graphql.http.request.query.body", query); + activity.SetTag(GraphQL.Http.Request.QueryBody, query); } if (request.OperationName is not null && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { - activity.SetTag("graphql.http.request.operation", request.OperationName); + activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); } if (request.Variables is not null @@ -141,7 +142,7 @@ public virtual void EnrichBatchRequest( IReadOnlyList batch, Activity activity) { - activity.SetTag("graphql.http.request.type", "batch"); + activity.SetTag(GraphQL.Http.Request.Type, "batch"); for (var i = 0; i < batch.Count; i++) { @@ -191,30 +192,30 @@ public virtual void EnrichOperationBatchRequest( IReadOnlyList operations, Activity activity) { - activity.SetTag("graphql.http.request.type", "operationBatch"); + activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); if (request.DocumentId is not null && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - activity.SetTag("graphql.http.request.query.id", request.DocumentId.Value); + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - activity.SetTag("graphql.http.request.query.hash", request.DocumentHash.Value); + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) { - activity.SetTag("graphql.http.request.query.body", request.Document.Print()); + activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); } if (request.OperationName is not null && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { - activity.SetTag("graphql.http.request.operations", string.Join(" -> ", operations)); + activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); } if (request.Variables is not null @@ -235,7 +236,7 @@ protected virtual void EnrichRequestVariables( GraphQLRequest request, JsonDocument variables, Activity activity) - => activity.SetTag("graphql.http.request.variables", variables.RootElement.ToString()); + => activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); protected virtual void EnrichBatchVariables( HttpContext context, @@ -254,7 +255,7 @@ protected virtual void EnrichRequestExtensions( try { activity.SetTag( - "graphql.http.request.extensions", + GraphQL.Http.Request.Extensions, extensions.RootElement.ToString()); } catch @@ -290,7 +291,7 @@ public virtual void EnrichHttpRequestError( public virtual void EnrichHttpRequestError( HttpContext context, - Exception exception, + System.Exception exception, Activity activity) { } @@ -325,22 +326,32 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi } activity.DisplayName = operationDisplayName ?? "Execute Request"; - activity.SetTag("graphql.document.id", documentInfo.Id.Value); - activity.SetTag("graphql.document.hash", documentInfo.Hash.Value); - activity.SetTag("graphql.document.valid", documentInfo.IsValidated); - activity.SetTag("graphql.operation.id", operation?.Id); - activity.SetTag("graphql.operation.kind", operation?.Kind); - activity.SetTag("graphql.operation.name", operation?.Name); + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); + activity.SetTag(GraphQL.Operation.Id, operation?.Id); + + if (operation is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operation.Kind]); + + if (!string.IsNullOrEmpty(operation.Name)) + { + activity.SetTag(GraphQL.Operation.Name, operation.Name); + } + } if (_options.IncludeDocument && documentInfo.Document is not null) { - activity.SetTag("graphql.document.body", documentInfo.Document.Print()); + activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); } if (context.Result is OperationResult result) { var errorCount = result.Errors.Count; - activity.SetTag("graphql.errors.count", errorCount); + activity.SetTag(GraphQL.Errors.Count, errorCount); } } protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) @@ -432,17 +443,40 @@ protected virtual string CreateRootActivityName( public virtual void EnrichParseDocument(RequestContext context, Activity activity) { activity.DisplayName = "Parse Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); if (_options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } + + context.TryGetOperation(out var operation); + + if (operation is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operation.Kind]); + + if (!string.IsNullOrEmpty(operation.Name)) + { + activity.SetTag(GraphQL.Operation.Name, operation.Name); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichRequestError( RequestContext context, Activity activity, - Exception error) + System.Exception error) => EnrichError(ErrorBuilder.FromException(error).Build(), activity); public virtual void EnrichRequestError( @@ -454,15 +488,34 @@ public virtual void EnrichRequestError( public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { activity.DisplayName = "Validate Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); if (_options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } + context.TryGetOperation(out var operation); + + if (operation is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operation.Kind]); + + if (!string.IsNullOrEmpty(operation.Name)) + { + activity.SetTag(GraphQL.Operation.Name, operation.Name); + } + } + var documentInfo = context.OperationDocumentInfo; - activity.SetTag("graphql.document.id", documentInfo.Id.Value); - activity.SetTag("graphql.document.hash", documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichValidationError( @@ -479,6 +532,29 @@ public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Act public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { activity.DisplayName = "Coerce Variable"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); + + context.TryGetOperation(out var operation); + + if (operation is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operation.Kind]); + + if (!string.IsNullOrEmpty(operation.Name)) + { + activity.SetTag(GraphQL.Operation.Name, operation.Name); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichCompileOperation(RequestContext context, Activity activity) @@ -493,6 +569,28 @@ public virtual void EnrichExecuteOperation(RequestContext context, Activity acti operation?.Name is { } op ? $"Execute Operation {op}" : "Execute Operation"; + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + + if (operation is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operation.Kind]); + + if (!string.IsNullOrEmpty(operation.Name)) + { + activity.SetTag(GraphQL.Operation.Name, operation.Name); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity activity) @@ -505,14 +603,15 @@ public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity var coordinate = selection.Field.Coordinate; activity.DisplayName = path; - activity.SetTag("graphql.selection.name", selection.ResponseName); - activity.SetTag("graphql.selection.type", selection.Field.Type.Print()); - activity.SetTag("graphql.selection.path", path); - activity.SetTag("graphql.selection.hierarchy", hierarchy); - activity.SetTag("graphql.selection.field.name", coordinate.MemberName); - activity.SetTag("graphql.selection.field.coordinate", coordinate.ToString()); - activity.SetTag("graphql.selection.field.declaringType", coordinate.Name); - activity.SetTag("graphql.selection.field.isDeprecated", selection.Field.IsDeprecated); + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Resolve); + activity.SetTag(GraphQL.Selection.Name, selection.ResponseName); + activity.SetTag(GraphQL.Selection.Field.Type, selection.Field.Type.Print()); + activity.SetTag(GraphQL.Selection.Path, path); + activity.SetTag(GraphQL.Selection.Hierarchy, hierarchy); + activity.SetTag(GraphQL.Selection.Field.Name, coordinate.MemberName); + activity.SetTag(GraphQL.Selection.Field.Coordinate, coordinate.ToString()); + activity.SetTag(GraphQL.Selection.Field.ParentType, coordinate.Name); + activity.SetTag(GraphQL.Selection.Field.IsDeprecated, selection.Field.IsDeprecated); void BuildPath() { @@ -578,12 +677,13 @@ public virtual void EnrichDataLoaderBatch( where TKey : notnull { activity.DisplayName = $"Execute {dataLoader.GetType().Name} Batch"; - activity.SetTag("graphql.dataLoader.keys.count", keys.Count); + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderBatch); + activity.SetTag(GraphQL.DataLoader.Batch.Size, keys.Count); if (_options.IncludeDataLoaderKeys) { var temp = keys.Select(t => t.ToString()).ToArray(); - activity.SetTag("graphql.dataLoader.keys", temp); + activity.SetTag(GraphQL.DataLoader.Batch.Keys, temp); } } @@ -596,28 +696,21 @@ protected virtual void EnrichError(IError error, Activity activity) var tags = new ActivityTagsCollection { - new(AttributeExceptionMessage, error.Message), - new(AttributeExceptionType, error.Code ?? "GRAPHQL_ERROR") + new(SemanticConventions.Exception.Message, error.Message), + new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") }; if (error.Path is not null) { - tags["graphql.error.path"] = error.Path.ToString(); + tags[GraphQL.Errors.Path] = error.Path.ToString(); } if (error.Locations is { Count: > 0 }) { - tags["graphql.error.location.column"] = error.Locations[0].Column; - tags["graphql.error.location.line"] = error.Locations[0].Line; + tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; + tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; } - activity.AddEvent(new ActivityEvent(AttributeExceptionEventName, default, tags)); + activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } } - -file static class SemanticConventions -{ - public const string AttributeExceptionEventName = "exception"; - public const string AttributeExceptionType = "exception.type"; - public const string AttributeExceptionMessage = "exception.message"; -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index a0eeffcedd6..0d7d0a2d16e 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -2,6 +2,7 @@ using GreenDonut; using HotChocolate.Diagnostics.Scopes; using static HotChocolate.Diagnostics.HotChocolateActivitySource; +using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics.Listeners; @@ -41,10 +42,11 @@ public override IDisposable RunBatchDispatchCoordinator() { var activity = Source.StartActivity("BatchCoordinator"); activity?.DisplayName = "Coordinate DataLoader Batches"; + activity?.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); return activity ?? EmptyScope; } - public override void BatchDispatchError(Exception error) + public override void BatchDispatchError(System.Exception error) { #if NET9_0_OR_GREATER Activity.Current?.AddException(error); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs new file mode 100644 index 00000000000..1c5e6cc3a67 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs @@ -0,0 +1,124 @@ +using System.Collections.Frozen; +using HotChocolate.Language; + +namespace HotChocolate.Diagnostics; + +internal static class SemanticConventions +{ + public static class Exception + { + public const string EventName = "exception"; + public const string Type = "exception.type"; + public const string Message = "exception.message"; + } + + public static class GraphQL + { + public static class Document + { + public const string Id = "graphql.document.id"; + public const string Hash = "graphql.document.hash"; + public const string Body = "graphql.document.body"; + public const string Valid = "graphql.document.valid"; + } + + public static class Operation + { + public const string Id = "graphql.operation.id"; + public const string Name = "graphql.operation.name"; + public const string Type = "graphql.operation.type"; + + public static FrozenDictionary TypeValues { get; } = + new Dictionary + { + [OperationType.Query] = "query", + [OperationType.Mutation] = "mutation", + [OperationType.Subscription] = "subscription" + }.ToFrozenDictionary(); + } + + public static class Processing + { + public const string Type = "graphql.processing.type"; + + public static class TypeValues + { + public const string Parse = "parse"; + public const string Validate = "validate"; + public const string VariableCoercion = "variable_coercion"; + public const string Execute = "execute"; + public const string Resolve = "resolve"; + public const string DataLoaderDispatch = "dataloader_dispatch"; + public const string DataLoaderBatch = "dataloader_batch"; + } + } + + public static class Selection + { + public const string Name = "graphql.selection.name"; + public const string Path = "graphql.selection.path"; + public const string Hierarchy = "graphql.selection.hierarchy"; + + public static class Field + { + public const string Name = "graphql.selection.field.name"; + public const string ParentType = "graphql.selection.field.parent_type"; + public const string Coordinate = "graphql.selection.field.coordinate"; + public const string IsDeprecated = "graphql.selection.field.isDeprecated"; + public const string Type = "graphql.selection.type"; + } + } + + public static class DataLoader + { + public const string Name = "graphql.dataloader.name"; + + public static class Batch + { + public const string Size = "graphql.dataloader.batch.size"; + public const string Keys = "graphql.dataloader.batch.keys"; + } + + public static class Cache + { + public const string HitCount = "graphql.dataloader.cache.hit_count"; + public const string MissCount = "graphql.dataloader.cache.miss_count"; + } + } + + public static class Errors + { + public const string Count = "graphql.errors.count"; + public const string Path = "graphql.error.path"; + + public static class Location + { + public const string Column = "graphql.error.location.column"; + public const string Line = "graphql.error.location.line"; + } + } + + public static class Http + { + public const string Kind = "graphql.http.kind"; + + public static class Request + { + public const string Type = "graphql.http.request.type"; + public const string QueryId = "graphql.http.request.query.id"; + public const string QueryHash = "graphql.http.request.query.hash"; + public const string QueryBody = "graphql.http.request.query.body"; + public const string OperationName = "graphql.http.request.operation"; + public const string Operations = "graphql.http.request.operations"; + public const string Variables = "graphql.http.request.variables"; + public const string Extensions = "graphql.http.request.extensions"; + } + } + + public static class Schema + { + public const string Name = "graphql.schema.name"; + public const string IsDefault = "graphql.schema.isDefault"; + } + } +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 523e91ae3ae..68ebb085e1d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "_Default-1-6af18618ae20c266f6ffc352b78cb69b" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -33,6 +37,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +58,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -77,6 +89,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -89,6 +117,10 @@ "DisplayName": "/sayHello", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "sayHello" @@ -114,7 +146,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index 121d1b09cd0..2974166579c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "_Default-1-851fb754d9ba6b5cc5a55ebcbea2621d" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -37,6 +41,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "OK" @@ -50,8 +62,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -81,6 +93,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Error", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "ERROR" @@ -93,6 +121,10 @@ "DisplayName": "/causeFatalError", "Status": "Error", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "causeFatalError" @@ -118,7 +150,7 @@ "Value": "SimpleQuery.causeFatalError" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index 158121c23ce..b8576551dd2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -29,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "803df9346db185e9dc0b22dd3909aa70" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +54,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap index 4f621b6ca2d..4a2b9d77d14 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-452ea802c4d1bf2a81a7411b0b361d9f" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -69,6 +81,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" @@ -81,6 +105,10 @@ "DisplayName": "/a", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "a" @@ -106,7 +134,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap index 6adee85c424..f16e3a80cd5 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "_Default-1-cee0e2939ece72d650cb0331f4be4669" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "GetA" @@ -29,6 +33,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" @@ -42,8 +54,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -73,6 +85,22 @@ "DisplayName": "Execute Operation GetA", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" @@ -85,6 +113,10 @@ "DisplayName": "/a", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "a" @@ -110,7 +142,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap index 321f860a750..fbc414941b4 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-2e55fbe10a9e3ddf26935a8f8d15ec89" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -69,6 +81,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" @@ -81,6 +105,10 @@ "DisplayName": "/a", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "a" @@ -106,7 +134,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { @@ -121,6 +149,10 @@ "DisplayName": "/b", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "b" @@ -146,7 +178,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { @@ -161,6 +193,10 @@ "DisplayName": "/c", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "c" @@ -186,7 +222,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap index 677ff97b674..030ce2f9739 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-a5f924bb2f5f8651014e92e1cc2428c7" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -69,6 +81,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" @@ -81,6 +105,10 @@ "DisplayName": "/a", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "a" @@ -106,7 +134,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { @@ -121,6 +149,10 @@ "DisplayName": "/b", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "b" @@ -146,7 +178,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { @@ -161,6 +193,10 @@ "DisplayName": "/c", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "c" @@ -186,7 +222,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { @@ -201,6 +237,10 @@ "DisplayName": "/d", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "d" @@ -226,7 +266,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index b0ea2c00d2c..9e676cdd3dd 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "_Default-1-6af18618ae20c266f6ffc352b78cb69b" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -29,6 +33,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -42,8 +54,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -73,6 +85,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -85,6 +113,10 @@ "DisplayName": "/sayHello", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "sayHello" @@ -110,7 +142,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index c13dbaa8b92..3b078cb9b83 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -1,4 +1,4 @@ -{ +{ "activities": [ { "OperationName": "ExecuteRequest", @@ -29,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "bb1d246465341a97bdc727d6cd8ead5c" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +54,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events.snap deleted file mode 100644 index 04ebef7195e..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events.snap +++ /dev/null @@ -1,111 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.id", - "Value": "9b20745108c8de5afccc35cd56ead9fc" - }, - { - "Key": "graphql.document.hash", - "Value": "9b20745108c8de5afccc35cd56ead9fc" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "/dataLoader", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.selection.name", - "Value": "dataLoader" - }, - { - "Key": "graphql.selection.type", - "Value": "String" - }, - { - "Key": "graphql.selection.path", - "Value": "/dataLoader" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/dataLoader" - }, - { - "Key": "graphql.selection.field.name", - "Value": "dataLoader" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.dataLoader" - }, - { - "Key": "graphql.selection.field.declaringType", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "BatchCoordinator", - "DisplayName": "Coordinate DataLoader Batches", - "Status": "Unset", - "tags": [], - "event": [ - { - "Name": "BatchEvaluated", - "Tags": [ - { - "Key": "openBatches", - "Value": 1 - } - ] - }, - { - "Name": "BatchDispatched", - "Tags": [ - { - "Key": "dispatchedBatches", - "Value": 1 - } - ] - } - ], - "activities": [ - { - "OperationName": "ExecuteBatch", - "DisplayName": "Execute CustomDataLoader Batch", - "Status": "Unset", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events_with_keys.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events_with_keys.snap deleted file mode 100644 index 04ebef7195e..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_data_loader_events_with_keys.snap +++ /dev/null @@ -1,111 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.id", - "Value": "9b20745108c8de5afccc35cd56ead9fc" - }, - { - "Key": "graphql.document.hash", - "Value": "9b20745108c8de5afccc35cd56ead9fc" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "/dataLoader", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.selection.name", - "Value": "dataLoader" - }, - { - "Key": "graphql.selection.type", - "Value": "String" - }, - { - "Key": "graphql.selection.path", - "Value": "/dataLoader" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/dataLoader" - }, - { - "Key": "graphql.selection.field.name", - "Value": "dataLoader" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.dataLoader" - }, - { - "Key": "graphql.selection.field.declaringType", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "BatchCoordinator", - "DisplayName": "Coordinate DataLoader Batches", - "Status": "Unset", - "tags": [], - "event": [ - { - "Name": "BatchEvaluated", - "Tags": [ - { - "Key": "openBatches", - "Value": 1 - } - ] - }, - { - "Name": "BatchDispatched", - "Tags": [ - { - "Key": "dispatchedBatches", - "Value": 1 - } - ] - } - ], - "activities": [ - { - "OperationName": "ExecuteBatch", - "DisplayName": "Execute CustomDataLoader Batch", - "Status": "Unset", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 31c920d0d93..c6bb0814344 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -1,4 +1,4 @@ -{ +{ "activities": [ { "OperationName": "ValidateDocument", @@ -6,8 +6,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -37,6 +37,10 @@ "DisplayName": "/sayHello", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "sayHello" @@ -62,7 +66,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index d528c17e108..1e73fddb0a7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -69,6 +81,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -81,6 +105,10 @@ "DisplayName": "/sayHello", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "sayHello" @@ -106,7 +134,7 @@ "Value": "SimpleQuery.sayHello" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap index 928bc599863..1669a6a2090 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap @@ -1,4 +1,4 @@ -{ +{ "activities": [ { "OperationName": "ExecuteHttpRequest", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 8f7af550618..8c4aafda115 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-530cb46cabc38757c74c05cc7a96b636" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "530cb46cabc38757c74c05cc7a96b636" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -143,7 +163,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index ea5e73977d3..4e4132c18de 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-a570a6bff748b5916eadf153261d9c6d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "a570a6bff748b5916eadf153261d9c6d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -143,7 +163,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index f5cc8ff4b80..e0912a0b152 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -24,6 +24,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-a570a6bff748b5916eadf153261d9c6d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -55,8 +59,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "a570a6bff748b5916eadf153261d9c6d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -86,6 +90,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -111,7 +119,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index ed74db6956e..19c7b120d6c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -130,6 +158,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -155,7 +187,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index c6b48eaef41..a0b7ae9e46a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -48,6 +48,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -67,8 +71,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -110,6 +114,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -122,6 +138,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -134,6 +162,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -159,7 +191,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 88a26adcf95..e8ea02b47ea 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-dd31323224a6428d4dc301134352aeab" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "dd31323224a6428d4dc301134352aeab" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "3beaca4ee1714ac9c9dfec8e445529df" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -143,7 +163,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { @@ -158,6 +178,10 @@ "DisplayName": "/hero/id", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "id" @@ -183,7 +207,7 @@ "Value": "Droid.id" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Droid" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 8a5b3455d73..481c91f7c48 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-c0513b4b6f0cf7430f64de4aa3dcd7c6" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "c0513b4b6f0cf7430f64de4aa3dcd7c6" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "668e9631148921208d08dbb69513fa8e" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -143,7 +163,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { @@ -158,6 +178,10 @@ "DisplayName": "/hero/friends", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "friends" @@ -183,7 +207,7 @@ "Value": "Droid.friends" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Droid" }, { @@ -198,6 +222,10 @@ "DisplayName": "/hero/friends/nodes[0]/friends", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "friends" @@ -223,7 +251,7 @@ "Value": "Human.friends" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Human" }, { @@ -238,6 +266,10 @@ "DisplayName": "/hero/friends/nodes[1]/friends", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "friends" @@ -263,7 +295,7 @@ "Value": "Human.friends" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Human" }, { @@ -278,6 +310,10 @@ "DisplayName": "/hero/friends/nodes[2]/friends", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "friends" @@ -303,7 +339,7 @@ "Value": "Human.friends" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Human" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index e33490a9a8c..a0ab4136d02 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -1,4 +1,4 @@ -{ +{ "activities": [ { "OperationName": "ExecuteHttpRequest", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index ed74db6956e..19c7b120d6c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -106,6 +110,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -118,6 +134,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -130,6 +158,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -155,7 +187,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 3b5136f879a..75e231aeb38 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -48,6 +48,10 @@ { "Key": "graphql.operation.id", "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -67,8 +71,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -110,6 +114,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -122,6 +138,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" @@ -134,6 +162,10 @@ "DisplayName": "/hero", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, { "Key": "graphql.selection.name", "Value": "hero" @@ -159,7 +191,7 @@ "Value": "Query.hero" }, { - "Key": "graphql.selection.field.declaringType", + "Key": "graphql.selection.field.parent_type", "Value": "Query" }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index b0834861a59..f888f28f571 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -1,4 +1,4 @@ -{ +{ "activities": [ { "OperationName": "ExecuteHttpRequest", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 97a0396c0dc..111ca5e59c5 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -58,8 +58,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "e2b13c5332af8a70da160fcb96894e5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index e5afc4e0c28..29b6b1ddbe3 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -70,7 +70,7 @@ public virtual void EnrichExecuteHttpRequest( UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } - activity.SetTag("graphql.http.kind", kind); + activity.SetTag(GraphQL.Http.Kind, kind); var isDefault = false; if (!(context.Items.TryGetValue(SchemaName, out var value) @@ -80,8 +80,9 @@ public virtual void EnrichExecuteHttpRequest( isDefault = true; } - activity.SetTag("graphql.schema.name", schemaName); - activity.SetTag("graphql.schema.isDefault", isDefault); + // TODO: Is this needed? + activity.SetTag(GraphQL.Schema.Name, schemaName); + activity.SetTag(GraphQL.Schema.IsDefault, isDefault); } public virtual void EnrichSingleRequest( @@ -89,18 +90,18 @@ public virtual void EnrichSingleRequest( GraphQLRequest request, Activity activity) { - activity.SetTag("graphql.http.request.type", "single"); + activity.SetTag(GraphQL.Http.Request.Type, "single"); if (request.DocumentId is not null && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - activity.SetTag("graphql.http.request.query.id", request.DocumentId.Value); + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - activity.SetTag("graphql.http.request.query.hash", request.DocumentHash.Value); + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null @@ -112,13 +113,13 @@ public virtual void EnrichSingleRequest( _queryCache.Add(request.Document, query); } - activity.SetTag("graphql.http.request.query.body", query); + activity.SetTag(GraphQL.Http.Request.QueryBody, query); } if (request.OperationName is not null && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { - activity.SetTag("graphql.http.request.operation", request.OperationName); + activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); } if (request.Variables is not null @@ -139,7 +140,7 @@ public virtual void EnrichBatchRequest( IReadOnlyList batch, Activity activity) { - activity.SetTag("graphql.http.request.type", "batch"); + activity.SetTag(GraphQL.Http.Request.Type, "batch"); for (var i = 0; i < batch.Count; i++) { @@ -189,30 +190,30 @@ public virtual void EnrichOperationBatchRequest( IReadOnlyList operations, Activity activity) { - activity.SetTag("graphql.http.request.type", "operationBatch"); + activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); if (request.DocumentId is not null && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - activity.SetTag("graphql.http.request.query.id", request.DocumentId.Value); + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - activity.SetTag("graphql.http.request.query.hash", request.DocumentHash.Value); + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) { - activity.SetTag("graphql.http.request.query.body", request.Document.Print()); + activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); } if (request.OperationName is not null && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { - activity.SetTag("graphql.http.request.operations", string.Join(" -> ", operations)); + activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); } if (request.Variables is not null @@ -234,7 +235,7 @@ protected virtual void EnrichRequestVariables( JsonDocument variables, Activity activity) { - activity.SetTag("graphql.http.request.variables", variables.RootElement.ToString()); + activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); } protected virtual void EnrichBatchVariables( @@ -256,7 +257,7 @@ protected virtual void EnrichRequestExtensions( try { activity.SetTag( - "graphql.http.request.extensions", + GraphQL.Http.Request.Extensions, extensions.RootElement.ToString()); } catch @@ -292,7 +293,7 @@ public virtual void EnrichHttpRequestError( public virtual void EnrichHttpRequestError( HttpContext context, - Exception exception, + System.Exception exception, Activity activity) { } @@ -327,21 +328,31 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi } activity.DisplayName = operationDisplayName ?? "Execute Request"; - activity.SetTag("graphql.document.id", documentInfo.Id.Value); - activity.SetTag("graphql.document.hash", documentInfo.Hash.Value); - activity.SetTag("graphql.document.valid", documentInfo.IsValidated); - activity.SetTag("graphql.operation.id", plan?.Id); - activity.SetTag("graphql.operation.kind", plan?.Operation.Definition.Operation); - activity.SetTag("graphql.operation.name", plan?.OperationName); + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); + activity.SetTag(GraphQL.Operation.Id, plan?.Id); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + } if (_options.IncludeDocument && documentInfo.Document is not null) { - activity.SetTag("graphql.document.body", documentInfo.Document.Print()); + activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); } if (context.Result is OperationResult { Errors: [_, ..] errors }) { - activity.SetTag("graphql.errors.count", errors.Count); + activity.SetTag(GraphQL.Errors.Count, errors.Count); } } @@ -434,17 +445,40 @@ protected virtual string CreateRootActivityName( public virtual void EnrichParseDocument(RequestContext context, Activity activity) { activity.DisplayName = "Parse Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); if (_options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } + + var plan = context.GetOperationPlan(); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichRequestError( RequestContext context, Activity activity, - Exception error) + System.Exception error) => EnrichError(ErrorBuilder.FromException(error).Build(), activity); public virtual void EnrichRequestError( @@ -456,15 +490,34 @@ public virtual void EnrichRequestError( public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { activity.DisplayName = "Validate Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); if (_options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } + var plan = context.GetOperationPlan(); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + } + var documentInfo = context.OperationDocumentInfo; - activity.SetTag("graphql.document.id", documentInfo.Id.Value); - activity.SetTag("graphql.document.hash", documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichValidationError( @@ -481,11 +534,52 @@ public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Act public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { activity.DisplayName = "Coerce Variable"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); + + var plan = context.GetOperationPlan(); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichPlanOperationScope(RequestContext context, Activity activity) { activity.DisplayName = "Plan Operation"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); + + var plan = context.GetOperationPlan(); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + } } public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) @@ -495,6 +589,28 @@ public virtual void EnrichExecuteOperation(RequestContext context, Activity acti plan?.OperationName is { } op ? $"Execute Operation {op}" : "Execute Operation"; + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + + if (plan is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + } + + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } public virtual void EnrichExecuteOperationNode( @@ -504,9 +620,35 @@ public virtual void EnrichExecuteOperationNode( Activity activity) { activity.DisplayName = $"Execute Operation Node ({schemaName})"; - activity.SetTag("graphql.fusion.node.id", node.Id); - activity.SetTag("graphql.fusion.node.type", node.Type.ToString()); - activity.SetTag("graphql.fusion.node.schema", schemaName); + + // Required + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + + // Recommended + activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); + + var plan = context.OperationPlan; + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + + activity.SetTag(GraphQL.Document.Hash, context.RequestContext.OperationDocumentInfo.Hash.Value); + + // Opt-in - source schema info + activity.SetTag(GraphQL.Source.Name, schemaName); + + // Opt-in - source operation info + var operation = node.Operation; + activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); + activity.SetTag(GraphQL.Source.Operation.Kind, operation.Type.ToString().ToLowerInvariant()); + activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); } public virtual void EnrichExecuteOperationBatchNode( @@ -516,9 +658,38 @@ public virtual void EnrichExecuteOperationBatchNode( Activity activity) { activity.DisplayName = $"Execute Operation Batch Node ({schemaName})"; - activity.SetTag("graphql.fusion.node.id", node.Id); - activity.SetTag("graphql.fusion.node.type", node.Type.ToString()); - activity.SetTag("graphql.fusion.node.schema", schemaName); + + // Required + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + + // Recommended + activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); + + var plan = context.OperationPlan; + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + + activity.SetTag(GraphQL.Document.Hash, context.RequestContext.OperationDocumentInfo.Hash.Value); + + // Opt-in - source schema info + activity.SetTag(GraphQL.Source.Name, schemaName); + + // Opt-in - source operation info (if available) + if (node is OperationBatchExecutionNode batchNode) + { + var operation = batchNode.Operation; + activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); + activity.SetTag(GraphQL.Source.Operation.Kind, operation.Type.ToString().ToLowerInvariant()); + activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); + } } public virtual void EnrichExecuteNodeFieldNode( @@ -527,8 +698,14 @@ public virtual void EnrichExecuteNodeFieldNode( Activity activity) { activity.DisplayName = "Execute Node Field Node"; - activity.SetTag("graphql.fusion.node.id", node.Id); - activity.SetTag("graphql.fusion.node.type", node.Type.ToString()); + + // Required + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + + // Recommended + activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); } public virtual void EnrichExecuteIntrospectionNode( @@ -537,14 +714,20 @@ public virtual void EnrichExecuteIntrospectionNode( Activity activity) { activity.DisplayName = "Execute Introspection Node"; - activity.SetTag("graphql.fusion.node.id", node.Id); - activity.SetTag("graphql.fusion.node.type", node.Type.ToString()); + + // Required + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + + // Recommended + activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); } public virtual void EnrichExecutionNodeError( OperationPlanContext context, ExecutionNode node, - Exception error, + System.Exception error, Activity activity) => activity.RecordException(error); @@ -552,7 +735,7 @@ public virtual void EnrichSourceSchemaError( OperationPlanContext context, ExecutionNode node, string schemaName, - Exception error, + System.Exception error, Activity activity) => activity.RecordException(error); @@ -565,28 +748,21 @@ protected virtual void EnrichError(IError error, Activity activity) var tags = new ActivityTagsCollection { - new(AttributeExceptionMessage, error.Message), - new(AttributeExceptionType, error.Code ?? "GRAPHQL_ERROR") + new(SemanticConventions.Exception.Message, error.Message), + new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") }; if (error.Path is not null) { - tags["graphql.error.path"] = error.Path.ToString(); + tags[GraphQL.Errors.Path] = error.Path.ToString(); } if (error.Locations is { Count: > 0 }) { - tags["graphql.error.location.column"] = error.Locations[0].Column; - tags["graphql.error.location.line"] = error.Locations[0].Line; + tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; + tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; } - activity.AddEvent(new ActivityEvent(AttributeExceptionEventName, default, tags)); + activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } } - -file static class SemanticConventions -{ - public const string AttributeExceptionEventName = "exception"; - public const string AttributeExceptionType = "exception.type"; - public const string AttributeExceptionMessage = "exception.message"; -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs new file mode 100644 index 00000000000..6cc3844e0a5 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs @@ -0,0 +1,114 @@ +using System.Collections.Frozen; +using HotChocolate.Language; + +namespace HotChocolate.Fusion.Diagnostics; + +internal static class SemanticConventions +{ + public static class Exception + { + public const string EventName = "exception"; + public const string Type = "exception.type"; + public const string Message = "exception.message"; + } + + public static class GraphQL + { + public static class Document + { + public const string Id = "graphql.document.id"; + public const string Hash = "graphql.document.hash"; + public const string Body = "graphql.document.body"; + public const string Valid = "graphql.document.valid"; + } + + public static class Operation + { + public const string Id = "graphql.operation.id"; + public const string Name = "graphql.operation.name"; + public const string Type = "graphql.operation.type"; + + public static FrozenDictionary TypeValues { get; } = + new Dictionary + { + [OperationType.Query] = "query", + [OperationType.Mutation] = "mutation", + [OperationType.Subscription] = "subscription" + }.ToFrozenDictionary(); + + public static class Step + { + public const string Id = "graphql.operation.step.id"; + public const string Kind = "graphql.operation.step.kind"; + + public static class Plan + { + public const string Id = "graphql.operation.step.plan.id"; + } + } + } + + public static class Processing + { + public const string Type = "graphql.processing.type"; + + public static class TypeValues + { + public const string Parse = "parse"; + public const string Validate = "validate"; + public const string VariableCoercion = "variable_coercion"; + public const string Plan = "plan"; + public const string Execute = "execute"; + public const string StepExecute = "step_execute"; + } + } + + public static class Source + { + public const string Name = "graphql.source.name"; + public const string Id = "graphql.source.id"; + + public static class Operation + { + public const string Name = "graphql.source.operation.name"; + public const string Kind = "graphql.source.operation.kind"; + public const string Hash = "graphql.source.operation.hash"; + } + } + + public static class Errors + { + public const string Count = "graphql.errors.count"; + public const string Path = "graphql.error.path"; + + public static class Location + { + public const string Column = "graphql.error.location.column"; + public const string Line = "graphql.error.location.line"; + } + } + + public static class Http + { + public const string Kind = "graphql.http.kind"; + + public static class Request + { + public const string Type = "graphql.http.request.type"; + public const string QueryId = "graphql.http.request.query.id"; + public const string QueryHash = "graphql.http.request.query.hash"; + public const string QueryBody = "graphql.http.request.query.body"; + public const string OperationName = "graphql.http.request.operation"; + public const string Operations = "graphql.http.request.operations"; + public const string Variables = "graphql.http.request.variables"; + public const string Extensions = "graphql.http.request.extensions"; + } + } + + public static class Schema + { + public const string Name = "graphql.schema.name"; + public const string IsDefault = "graphql.schema.isDefault"; + } + } +} diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index 032d0b194de..3c15743962b 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -596,6 +596,27 @@ builder.Services incrementalDeliveryFormat: IncrementalDeliveryFormat.Version_0_1); ``` +## OpenTelemetry span attribute changes + +The OpenTelemetry span attributes emitted by `AddInstrumentation()` have been updated to align with the [proposed OpenTelemetry semantic conventions for GraphQL](https://github.com/graphql/otel-wg/blob/main/spec/spans.yml). + +If you have dashboards or alerts that filter on the old attribute names or values, update them accordingly. + +### Renamed attributes + +| Old Attribute | New Attribute | +| --------------------------------------- | ------------------------------------- | +| `graphql.operation.kind` | `graphql.operation.type` | +| `graphql.selection.field.declaringType` | `graphql.selection.field.parent_type` | +| `graphql.dataLoader.keys.count` | `graphql.dataloader.batch.size` | +| `graphql.dataLoader.keys` | `graphql.dataloader.batch.keys` | + +### Changed attribute values + +| Attribute | Old Value | New Value | +| ------------------------ | ------------------------------------- | ------------------------------------- | +| `graphql.operation.type` | `Query` / `Mutation` / `Subscription` | `query` / `mutation` / `subscription` | + # Deprecations Things that will continue to function this release, but we encourage you to move away from. From e5e8eb397b57f4910da26cb8cf31a2f35731a280 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 10:13:49 +0000 Subject: [PATCH 02/37] Introduce HotChocolate.Diagnostics.Core project --- src/All.slnx | 1 + .../Diagnostics/HotChocolate.Diagnostics.slnx | 1 + .../Diagnostics.Core/ActivityEnricherBase.cs | 387 ++++++++++++++++++ .../HotChocolate.Diagnostics.Core.csproj | 26 ++ .../InstrumentationOptionsBase.cs | 40 ++ .../RequestDetails.cs | 0 .../SemanticConventions.cs | 26 ++ .../src/Diagnostics/ActivityEnricher.cs | 367 +---------------- .../HotChocolate.Diagnostics.csproj | 1 + .../src/Diagnostics/InstrumentationOptions.cs | 35 +- .../FusionActivityEnricher.cs | 372 +---------------- .../HotChocolate.Fusion.Diagnostics.csproj | 1 + .../InstrumentationOptions.cs | 36 +- .../src/Fusion.Diagnostics/RequestDetails.cs | 15 - .../Fusion.Diagnostics/SemanticConventions.cs | 114 ------ ...tChocolate.Fusion.Diagnostics.Tests.csproj | 1 + .../ServerInstrumentationTests.cs | 23 +- ...onTests.Allow_Document_To_Be_Captured.snap | 84 +++- ...r_Error_That_Deletes_The_Whole_Result.snap | 84 +++- ...or_That_Deletes_The_Whole_Result_Deep.snap | 12 +- ...e_Operation_Display_Name_With_1_Field.snap | 72 +++- ...tion_Display_Name_With_1_Field_And_Op.snap | 84 +++- ...e_Operation_Display_Name_With_3_Field.snap | 72 +++- ...e_Operation_Display_Name_With_4_Field.snap | 72 +++- ...peration_Name_Is_Used_As_Request_Name.snap | 84 +++- ...lidation_Activity_Has_An_Error_Status.snap | 12 +- ...onTests.Source_Schema_Transport_Error.snap | 72 +++- ...ents_Of_A_Query_With_Multiple_Sources.snap | 104 ++++- ...rack_Events_Of_A_Simple_Query_Default.snap | 48 ++- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 72 +++- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 72 +++- ...entationTests.Http_Get_Single_Request.snap | 64 ++- ....Http_Post_Add_Query_To_Http_Activity.snap | 76 +++- ...p_Post_Add_Variables_To_Http_Activity.snap | 76 +++- ...ntationTests.Http_Post_Single_Request.snap | 64 ++- ...ests.Http_Post_Single_Request_Default.snap | 52 ++- ...Not_Automatically_Added_To_Activities.snap | 76 +++- ...onTests.Http_Post_With_Extensions_Map.snap | 76 +++- ...n_Error_When_Rename_Root_Is_Activated.snap | 4 +- 39 files changed, 1870 insertions(+), 1008 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/HotChocolate.Diagnostics.Core.csproj create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs rename src/HotChocolate/Diagnostics/src/{Diagnostics => Diagnostics.Core}/RequestDetails.cs (100%) rename src/HotChocolate/Diagnostics/src/{Diagnostics => Diagnostics.Core}/SemanticConventions.cs (83%) delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/RequestDetails.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs diff --git a/src/All.slnx b/src/All.slnx index 6e47fb35693..5de922b6493 100644 --- a/src/All.slnx +++ b/src/All.slnx @@ -173,6 +173,7 @@ + diff --git a/src/HotChocolate/Diagnostics/HotChocolate.Diagnostics.slnx b/src/HotChocolate/Diagnostics/HotChocolate.Diagnostics.slnx index 3c4f93bf3f9..a1b11b2c50d 100644 --- a/src/HotChocolate/Diagnostics/HotChocolate.Diagnostics.slnx +++ b/src/HotChocolate/Diagnostics/HotChocolate.Diagnostics.slnx @@ -1,6 +1,7 @@ + diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs new file mode 100644 index 00000000000..fc8046b74e2 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -0,0 +1,387 @@ +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Text; +using System.Text.Json; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.ObjectPool; +using HotChocolate.AspNetCore.Instrumentation; +using HotChocolate.Execution; +using HotChocolate.Language; +using HotChocolate.Language.Utilities; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; +using static HotChocolate.WellKnownContextData; + +namespace HotChocolate.Diagnostics; + +/// +/// Base class for activity enrichers that provides shared enrichment logic +/// for HTTP request handling, error handling, and common span enrichment. +/// +public abstract class ActivityEnricherBase +{ + private readonly InstrumentationOptionsBase _options; + private readonly ConditionalWeakTable _queryCache = []; + + protected ActivityEnricherBase( + ObjectPool stringBuilderPool, + InstrumentationOptionsBase options) + { + StringBuilderPool = stringBuilderPool; + _options = options; + } + + /// + /// Gets the pool used by this enricher. + /// + protected ObjectPool StringBuilderPool { get; } + + public virtual void EnrichExecuteHttpRequest( + HttpContext context, + HttpRequestKind kind, + Activity activity) + { + switch (kind) + { + case HttpRequestKind.HttpPost: + activity.DisplayName = "GraphQL HTTP POST"; + break; + case HttpRequestKind.HttpMultiPart: + activity.DisplayName = "GraphQL HTTP POST MultiPart"; + break; + case HttpRequestKind.HttpGet: + activity.DisplayName = "GraphQL HTTP GET"; + break; + case HttpRequestKind.HttpGetSchema: + activity.DisplayName = "GraphQL HTTP GET SDL"; + break; + } + + if (_options.RenameRootActivity) + { + UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); + } + + activity.SetTag(GraphQL.Http.Kind, kind); + + var isDefault = false; + if (!(context.Items.TryGetValue(SchemaName, out var value) + && value is string schemaName)) + { + schemaName = ISchemaDefinition.DefaultName; + isDefault = true; + } + + // TODO: Is this needed? + activity.SetTag(GraphQL.Schema.Name, schemaName); + activity.SetTag(GraphQL.Schema.IsDefault, isDefault); + } + + public virtual void EnrichSingleRequest( + HttpContext context, + GraphQLRequest request, + Activity activity) + { + activity.SetTag(GraphQL.Http.Request.Type, "single"); + + if (request.DocumentId is not null + && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + } + + if (request.Document is not null + && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + { + if (!_queryCache.TryGetValue(request.Document, out var query)) + { + query = request.Document.Print(); + _queryCache.Add(request.Document, query); + } + + activity.SetTag(GraphQL.Http.Request.QueryBody, query); + } + + if (request.OperationName is not null + && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + { + activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); + } + + if (request.Variables is not null + && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + EnrichRequestVariables(context, request, request.Variables, activity); + } + + if (request.Extensions is not null + && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + EnrichRequestExtensions(context, request, request.Extensions, activity); + } + } + + public virtual void EnrichBatchRequest( + HttpContext context, + IReadOnlyList batch, + Activity activity) + { + activity.SetTag(GraphQL.Http.Request.Type, "batch"); + + for (var i = 0; i < batch.Count; i++) + { + var request = batch[i]; + + if (request.DocumentId is not null + && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + activity.SetTag($"graphql.http.request[{i}].query.id", request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + activity.SetTag($"graphql.http.request[{i}].query.hash", request.DocumentHash.Value); + } + + if (request.Document is not null + && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + { + activity.SetTag($"graphql.http.request[{i}].query.body", request.Document.Print()); + } + + if (request.OperationName is not null + && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + { + activity.SetTag($"graphql.http.request[{i}].operation", request.OperationName); + } + + if (request.Variables is not null + && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + EnrichBatchVariables(context, request, request.Variables, i, activity); + } + + if (request.Extensions is not null + && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + EnrichBatchExtensions(context, request, request.Extensions, i, activity); + } + } + } + + public virtual void EnrichOperationBatchRequest( + HttpContext context, + GraphQLRequest request, + IReadOnlyList operations, + Activity activity) + { + activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); + + if (request.DocumentId is not null + && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + } + + if (request.Document is not null + && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + { + activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); + } + + if (request.OperationName is not null + && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + { + activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); + } + + if (request.Variables is not null + && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + EnrichRequestVariables(context, request, request.Variables, activity); + } + + if (request.Extensions is not null + && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + EnrichRequestExtensions(context, request, request.Extensions, activity); + } + } + + protected virtual void EnrichRequestVariables( + HttpContext context, + GraphQLRequest request, + JsonDocument variables, + Activity activity) + => activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); + + protected virtual void EnrichBatchVariables( + HttpContext context, + GraphQLRequest request, + JsonDocument variables, + int index, + Activity activity) + => activity.SetTag($"graphql.http.request[{index}].variables", variables.RootElement.ToString()); + + protected virtual void EnrichRequestExtensions( + HttpContext context, + GraphQLRequest request, + JsonDocument extensions, + Activity activity) + { + try + { + activity.SetTag( + GraphQL.Http.Request.Extensions, + extensions.RootElement.ToString()); + } + catch + { + // Ignore any errors + } + } + + protected virtual void EnrichBatchExtensions( + HttpContext context, + GraphQLRequest request, + JsonDocument extensions, + int index, + Activity activity) + { + try + { + activity.SetTag( + $"graphql.http.request[{index}].extensions", + extensions.RootElement.ToString()); + } + catch + { + // Ignore any errors + } + } + + public virtual void EnrichHttpRequestError( + HttpContext context, + IError error, + Activity activity) + => EnrichError(error, activity); + + public virtual void EnrichHttpRequestError( + HttpContext context, + System.Exception exception, + Activity activity) + { + } + + public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) + { + activity.DisplayName = "Parse HTTP Request"; + + if (_options.RenameRootActivity) + { + UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); + } + } + + public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) + => EnrichError(error, activity); + + public virtual void EnrichFormatHttpResponse(HttpContext context, Activity activity) + { + activity.DisplayName = "Format HTTP Response"; + } + + public virtual void EnrichRequestError( + RequestContext context, + Activity activity, + System.Exception error) + => EnrichError(ErrorBuilder.FromException(error).Build(), activity); + + public virtual void EnrichRequestError( + RequestContext context, + Activity activity, + IError error) + => EnrichError(error, activity); + + public virtual void EnrichValidationError( + RequestContext context, + Activity activity, + IError error) + => EnrichError(error, activity); + + public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Activity activity) + { + activity.DisplayName = "Analyze Operation Complexity"; + } + + protected void UpdateRootActivityName(Activity activity, string displayName) + { + var current = activity; + + while (current.Parent is not null) + { + current = current.Parent; + } + + if (current != activity) + { + current.DisplayName = CreateRootActivityName(activity, current, displayName); + } + } + + protected virtual string CreateRootActivityName( + Activity activity, + Activity root, + string displayName) + { + const string key = "originalDisplayName"; + + if (root.GetCustomProperty(key) is not string rootDisplayName) + { + rootDisplayName = root.DisplayName; + root.SetCustomProperty(key, rootDisplayName); + } + + return $"{rootDisplayName}: {displayName}"; + } + + protected virtual void EnrichError(IError error, Activity activity) + { + if (error.Exception is { } exception) + { + activity.RecordException(exception); + } + + var tags = new ActivityTagsCollection + { + new(SemanticConventions.Exception.Message, error.Message), + new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") + }; + + if (error.Path is not null) + { + tags[GraphQL.Errors.Path] = error.Path.ToString(); + } + + if (error.Locations is { Count: > 0 }) + { + tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; + tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; + } + + activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/HotChocolate.Diagnostics.Core.csproj b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/HotChocolate.Diagnostics.Core.csproj new file mode 100644 index 00000000000..51a678de338 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/HotChocolate.Diagnostics.Core.csproj @@ -0,0 +1,26 @@ + + + + HotChocolate.Diagnostics.Core + HotChocolate.Diagnostics.Core + HotChocolate.Diagnostics + + + + + + + + + + + + + + + + + + + + diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs new file mode 100644 index 00000000000..f5a0854d474 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs @@ -0,0 +1,40 @@ +namespace HotChocolate.Diagnostics; + +/// +/// Base class for Hot Chocolate instrumentation options. +/// +public abstract class InstrumentationOptionsBase +{ + /// + /// Specifies the request detail that shall be included into the tracing activities. + /// + public RequestDetails RequestDetails { get; set; } = RequestDetails.Default; + + /// + /// Specifies if the parsed document shall be included into the tracing data. + /// + public bool IncludeDocument { get; set; } + + /// + /// Defines if the operation display name shall be included in the root activity. + /// + public bool RenameRootActivity { get; set; } + + internal bool IncludeRequestDetails => RequestDetails is not RequestDetails.None; + + internal abstract bool SkipExecuteHttpRequest { get; } + + internal abstract bool SkipParseHttpRequest { get; } + + internal abstract bool SkipFormatHttpResponse { get; } + + internal abstract bool SkipExecuteRequest { get; } + + internal abstract bool SkipParseDocument { get; } + + internal abstract bool SkipValidateDocument { get; } + + internal abstract bool SkipCoerceVariables { get; } + + internal abstract bool SkipExecuteOperation { get; } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/RequestDetails.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs similarity index 100% rename from src/HotChocolate/Diagnostics/src/Diagnostics/RequestDetails.cs rename to src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs similarity index 83% rename from src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs rename to src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 1c5e6cc3a67..86991705d45 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -35,6 +35,17 @@ public static class Operation [OperationType.Mutation] = "mutation", [OperationType.Subscription] = "subscription" }.ToFrozenDictionary(); + + public static class Step + { + public const string Id = "graphql.operation.step.id"; + public const string Kind = "graphql.operation.step.kind"; + + public static class Plan + { + public const string Id = "graphql.operation.step.plan.id"; + } + } } public static class Processing @@ -46,7 +57,9 @@ public static class TypeValues public const string Parse = "parse"; public const string Validate = "validate"; public const string VariableCoercion = "variable_coercion"; + public const string Plan = "plan"; public const string Execute = "execute"; + public const string StepExecute = "step_execute"; public const string Resolve = "resolve"; public const string DataLoaderDispatch = "dataloader_dispatch"; public const string DataLoaderBatch = "dataloader_batch"; @@ -86,6 +99,19 @@ public static class Cache } } + public static class Source + { + public const string Name = "graphql.source.name"; + public const string Id = "graphql.source.id"; + + public static class Operation + { + public const string Name = "graphql.source.operation.name"; + public const string Kind = "graphql.source.operation.kind"; + public const string Hash = "graphql.source.operation.hash"; + } + } + public static class Errors { public const string Count = "graphql.errors.count"; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 3c6c7f8e672..7fcde2d252c 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -1,20 +1,13 @@ using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Text; -using System.Text.Json; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.ObjectPool; using GreenDonut; -using HotChocolate.AspNetCore.Instrumentation; using HotChocolate.Execution; using HotChocolate.Execution.Processing; -using HotChocolate.Language; using HotChocolate.Language.Utilities; using HotChocolate.Resolvers; using HotChocolate.Types; -using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; -using static HotChocolate.WellKnownContextData; namespace HotChocolate.Diagnostics; @@ -23,10 +16,9 @@ namespace HotChocolate.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class ActivityEnricher +public class ActivityEnricher : ActivityEnricherBase { private readonly InstrumentationOptions _options; - private readonly ConditionalWeakTable _queryCache = []; /// /// Initializes a new instance of . @@ -36,284 +28,11 @@ public class ActivityEnricher protected ActivityEnricher( ObjectPool stringBuilderPool, InstrumentationOptions options) + : base(stringBuilderPool, options) { - StringBuilderPool = stringBuilderPool; _options = options; } - /// - /// Gets the pool used by this enricher. - /// - protected ObjectPool StringBuilderPool { get; } - - public virtual void EnrichExecuteHttpRequest( - HttpContext context, - HttpRequestKind kind, - Activity activity) - { - switch (kind) - { - case HttpRequestKind.HttpPost: - activity.DisplayName = "GraphQL HTTP POST"; - break; - case HttpRequestKind.HttpMultiPart: - activity.DisplayName = "GraphQL HTTP POST MultiPart"; - break; - case HttpRequestKind.HttpGet: - activity.DisplayName = "GraphQL HTTP GET"; - break; - case HttpRequestKind.HttpGetSchema: - activity.DisplayName = "GraphQL HTTP GET SDL"; - break; - } - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - - activity.SetTag(GraphQL.Http.Kind, kind); - - var isDefault = false; - if (!(context.Items.TryGetValue(SchemaName, out var value) - && value is string schemaName)) - { - schemaName = ISchemaDefinition.DefaultName; - isDefault = true; - } - - // TODO: Is this needed? - activity.SetTag(GraphQL.Schema.Name, schemaName); - activity.SetTag(GraphQL.Schema.IsDefault, isDefault); - } - - public virtual void EnrichSingleRequest( - HttpContext context, - GraphQLRequest request, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "single"); - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - if (!_queryCache.TryGetValue(request.Document, out var query)) - { - query = request.Document.Print(); - _queryCache.Add(request.Document, query); - } - - activity.SetTag(GraphQL.Http.Request.QueryBody, query); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - public virtual void EnrichBatchRequest( - HttpContext context, - IReadOnlyList batch, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "batch"); - - for (var i = 0; i < batch.Count; i++) - { - var request = batch[i]; - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag($"graphql.http.request[{i}].query.id", request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag($"graphql.http.request[{i}].query.hash", request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - activity.SetTag($"graphql.http.request[{i}].query.body", request.Document.Print()); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag($"graphql.http.request[{i}].operation", request.OperationName); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichBatchVariables(context, request, request.Variables, i, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichBatchExtensions(context, request, request.Extensions, i, activity); - } - } - } - - public virtual void EnrichOperationBatchRequest( - HttpContext context, - GraphQLRequest request, - IReadOnlyList operations, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - protected virtual void EnrichRequestVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - Activity activity) - => activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); - - protected virtual void EnrichBatchVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - int index, - Activity activity) - => activity.SetTag($"graphql.http.request[{index}].variables", variables.RootElement.ToString()); - - protected virtual void EnrichRequestExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - Activity activity) - { - try - { - activity.SetTag( - GraphQL.Http.Request.Extensions, - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - protected virtual void EnrichBatchExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - int index, - Activity activity) - { - try - { - activity.SetTag( - $"graphql.http.request[{index}].extensions", - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - public virtual void EnrichHttpRequestError( - HttpContext context, - IError error, - Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichHttpRequestError( - HttpContext context, - System.Exception exception, - Activity activity) - { - } - - public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) - { - activity.DisplayName = "Parse HTTP Request"; - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - } - - public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichFormatHttpResponse(HttpContext context, Activity activity) - { - activity.DisplayName = "Format HTTP Response"; - } - public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); @@ -354,6 +73,7 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi activity.SetTag(GraphQL.Errors.Count, errorCount); } } + protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) { if (operation is null) @@ -409,37 +129,6 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi } } - private void UpdateRootActivityName(Activity activity, string displayName) - { - var current = activity; - - while (current.Parent is not null) - { - current = current.Parent; - } - - if (current != activity) - { - current.DisplayName = CreateRootActivityName(activity, current, displayName); - } - } - - protected virtual string CreateRootActivityName( - Activity activity, - Activity root, - string displayName) - { - const string key = "originalDisplayName"; - - if (root.GetCustomProperty(key) is not string rootDisplayName) - { - rootDisplayName = root.DisplayName; - root.SetCustomProperty(key, rootDisplayName); - } - - return $"{rootDisplayName}: {displayName}"; - } - public virtual void EnrichParseDocument(RequestContext context, Activity activity) { activity.DisplayName = "Parse Document"; @@ -473,18 +162,6 @@ public virtual void EnrichParseDocument(RequestContext context, Activity activit } } - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - System.Exception error) - => EnrichError(ErrorBuilder.FromException(error).Build(), activity); - - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(error, activity); - public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { activity.DisplayName = "Validate Document"; @@ -518,17 +195,6 @@ public virtual void EnrichValidateDocument(RequestContext context, Activity acti } } - public virtual void EnrichValidationError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(error, activity); - - public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Activity activity) - { - activity.DisplayName = "Analyze Operation Complexity"; - } - public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { activity.DisplayName = "Coerce Variable"; @@ -686,31 +352,4 @@ public virtual void EnrichDataLoaderBatch( activity.SetTag(GraphQL.DataLoader.Batch.Keys, temp); } } - - protected virtual void EnrichError(IError error, Activity activity) - { - if (error.Exception is { } exception) - { - activity.RecordException(exception); - } - - var tags = new ActivityTagsCollection - { - new(SemanticConventions.Exception.Message, error.Message), - new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") - }; - - if (error.Path is not null) - { - tags[GraphQL.Errors.Path] = error.Path.ToString(); - } - - if (error.Locations is { Count: > 0 }) - { - tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; - tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; - } - - activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); - } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/HotChocolate.Diagnostics.csproj b/src/HotChocolate/Diagnostics/src/Diagnostics/HotChocolate.Diagnostics.csproj index 49885604251..a1a4cf24a90 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/HotChocolate.Diagnostics.csproj +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/HotChocolate.Diagnostics.csproj @@ -16,6 +16,7 @@ + diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs index a28fe4fbd41..52815ef7aa2 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs @@ -5,54 +5,37 @@ namespace HotChocolate.Diagnostics; /// /// The Hot Chocolate instrumentation options. /// -public sealed class InstrumentationOptions +public sealed class InstrumentationOptions : InstrumentationOptionsBase { - /// - /// Specifies the request detail that shall be included into the tracing activities. - /// - public RequestDetails RequestDetails { get; set; } = RequestDetails.Default; - /// /// Specifies the activity scopes that shall be instrumented. /// public ActivityScopes Scopes { get; set; } = Default; - /// - /// Specifies if the parsed document shall be included into the tracing data. - /// - public bool IncludeDocument { get; set; } - /// /// Specifies if DataLoader batch keys shall be included into the tracing data. /// public bool IncludeDataLoaderKeys { get; set; } - /// - /// Defines if the operation display name shall be included in the root activity. - /// - public bool RenameRootActivity { get; set; } - - internal bool IncludeRequestDetails => RequestDetails is not RequestDetails.None; - - internal bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; + internal override bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; - internal bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; + internal override bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; - internal bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; + internal override bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; - internal bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; + internal override bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; - internal bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; + internal override bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; - internal bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; + internal override bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; internal bool SkipAnalyzeComplexity => (Scopes & AnalyzeComplexity) != AnalyzeComplexity; - internal bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; + internal override bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; internal bool SkipCompileOperation => (Scopes & CompileOperation) != CompileOperation; - internal bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; + internal override bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; internal bool SkipResolveFieldValue => (Scopes & ResolveFieldValue) != ResolveFieldValue; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index 29b6b1ddbe3..33ab7ccf374 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -1,18 +1,13 @@ using System.Diagnostics; -using System.Runtime.CompilerServices; using System.Text; -using System.Text.Json; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.ObjectPool; -using HotChocolate.AspNetCore.Instrumentation; +using HotChocolate.Diagnostics; using HotChocolate.Execution; using HotChocolate.Fusion.Execution; using HotChocolate.Fusion.Execution.Nodes; -using HotChocolate.Language; using HotChocolate.Language.Utilities; using OpenTelemetry.Trace; -using static HotChocolate.Fusion.Diagnostics.SemanticConventions; -using static HotChocolate.WellKnownContextData; +using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Fusion.Diagnostics; @@ -21,10 +16,9 @@ namespace HotChocolate.Fusion.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class FusionActivityEnricher +public class FusionActivityEnricher : ActivityEnricherBase { private readonly InstrumentationOptions _options; - private readonly ConditionalWeakTable _queryCache = []; /// /// Initializes a new instance of . @@ -34,288 +28,11 @@ public class FusionActivityEnricher protected FusionActivityEnricher( ObjectPool stringBuilderPool, InstrumentationOptions options) + : base(stringBuilderPool, options) { - StringBuilderPool = stringBuilderPool; _options = options; } - /// - /// Gets the pool used by this enricher. - /// - protected ObjectPool StringBuilderPool { get; } - - public virtual void EnrichExecuteHttpRequest( - HttpContext context, - HttpRequestKind kind, - Activity activity) - { - switch (kind) - { - case HttpRequestKind.HttpPost: - activity.DisplayName = "GraphQL HTTP POST"; - break; - case HttpRequestKind.HttpMultiPart: - activity.DisplayName = "GraphQL HTTP POST MultiPart"; - break; - case HttpRequestKind.HttpGet: - activity.DisplayName = "GraphQL HTTP GET"; - break; - case HttpRequestKind.HttpGetSchema: - activity.DisplayName = "GraphQL HTTP GET SDL"; - break; - } - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - - activity.SetTag(GraphQL.Http.Kind, kind); - - var isDefault = false; - if (!(context.Items.TryGetValue(SchemaName, out var value) - && value is string schemaName)) - { - schemaName = ISchemaDefinition.DefaultName; - isDefault = true; - } - - // TODO: Is this needed? - activity.SetTag(GraphQL.Schema.Name, schemaName); - activity.SetTag(GraphQL.Schema.IsDefault, isDefault); - } - - public virtual void EnrichSingleRequest( - HttpContext context, - GraphQLRequest request, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "single"); - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - if (!_queryCache.TryGetValue(request.Document, out var query)) - { - query = request.Document.Print(); - _queryCache.Add(request.Document, query); - } - - activity.SetTag(GraphQL.Http.Request.QueryBody, query); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - public virtual void EnrichBatchRequest( - HttpContext context, - IReadOnlyList batch, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "batch"); - - for (var i = 0; i < batch.Count; i++) - { - var request = batch[i]; - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag($"graphql.http.request[{i}].query.id", request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag($"graphql.http.request[{i}].query.hash", request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - activity.SetTag($"graphql.http.request[{i}].query.body", request.Document.Print()); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag($"graphql.http.request[{i}].operation", request.OperationName); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichBatchVariables(context, request, request.Variables, i, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichBatchExtensions(context, request, request.Extensions, i, activity); - } - } - } - - public virtual void EnrichOperationBatchRequest( - HttpContext context, - GraphQLRequest request, - IReadOnlyList operations, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); - - if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) - { - activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); - } - - if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) - { - activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); - } - - if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - protected virtual void EnrichRequestVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); - } - - protected virtual void EnrichBatchVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - int index, - Activity activity) - { - activity.SetTag($"graphql.http.request[{index}].variables", variables.RootElement.ToString()); - } - - protected virtual void EnrichRequestExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - Activity activity) - { - try - { - activity.SetTag( - GraphQL.Http.Request.Extensions, - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - protected virtual void EnrichBatchExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - int index, - Activity activity) - { - try - { - activity.SetTag( - $"graphql.http.request[{index}].extensions", - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - public virtual void EnrichHttpRequestError( - HttpContext context, - IError error, - Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichHttpRequestError( - HttpContext context, - System.Exception exception, - Activity activity) - { - } - - public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) - { - activity.DisplayName = "Parse HTTP Request"; - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - } - - public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichFormatHttpResponse(HttpContext context, Activity activity) - { - activity.DisplayName = "Format HTTP Response"; - } - public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); @@ -411,37 +128,6 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi } } - private void UpdateRootActivityName(Activity activity, string displayName) - { - var current = activity; - - while (current.Parent is not null) - { - current = current.Parent; - } - - if (current != activity) - { - current.DisplayName = CreateRootActivityName(activity, current, displayName); - } - } - - protected virtual string CreateRootActivityName( - Activity activity, - Activity root, - string displayName) - { - const string key = "originalDisplayName"; - - if (root.GetCustomProperty(key) is not string rootDisplayName) - { - rootDisplayName = root.DisplayName; - root.SetCustomProperty(key, rootDisplayName); - } - - return $"{rootDisplayName}: {displayName}"; - } - public virtual void EnrichParseDocument(RequestContext context, Activity activity) { activity.DisplayName = "Parse Document"; @@ -475,18 +161,6 @@ public virtual void EnrichParseDocument(RequestContext context, Activity activit } } - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - System.Exception error) - => EnrichError(ErrorBuilder.FromException(error).Build(), activity); - - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(error, activity); - public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { activity.DisplayName = "Validate Document"; @@ -520,17 +194,6 @@ public virtual void EnrichValidateDocument(RequestContext context, Activity acti } } - public virtual void EnrichValidationError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(error, activity); - - public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Activity activity) - { - activity.DisplayName = "Analyze Operation Complexity"; - } - public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { activity.DisplayName = "Coerce Variable"; @@ -738,31 +401,4 @@ public virtual void EnrichSourceSchemaError( System.Exception error, Activity activity) => activity.RecordException(error); - - protected virtual void EnrichError(IError error, Activity activity) - { - if (error.Exception is { } exception) - { - activity.RecordException(exception); - } - - var tags = new ActivityTagsCollection - { - new(SemanticConventions.Exception.Message, error.Message), - new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") - }; - - if (error.Path is not null) - { - tags[GraphQL.Errors.Path] = error.Path.ToString(); - } - - if (error.Locations is { Count: > 0 }) - { - tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; - tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; - } - - activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); - } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolate.Fusion.Diagnostics.csproj b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolate.Fusion.Diagnostics.csproj index 0d84beeb354..b1a23705284 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolate.Fusion.Diagnostics.csproj +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolate.Fusion.Diagnostics.csproj @@ -16,6 +16,7 @@ + diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs index 74ae97005eb..3c78f2644ff 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs @@ -1,3 +1,4 @@ +using HotChocolate.Diagnostics; using static HotChocolate.Fusion.Diagnostics.FusionActivityScopes; namespace HotChocolate.Fusion.Diagnostics; @@ -5,47 +6,30 @@ namespace HotChocolate.Fusion.Diagnostics; /// /// The Hot Chocolate Fusion instrumentation options. /// -public sealed class InstrumentationOptions +public sealed class InstrumentationOptions : InstrumentationOptionsBase { - /// - /// Specifies the request detail that shall be included into the tracing activities. - /// - public RequestDetails RequestDetails { get; set; } = RequestDetails.Default; - /// /// Specifies the activity scopes that shall be instrumented. /// public FusionActivityScopes Scopes { get; set; } = Default; - /// - /// Specifies if the parsed document shall be included into the tracing data. - /// - public bool IncludeDocument { get; set; } - - /// - /// Defines if the operation display name shall be included in the root activity. - /// - public bool RenameRootActivity { get; set; } - - internal bool IncludeRequestDetails => RequestDetails is not RequestDetails.None; - - internal bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; + internal override bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; - internal bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; + internal override bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; - internal bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; + internal override bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; - internal bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; + internal override bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; - internal bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; + internal override bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; - internal bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; + internal override bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; - internal bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; + internal override bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; internal bool SkipPlanOperation => (Scopes & PlanOperation) != PlanOperation; - internal bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; + internal override bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; internal bool SkipExecuteNodes => (Scopes & ExecuteNodes) != ExecuteNodes; } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/RequestDetails.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/RequestDetails.cs deleted file mode 100644 index dd05a951ba2..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/RequestDetails.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace HotChocolate.Fusion.Diagnostics; - -[Flags] -public enum RequestDetails -{ - None = 0, - Id = 1, - Hash = 2, - Operation = 4, - Variables = 8, - Extensions = 16, - Query = 32, - Default = Id | Hash | Operation | Extensions, - All = Id | Hash | Operation | Variables | Extensions | Query -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs deleted file mode 100644 index 6cc3844e0a5..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/SemanticConventions.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Collections.Frozen; -using HotChocolate.Language; - -namespace HotChocolate.Fusion.Diagnostics; - -internal static class SemanticConventions -{ - public static class Exception - { - public const string EventName = "exception"; - public const string Type = "exception.type"; - public const string Message = "exception.message"; - } - - public static class GraphQL - { - public static class Document - { - public const string Id = "graphql.document.id"; - public const string Hash = "graphql.document.hash"; - public const string Body = "graphql.document.body"; - public const string Valid = "graphql.document.valid"; - } - - public static class Operation - { - public const string Id = "graphql.operation.id"; - public const string Name = "graphql.operation.name"; - public const string Type = "graphql.operation.type"; - - public static FrozenDictionary TypeValues { get; } = - new Dictionary - { - [OperationType.Query] = "query", - [OperationType.Mutation] = "mutation", - [OperationType.Subscription] = "subscription" - }.ToFrozenDictionary(); - - public static class Step - { - public const string Id = "graphql.operation.step.id"; - public const string Kind = "graphql.operation.step.kind"; - - public static class Plan - { - public const string Id = "graphql.operation.step.plan.id"; - } - } - } - - public static class Processing - { - public const string Type = "graphql.processing.type"; - - public static class TypeValues - { - public const string Parse = "parse"; - public const string Validate = "validate"; - public const string VariableCoercion = "variable_coercion"; - public const string Plan = "plan"; - public const string Execute = "execute"; - public const string StepExecute = "step_execute"; - } - } - - public static class Source - { - public const string Name = "graphql.source.name"; - public const string Id = "graphql.source.id"; - - public static class Operation - { - public const string Name = "graphql.source.operation.name"; - public const string Kind = "graphql.source.operation.kind"; - public const string Hash = "graphql.source.operation.hash"; - } - } - - public static class Errors - { - public const string Count = "graphql.errors.count"; - public const string Path = "graphql.error.path"; - - public static class Location - { - public const string Column = "graphql.error.location.column"; - public const string Line = "graphql.error.location.line"; - } - } - - public static class Http - { - public const string Kind = "graphql.http.kind"; - - public static class Request - { - public const string Type = "graphql.http.request.type"; - public const string QueryId = "graphql.http.request.query.id"; - public const string QueryHash = "graphql.http.request.query.hash"; - public const string QueryBody = "graphql.http.request.query.body"; - public const string OperationName = "graphql.http.request.operation"; - public const string Operations = "graphql.http.request.operations"; - public const string Variables = "graphql.http.request.variables"; - public const string Extensions = "graphql.http.request.extensions"; - } - } - - public static class Schema - { - public const string Name = "graphql.schema.name"; - public const string IsDefault = "graphql.schema.isDefault"; - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/HotChocolate.Fusion.Diagnostics.Tests.csproj b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/HotChocolate.Fusion.Diagnostics.Tests.csproj index 528f2642747..cb0ec4301ce 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/HotChocolate.Fusion.Diagnostics.Tests.csproj +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/HotChocolate.Fusion.Diagnostics.Tests.csproj @@ -7,6 +7,7 @@ + diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index f5d49d69610..88927005292 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -1,3 +1,4 @@ +using HotChocolate.Diagnostics; using HotChocolate.Transport.Http; using Microsoft.Extensions.DependencyInjection; using static HotChocolate.Fusion.Diagnostics.ActivityTestHelper; @@ -10,7 +11,7 @@ public class ServerInstrumentationTests : FusionTestBase { private static readonly Uri s_url = new("http://localhost:5000/graphql"); - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Single_Request_Default() { using (CaptureActivities(out var activities)) @@ -36,7 +37,7 @@ public async Task Http_Post_Single_Request_Default() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Single_Request() { using (CaptureActivities(out var activities)) @@ -63,7 +64,7 @@ public async Task Http_Post_Single_Request() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Get_Single_Request() { using (CaptureActivities(out var activities)) @@ -90,7 +91,7 @@ public async Task Http_Get_Single_Request() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Variables_Are_Not_Automatically_Added_To_Activities() { using (CaptureActivities(out var activities)) @@ -123,7 +124,7 @@ public async Task Http_Post_Variables_Are_Not_Automatically_Added_To_Activities( } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Add_Variables_To_Http_Activity() { using (CaptureActivities(out var activities)) @@ -160,7 +161,7 @@ public async Task Http_Post_Add_Variables_To_Http_Activity() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Add_Query_To_Http_Activity() { using (CaptureActivities(out var activities)) @@ -197,7 +198,7 @@ public async Task Http_Post_Add_Query_To_Http_Activity() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_With_Extensions_Map() { using (CaptureActivities(out var activities)) @@ -231,7 +232,7 @@ public async Task Http_Post_With_Extensions_Map() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Get_SDL_Download() { using (CaptureActivities(out var activities)) @@ -288,7 +289,7 @@ public async Task Http_Post_Capture_Deferred_Response() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Http_Post_Parser_Error() { using (CaptureActivities(out var activities)) @@ -327,7 +328,7 @@ public async Task Http_Post_Parser_Error() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Parsing_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out var activities)) @@ -359,7 +360,7 @@ public async Task Parsing_Error_When_Rename_Root_Is_Activated() } } - [Fact(Skip = "This is flaky")] + [Fact] public async Task Validation_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out var activities)) diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index d3e100c155c..ee893fc8dde 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -33,6 +37,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +58,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -65,6 +77,22 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -77,6 +105,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -90,13 +134,45 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "SayHelloOperation_6af18618_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 86e0de8de0f..4e83d14771f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "5f75eb886568e255310bed3eb3e1f7f1c91f1a22f71ac7c36f00d8df27400d8e" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -37,6 +41,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "OK" @@ -50,8 +62,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -69,6 +81,22 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "OK" @@ -81,6 +109,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Error", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "ERROR" @@ -94,13 +138,45 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "5f75eb886568e255310bed3eb3e1f7f1c91f1a22f71ac7c36f00d8df27400d8e" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "SayHelloOperation_851fb754_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "1b35e9142c2e8235f31d2b3ae0de3d2ba54692a7aa6481803c3841fd135f4c4c" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index 158121c23ce..b8576551dd2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -29,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "803df9346db185e9dc0b22dd3909aa70" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +54,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap index 85a94d3f7b2..d23ac2e0027 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "91d3f369067488892e5c81c27598c0d43b5ecfe5ad824925965ac60c70351919" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "91d3f369067488892e5c81c27598c0d43b5ecfe5ad824925965ac60c70351919" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_452ea802_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "fe5043810b215e414a23ad906fe02c57ac0adb87cbef5e925297ea3922dea294" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap index 0ed0deda928..af67dc00f2a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "155189958e55686347a7f921c0f7a1ef143f829f5b116365a297651606d5703f" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "GetA" @@ -29,6 +33,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" @@ -42,8 +54,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -61,6 +73,22 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" @@ -73,6 +101,22 @@ "DisplayName": "Execute Operation GetA", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" @@ -86,13 +130,45 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "155189958e55686347a7f921c0f7a1ef143f829f5b116365a297651606d5703f" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "GetA_cee0e293_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "dfd8c2288a98a5ade0836a3fb80cd00374fc36f2a66aaa71e170afca30b22517" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap index f4870f0ca44..cb703997b7f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "8b26a2633c9b68833461d6b2249f54600493dfc632399469d5c108e79410ca7b" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "8b26a2633c9b68833461d6b2249f54600493dfc632399469d5c108e79410ca7b" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_2e55fbe1_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "8826181dc487d072381743cb4417bc07e557ea4fdb3163add5c0fb664febfe31" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap index 1af065e2ac9..0a0e356ff68 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "1c020b5562fde1e7673b1f4750bdf6d35f2789819d03bb6b5d088bf445231501" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "1c020b5562fde1e7673b1f4750bdf6d35f2789819d03bb6b5d088bf445231501" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_a5f924bb_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "78fb01a8827e80543966f0f5d34e2dbe7283145ac5de0ce2842af14783f9caeb" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index b58f55ac83f..8095911f16c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.operation.name", "Value": "SayHelloOperation" @@ -29,6 +33,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -42,8 +54,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -61,6 +73,22 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -73,6 +101,22 @@ "DisplayName": "Execute Operation SayHelloOperation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" @@ -86,13 +130,45 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "SayHelloOperation_6af18618_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index 725e9a44a05..070b1c738ca 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -29,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "bb1d246465341a97bdc727d6cd8ead5c" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +54,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 88d2aba887c..b72c0c8d883 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -17,6 +17,10 @@ "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.body", "Value": "{\n sayHello\n}" @@ -33,6 +37,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -46,8 +58,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -65,6 +77,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -77,6 +101,18 @@ "DisplayName": "Execute Operation", "Status": "Error", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "ERROR" @@ -90,13 +126,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index fa4b3838f11..96f6b26a2fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "073bf7696c078e52587c88890ef21bbe" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "073bf7696c078e52587c88890ef21bbe" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "073bf7696c078e52587c88890ef21bbe" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "073bf7696c078e52587c88890ef21bbe" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_073bf769_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "b6db85f78e867baa06bf8b4f45ed381a2b6bc9f7abd15948f0bfff0967fbc308" + }, { "Key": "otel.status_code", "Value": "OK" @@ -102,13 +166,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "073bf7696c078e52587c88890ef21bbe" + }, + { + "Key": "graphql.source.name", "Value": "b" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_073bf769_2" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 5ecaa32bc36..1e218dd9ef1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -6,8 +6,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -25,6 +25,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,13 +50,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index c2b6eb5d039..73d3b8606dd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index c2b6eb5d039..73d3b8606dd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -16,6 +16,10 @@ { "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [], @@ -25,6 +29,14 @@ "DisplayName": "Parse Document", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -38,8 +50,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -57,6 +69,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -69,6 +93,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -82,13 +118,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index bb203ba5752..5ba02d71030 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -82,6 +86,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -94,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -107,13 +135,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 1f787a37f1b..90ea5e85118 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -82,6 +86,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -94,6 +110,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -106,6 +134,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -119,13 +159,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 46c0ade8f33..a4ce74cf4f8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -48,6 +48,10 @@ { "Key": "graphql.operation.id", "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -67,8 +71,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -86,6 +90,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -98,6 +114,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -110,6 +138,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -123,13 +163,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 268c3ad7374..23ea2424c7f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -82,6 +86,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -94,6 +110,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -107,13 +135,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index 86acae93e01..577ac07d037 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -24,6 +24,10 @@ { "Key": "graphql.operation.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -55,8 +59,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -74,6 +78,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" @@ -87,13 +103,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 1f787a37f1b..90ea5e85118 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -44,6 +44,10 @@ { "Key": "graphql.operation.id", "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -63,8 +67,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -82,6 +86,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -94,6 +110,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -106,6 +134,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -119,13 +159,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 2baf19b2df6..cca194af26d 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -48,6 +48,10 @@ { "Key": "graphql.operation.id", "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [ @@ -67,8 +71,8 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", @@ -86,6 +90,18 @@ "DisplayName": "Plan Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -98,6 +114,18 @@ "DisplayName": "Coerce Variable", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -110,6 +138,18 @@ "DisplayName": "Execute Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, { "Key": "otel.status_code", "Value": "OK" @@ -123,13 +163,41 @@ "Status": "Ok", "tags": [ { - "Key": "graphql.fusion.node.type", + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.step.kind", "Value": "Operation" }, { - "Key": "graphql.fusion.node.schema", + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.source.name", "Value": "a" }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index a8e45a9ef6d..3c55bf0c232 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -58,8 +58,8 @@ "Value": "ERROR" }, { - "Key": "graphql.document.id", - "Value": "346f68539881f0624dca2927281d1a2f" + "Key": "graphql.processing.type", + "Value": "validate" }, { "Key": "graphql.document.hash", From fffbcd27e0e9c326c12635e52894cbf26891eda4 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 10:42:01 +0000 Subject: [PATCH 03/37] wip: More consolidation --- .../Diagnostics.Core/ActivityEnricherBase.cs | 97 +++++++++++++++++++ .../src/Diagnostics/ActivityEnricher.cs | 88 ++++------------- .../FusionActivityEnricher.cs | 89 ++++------------- 3 files changed, 131 insertions(+), 143 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index fc8046b74e2..7a37b0b1e3e 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -327,6 +327,103 @@ public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Act activity.DisplayName = "Analyze Operation Complexity"; } + protected void EnrichExecuteRequestCore( + RequestContext context, + Activity activity, + string? operationDisplayName, + object? operationId, + OperationType? operationType, + string? operationName) + { + if (_options.RenameRootActivity && operationDisplayName is not null) + { + UpdateRootActivityName(activity, operationDisplayName); + } + + var documentInfo = context.OperationDocumentInfo; + + activity.DisplayName = operationDisplayName ?? "Execute Request"; + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); + activity.SetTag(GraphQL.Operation.Id, operationId); + + if (operationType is not null) + { + activity.SetTag( + GraphQL.Operation.Type, + GraphQL.Operation.TypeValues[operationType.Value]); + + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + } + + if (_options.IncludeDocument && documentInfo.Document is not null) + { + activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); + } + } + + protected string BuildOperationDisplayName( + OperationType operationType, + string? operationName, + int selectionCount, + IEnumerable selectionResponseNames) + { + var displayName = StringBuilderPool.Get(); + + try + { + displayName.Append('{'); + displayName.Append(' '); + + var count = 0; + foreach (var name in selectionResponseNames) + { + if (count >= 3) + { + break; + } + + if (displayName.Length > 2) + { + displayName.Append(' '); + } + + displayName.Append(name); + count++; + } + + if (selectionCount > 3) + { + displayName.Append(' '); + displayName.Append('.'); + displayName.Append('.'); + displayName.Append('.'); + } + + displayName.Append(' '); + displayName.Append('}'); + + if (operationName is not null) + { + displayName.Insert(0, ' '); + displayName.Insert(0, operationName); + } + + displayName.Insert(0, ' '); + displayName.Insert(0, operationType.ToString().ToLowerInvariant()); + + return displayName.ToString(); + } + finally + { + StringBuilderPool.Return(displayName); + } + } + protected void UpdateRootActivityName(Activity activity, string displayName) { var current = activity; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 7fcde2d252c..91f3844790b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -36,36 +36,15 @@ protected ActivityEnricher( public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - var documentInfo = context.OperationDocumentInfo; var operationDisplayName = CreateOperationDisplayName(context, operation); - if (_options.RenameRootActivity && operationDisplayName is not null) - { - UpdateRootActivityName(activity, operationDisplayName); - } - - activity.DisplayName = operationDisplayName ?? "Execute Request"; - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); - activity.SetTag(GraphQL.Operation.Id, operation?.Id); - - if (operation is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operation.Kind]); - - if (!string.IsNullOrEmpty(operation.Name)) - { - activity.SetTag(GraphQL.Operation.Name, operation.Name); - } - } - - if (_options.IncludeDocument && documentInfo.Document is not null) - { - activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); - } + EnrichExecuteRequestCore( + context, + activity, + operationDisplayName, + operation?.Id, + operation?.Kind, + operation?.Name); if (context.Result is OperationResult result) { @@ -81,52 +60,19 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi return null; } - var displayName = StringBuilderPool.Get(); + var selections = operation.RootSelectionSet.Selections; + var names = new string[selections.Length]; - try + for (var i = 0; i < selections.Length; i++) { - var rootSelectionSet = operation.RootSelectionSet; - var selectionCount = rootSelectionSet.Selections.Length; - - displayName.Append('{'); - displayName.Append(' '); - - foreach (var selection in rootSelectionSet.Selections[..Math.Min(3, selectionCount)]) - { - if (displayName.Length > 2) - { - displayName.Append(' '); - } - - displayName.Append(selection.ResponseName); - } - - if (rootSelectionSet.Selections.Length > 3) - { - displayName.Append(' '); - displayName.Append('.'); - displayName.Append('.'); - displayName.Append('.'); - } - - displayName.Append(' '); - displayName.Append('}'); - - if (operation.Name is { } name) - { - displayName.Insert(0, ' '); - displayName.Insert(0, name); - } - - displayName.Insert(0, ' '); - displayName.Insert(0, operation.Definition.Operation.ToString().ToLowerInvariant()); - - return displayName.ToString(); - } - finally - { - StringBuilderPool.Return(displayName); + names[i] = selections[i].ResponseName; } + + return BuildOperationDisplayName( + operation.Definition.Operation, + operation.Name, + names.Length, + names); } public virtual void EnrichParseDocument(RequestContext context, Activity activity) diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index 33ab7ccf374..1af5021959a 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -5,7 +5,6 @@ using HotChocolate.Execution; using HotChocolate.Fusion.Execution; using HotChocolate.Fusion.Execution.Nodes; -using HotChocolate.Language.Utilities; using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; @@ -36,36 +35,15 @@ protected FusionActivityEnricher( public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); - var documentInfo = context.OperationDocumentInfo; var operationDisplayName = CreateOperationDisplayName(context, plan); - if (_options.RenameRootActivity && operationDisplayName is not null) - { - UpdateRootActivityName(activity, operationDisplayName); - } - - activity.DisplayName = operationDisplayName ?? "Execute Request"; - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); - activity.SetTag(GraphQL.Operation.Id, plan?.Id); - - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - } - - if (_options.IncludeDocument && documentInfo.Document is not null) - { - activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); - } + EnrichExecuteRequestCore( + context, + activity, + operationDisplayName, + plan?.Id, + plan?.Operation.Definition.Operation, + plan?.OperationName); if (context.Result is OperationResult { Errors: [_, ..] errors }) { @@ -80,52 +58,19 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi return null; } - var displayName = StringBuilderPool.Get(); - - try - { - var rootSelectionSet = plan.Operation.RootSelectionSet; - var selectionCount = rootSelectionSet.Selections.Length; - - displayName.Append('{'); - displayName.Append(' '); - - foreach (var selection in rootSelectionSet.Selections[..Math.Min(3, selectionCount)]) - { - if (displayName.Length > 2) - { - displayName.Append(' '); - } - - displayName.Append(selection.ResponseName); - } - - if (rootSelectionSet.Selections.Length > 3) - { - displayName.Append(' '); - displayName.Append('.'); - displayName.Append('.'); - displayName.Append('.'); - } - - displayName.Append(' '); - displayName.Append('}'); + var selections = plan.Operation.RootSelectionSet.Selections; + var names = new string[selections.Length]; - if (plan.OperationName is { } name) - { - displayName.Insert(0, ' '); - displayName.Insert(0, name); - } - - displayName.Insert(0, ' '); - displayName.Insert(0, plan.Operation.Definition.Operation.ToString().ToLowerInvariant()); - - return displayName.ToString(); - } - finally + for (var i = 0; i < selections.Length; i++) { - StringBuilderPool.Return(displayName); + names[i] = selections[i].ResponseName; } + + return BuildOperationDisplayName( + plan.Operation.Definition.Operation, + plan.OperationName, + names.Length, + names); } public virtual void EnrichParseDocument(RequestContext context, Activity activity) From 11ae4a6740a8a3b60465c94ffdbe14c736eb9cac Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:42:54 +0100 Subject: [PATCH 04/37] Cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 191 +++++++---- .../Diagnostics.Core/SemanticConventions.cs | 22 ++ .../src/Diagnostics/ActivityEnricher.cs | 177 ++-------- .../FusionActivityEnricher.cs | 313 +++++------------- ...yFusionExecutionDiagnosticEventListener.cs | 2 +- .../Scopes/ExecuteOperationBatchNodeScope.cs | 2 +- ...ggregateFusionExecutionDiagnosticEvents.cs | 2 +- .../FusionExecutionDiagnosticEventListener.cs | 2 +- .../IFusionExecutionDiagnosticEvents.cs | 2 +- ...onTests.Allow_Document_To_Be_Captured.snap | 2 +- ...r_Error_That_Deletes_The_Whole_Result.snap | 2 +- ...e_Operation_Display_Name_With_1_Field.snap | 2 +- ...tion_Display_Name_With_1_Field_And_Op.snap | 2 +- ...e_Operation_Display_Name_With_3_Field.snap | 2 +- ...e_Operation_Display_Name_With_4_Field.snap | 2 +- ...peration_Name_Is_Used_As_Request_Name.snap | 2 +- ...onTests.Source_Schema_Transport_Error.snap | 2 +- ...ents_Of_A_Query_With_Multiple_Sources.snap | 4 +- ...rack_Events_Of_A_Simple_Query_Default.snap | 2 +- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 2 +- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 2 +- ...entationTests.Http_Get_Single_Request.snap | 2 +- ....Http_Post_Add_Query_To_Http_Activity.snap | 2 +- ...p_Post_Add_Variables_To_Http_Activity.snap | 2 +- ...ntationTests.Http_Post_Single_Request.snap | 2 +- ...ests.Http_Post_Single_Request_Default.snap | 2 +- ...Not_Automatically_Added_To_Activities.snap | 2 +- ...onTests.Http_Post_With_Extensions_Map.snap | 2 +- 28 files changed, 305 insertions(+), 448 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 7a37b0b1e3e..ccf42c8e68a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -18,23 +18,16 @@ namespace HotChocolate.Diagnostics; /// Base class for activity enrichers that provides shared enrichment logic /// for HTTP request handling, error handling, and common span enrichment. /// -public abstract class ActivityEnricherBase +public abstract class ActivityEnricherBase( + ObjectPool stringBuilderPool, + InstrumentationOptionsBase options) { - private readonly InstrumentationOptionsBase _options; private readonly ConditionalWeakTable _queryCache = []; - protected ActivityEnricherBase( - ObjectPool stringBuilderPool, - InstrumentationOptionsBase options) - { - StringBuilderPool = stringBuilderPool; - _options = options; - } - /// /// Gets the pool used by this enricher. /// - protected ObjectPool StringBuilderPool { get; } + protected ObjectPool StringBuilderPool { get; } = stringBuilderPool; public virtual void EnrichExecuteHttpRequest( HttpContext context, @@ -57,7 +50,7 @@ public virtual void EnrichExecuteHttpRequest( break; } - if (_options.RenameRootActivity) + if (options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } @@ -82,22 +75,22 @@ public virtual void EnrichSingleRequest( GraphQLRequest request, Activity activity) { - activity.SetTag(GraphQL.Http.Request.Type, "single"); + activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Single); if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) { if (!_queryCache.TryGetValue(request.Document, out var query)) { @@ -109,19 +102,19 @@ public virtual void EnrichSingleRequest( } if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); } if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { EnrichRequestVariables(context, request, request.Variables, activity); } if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) { EnrichRequestExtensions(context, request, request.Extensions, activity); } @@ -132,44 +125,44 @@ public virtual void EnrichBatchRequest( IReadOnlyList batch, Activity activity) { - activity.SetTag(GraphQL.Http.Request.Type, "batch"); + activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Batch); for (var i = 0; i < batch.Count; i++) { var request = batch[i]; if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - activity.SetTag($"graphql.http.request[{i}].query.id", request.DocumentId.Value); + activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryId(i), request.DocumentId.Value); } if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - activity.SetTag($"graphql.http.request[{i}].query.hash", request.DocumentHash.Value); + activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryHash(i), request.DocumentHash.Value); } if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) { - activity.SetTag($"graphql.http.request[{i}].query.body", request.Document.Print()); + activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryBody(i), request.Document.Print()); } if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { - activity.SetTag($"graphql.http.request[{i}].operation", request.OperationName); + activity.SetTag(GraphQL.Http.Request.BatchRequest.OperationName(i), request.OperationName); } if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { EnrichBatchVariables(context, request, request.Variables, i, activity); } if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) { EnrichBatchExtensions(context, request, request.Extensions, i, activity); } @@ -182,40 +175,40 @@ public virtual void EnrichOperationBatchRequest( IReadOnlyList operations, Activity activity) { - activity.SetTag(GraphQL.Http.Request.Type, "operationBatch"); + activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.OperationBatch); if (request.DocumentId is not null - && (_options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); } if (request.DocumentHash is not null - && (_options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); } if (request.Document is not null - && (_options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) { activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); } if (request.OperationName is not null - && (_options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) { activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); } if (request.Variables is not null - && (_options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) { EnrichRequestVariables(context, request, request.Variables, activity); } if (request.Extensions is not null - && (_options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) { EnrichRequestExtensions(context, request, request.Extensions, activity); } @@ -234,7 +227,9 @@ protected virtual void EnrichBatchVariables( JsonDocument variables, int index, Activity activity) - => activity.SetTag($"graphql.http.request[{index}].variables", variables.RootElement.ToString()); + => activity.SetTag( + GraphQL.Http.Request.BatchRequest.Variables(index), + variables.RootElement.ToString()); protected virtual void EnrichRequestExtensions( HttpContext context, @@ -264,7 +259,7 @@ protected virtual void EnrichBatchExtensions( try { activity.SetTag( - $"graphql.http.request[{index}].extensions", + GraphQL.Http.Request.BatchRequest.Extensions(index), extensions.RootElement.ToString()); } catch @@ -290,7 +285,7 @@ public virtual void EnrichParseHttpRequest(HttpContext context, Activity activit { activity.DisplayName = "Parse HTTP Request"; - if (_options.RenameRootActivity) + if (options.RenameRootActivity) { UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); } @@ -335,14 +330,14 @@ protected void EnrichExecuteRequestCore( OperationType? operationType, string? operationName) { - if (_options.RenameRootActivity && operationDisplayName is not null) + activity.DisplayName = operationDisplayName ?? "Execute Request"; + + if (options.RenameRootActivity && operationDisplayName is not null) { UpdateRootActivityName(activity, operationDisplayName); } var documentInfo = context.OperationDocumentInfo; - - activity.DisplayName = operationDisplayName ?? "Execute Request"; activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); @@ -360,10 +355,88 @@ protected void EnrichExecuteRequestCore( } } - if (_options.IncludeDocument && documentInfo.Document is not null) + if (options.IncludeDocument && documentInfo.Document is not null) { activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); } + + if (context.Result is OperationResult { Errors: [_, ..] errors }) + { + activity.SetTag(GraphQL.Errors.Count, errors.Count); + } + } + + protected void EnrichParseDocumentCore( + Activity activity, + OperationDefinitionNode? operationDefinition, + OperationDocumentInfo documentInfo) + { + activity.DisplayName = "Parse Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); + + if (options.RenameRootActivity) + { + UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); + } + + EnrichWithTags(activity, operationDefinition, documentInfo); + } + + protected void EnrichValidateDocumentCore( + Activity activity, + OperationDefinitionNode? operationDefinition, + OperationDocumentInfo documentInfo) + { + activity.DisplayName = "Validate Document"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); + + if (options.RenameRootActivity) + { + UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); + } + + EnrichWithTags(activity, operationDefinition, documentInfo); + } + + protected void EnrichCoerceVariablesCore( + Activity activity, + OperationDefinitionNode? operationDefinition, + OperationDocumentInfo documentInfo) + { + activity.DisplayName = "Coerce Variable"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); + + // TODO: This is new here. Why do we do this in other places? + if (options.RenameRootActivity) + { + UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); + } + + EnrichWithTags(activity, operationDefinition, documentInfo); + } + + protected static void EnrichWithTags( + Activity activity, + OperationDefinitionNode? operationDefinition, + OperationDocumentInfo documentInfo) + { + if (operationDefinition is not null) + { + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationDefinition.Operation]); + + var operationName = operationDefinition.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + } + + activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } } protected string BuildOperationDisplayName( @@ -424,21 +497,6 @@ protected string BuildOperationDisplayName( } } - protected void UpdateRootActivityName(Activity activity, string displayName) - { - var current = activity; - - while (current.Parent is not null) - { - current = current.Parent; - } - - if (current != activity) - { - current.DisplayName = CreateRootActivityName(activity, current, displayName); - } - } - protected virtual string CreateRootActivityName( Activity activity, Activity root, @@ -481,4 +539,19 @@ protected virtual void EnrichError(IError error, Activity activity) activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } + + private void UpdateRootActivityName(Activity activity, string displayName) + { + var current = activity; + + while (current.Parent is not null) + { + current = current.Parent; + } + + if (current != activity) + { + current.DisplayName = CreateRootActivityName(activity, current, displayName); + } + } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 86991705d45..3129e19cf41 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -138,6 +138,28 @@ public static class Request public const string Operations = "graphql.http.request.operations"; public const string Variables = "graphql.http.request.variables"; public const string Extensions = "graphql.http.request.extensions"; + + public static class Types + { + public const string Single = "single"; + public const string Batch = "batch"; + public const string OperationBatch = "operation-batch"; + } + + public static class BatchRequest + { + public static string QueryId(int index) => $"graphql.http.request[{index}].query.id"; + + public static string QueryHash(int index) => $"graphql.http.request[{index}].query.hash"; + + public static string QueryBody(int index) => $"graphql.http.request[{index}].query.body"; + + public static string OperationName(int index) => $"graphql.http.request[{index}].operation"; + + public static string Variables(int index) => $"graphql.http.request[{index}].variables"; + + public static string Extensions(int index) => $"graphql.http.request[{index}].extensions"; + } } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 91f3844790b..3e586ba6467 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -4,7 +4,6 @@ using GreenDonut; using HotChocolate.Execution; using HotChocolate.Execution.Processing; -using HotChocolate.Language.Utilities; using HotChocolate.Resolvers; using HotChocolate.Types; using static HotChocolate.Diagnostics.SemanticConventions; @@ -16,23 +15,10 @@ namespace HotChocolate.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class ActivityEnricher : ActivityEnricherBase +public class ActivityEnricher( + ObjectPool stringBuilderPool, + InstrumentationOptions options) : ActivityEnricherBase(stringBuilderPool, options) { - private readonly InstrumentationOptions _options; - - /// - /// Initializes a new instance of . - /// - /// - /// - protected ActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) - : base(stringBuilderPool, options) - { - _options = options; - } - public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); @@ -45,133 +31,38 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi operation?.Id, operation?.Kind, operation?.Name); - - if (context.Result is OperationResult result) - { - var errorCount = result.Errors.Count; - activity.SetTag(GraphQL.Errors.Count, errorCount); - } - } - - protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) - { - if (operation is null) - { - return null; - } - - var selections = operation.RootSelectionSet.Selections; - var names = new string[selections.Length]; - - for (var i = 0; i < selections.Length; i++) - { - names[i] = selections[i].ResponseName; - } - - return BuildOperationDisplayName( - operation.Definition.Operation, - operation.Name, - names.Length, - names); } public virtual void EnrichParseDocument(RequestContext context, Activity activity) { - activity.DisplayName = "Parse Document"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - context.TryGetOperation(out var operation); - if (operation is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operation.Kind]); - - if (!string.IsNullOrEmpty(operation.Name)) - { - activity.SetTag(GraphQL.Operation.Name, operation.Name); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichParseDocumentCore(activity, operation?.Definition, context.OperationDocumentInfo); } public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { - activity.DisplayName = "Validate Document"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - context.TryGetOperation(out var operation); - if (operation is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operation.Kind]); - - if (!string.IsNullOrEmpty(operation.Name)) - { - activity.SetTag(GraphQL.Operation.Name, operation.Name); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichValidateDocumentCore(activity, operation?.Definition, context.OperationDocumentInfo); } public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { - activity.DisplayName = "Coerce Variable"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - context.TryGetOperation(out var operation); - if (operation is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operation.Kind]); - - if (!string.IsNullOrEmpty(operation.Name)) - { - activity.SetTag(GraphQL.Operation.Name, operation.Name); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichCoerceVariablesCore(activity, operation?.Definition, context.OperationDocumentInfo); } public virtual void EnrichCompileOperation(RequestContext context, Activity activity) { + context.TryGetOperation(out var operation); + activity.DisplayName = "Compile Operation"; + // TODO: Not sure if plan is supposed to be used like this + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); + + EnrichWithTags(activity, operation?.Definition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) @@ -184,25 +75,7 @@ public virtual void EnrichExecuteOperation(RequestContext context, Activity acti activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - if (operation is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operation.Kind]); - - if (!string.IsNullOrEmpty(operation.Name)) - { - activity.SetTag(GraphQL.Operation.Name, operation.Name); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichWithTags(activity, operation?.Definition, context.OperationDocumentInfo); } public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity activity) @@ -292,10 +165,32 @@ public virtual void EnrichDataLoaderBatch( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderBatch); activity.SetTag(GraphQL.DataLoader.Batch.Size, keys.Count); - if (_options.IncludeDataLoaderKeys) + if (options.IncludeDataLoaderKeys) { var temp = keys.Select(t => t.ToString()).ToArray(); activity.SetTag(GraphQL.DataLoader.Batch.Keys, temp); } } + + protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) + { + if (operation is null) + { + return null; + } + + var selections = operation.RootSelectionSet.Selections; + var names = new string[selections.Length]; + + for (var i = 0; i < selections.Length; i++) + { + names[i] = selections[i].ResponseName; + } + + return BuildOperationDisplayName( + operation.Definition.Operation, + operation.Name, + names.Length, + names); + } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index 1af5021959a..c92b18962e0 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -1,3 +1,4 @@ +using System.Collections.Frozen; using System.Diagnostics; using System.Text; using Microsoft.Extensions.ObjectPool; @@ -15,22 +16,18 @@ namespace HotChocolate.Fusion.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class FusionActivityEnricher : ActivityEnricherBase +public class FusionActivityEnricher( + ObjectPool stringBuilderPool, + InstrumentationOptions options) : ActivityEnricherBase(stringBuilderPool, options) { - private readonly InstrumentationOptions _options; - - /// - /// Initializes a new instance of . - /// - /// - /// - protected FusionActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) - : base(stringBuilderPool, options) - { - _options = options; - } + private static FrozenDictionary KindValues { get; } = + new Dictionary + { + [ExecutionNodeType.Operation] = "operation", + [ExecutionNodeType.OperationBatch] = "operation-batch", + [ExecutionNodeType.Introspection] = "introspection", + [ExecutionNodeType.Node] = "node" + }.ToFrozenDictionary(); public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { @@ -44,150 +41,37 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi plan?.Id, plan?.Operation.Definition.Operation, plan?.OperationName); - - if (context.Result is OperationResult { Errors: [_, ..] errors }) - { - activity.SetTag(GraphQL.Errors.Count, errors.Count); - } - } - - protected virtual string? CreateOperationDisplayName(RequestContext context, OperationPlan? plan) - { - if (plan is null) - { - return null; - } - - var selections = plan.Operation.RootSelectionSet.Selections; - var names = new string[selections.Length]; - - for (var i = 0; i < selections.Length; i++) - { - names[i] = selections[i].ResponseName; - } - - return BuildOperationDisplayName( - plan.Operation.Definition.Operation, - plan.OperationName, - names.Length, - names); } public virtual void EnrichParseDocument(RequestContext context, Activity activity) { - activity.DisplayName = "Parse Document"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - var plan = context.GetOperationPlan(); - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichParseDocumentCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); } public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { - activity.DisplayName = "Validate Document"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - - if (_options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - var plan = context.GetOperationPlan(); - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichValidateDocumentCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); } public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { - activity.DisplayName = "Coerce Variable"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - var plan = context.GetOperationPlan(); - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichCoerceVariablesCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); } public virtual void EnrichPlanOperationScope(RequestContext context, Activity activity) { - activity.DisplayName = "Plan Operation"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - var plan = context.GetOperationPlan(); - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } + activity.DisplayName = "Plan Operation"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - } + EnrichWithTags(activity, plan?.Operation.Definition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) @@ -200,25 +84,7 @@ public virtual void EnrichExecuteOperation(RequestContext context, Activity acti activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - if (plan is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - } - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + EnrichWithTags(activity, plan?.Operation.Definition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperationNode( @@ -228,76 +94,33 @@ public virtual void EnrichExecuteOperationNode( Activity activity) { activity.DisplayName = $"Execute Operation Node ({schemaName})"; - - // Required activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - activity.SetTag(GraphQL.Operation.Step.Id, node.Id); - - // Recommended - activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); - activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); - - var plan = context.OperationPlan; - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - - activity.SetTag(GraphQL.Document.Hash, context.RequestContext.OperationDocumentInfo.Hash.Value); - - // Opt-in - source schema info - activity.SetTag(GraphQL.Source.Name, schemaName); - - // Opt-in - source operation info - var operation = node.Operation; - activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); - activity.SetTag(GraphQL.Source.Operation.Kind, operation.Type.ToString().ToLowerInvariant()); - activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); + EnrichOperationWithTags( + activity, + context.OperationPlan, + node, + node.Operation, + context.RequestContext.OperationDocumentInfo, + schemaName); } public virtual void EnrichExecuteOperationBatchNode( OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName, Activity activity) { activity.DisplayName = $"Execute Operation Batch Node ({schemaName})"; - - // Required activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - activity.SetTag(GraphQL.Operation.Step.Id, node.Id); - - // Recommended - activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); - activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); - - var plan = context.OperationPlan; - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - activity.SetTag(GraphQL.Document.Hash, context.RequestContext.OperationDocumentInfo.Hash.Value); - - // Opt-in - source schema info - activity.SetTag(GraphQL.Source.Name, schemaName); - - // Opt-in - source operation info (if available) - if (node is OperationBatchExecutionNode batchNode) - { - var operation = batchNode.Operation; - activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); - activity.SetTag(GraphQL.Source.Operation.Kind, operation.Type.ToString().ToLowerInvariant()); - activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); - } + EnrichOperationWithTags( + activity, + context.OperationPlan, + node, + node.Operation, + context.RequestContext.OperationDocumentInfo, + schemaName); } public virtual void EnrichExecuteNodeFieldNode( @@ -306,14 +129,9 @@ public virtual void EnrichExecuteNodeFieldNode( Activity activity) { activity.DisplayName = "Execute Node Field Node"; - - // Required activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - activity.SetTag(GraphQL.Operation.Step.Id, node.Id); - // Recommended - activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); - activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); + EnrichNodeWithTags(activity, node, context.OperationPlan); } public virtual void EnrichExecuteIntrospectionNode( @@ -322,14 +140,9 @@ public virtual void EnrichExecuteIntrospectionNode( Activity activity) { activity.DisplayName = "Execute Introspection Node"; - - // Required activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - activity.SetTag(GraphQL.Operation.Step.Id, node.Id); - // Recommended - activity.SetTag(GraphQL.Operation.Step.Kind, node.Type.ToString()); - activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); + EnrichNodeWithTags(activity, node, context.OperationPlan); } public virtual void EnrichExecutionNodeError( @@ -346,4 +159,58 @@ public virtual void EnrichSourceSchemaError( System.Exception error, Activity activity) => activity.RecordException(error); + + protected virtual string? CreateOperationDisplayName(RequestContext context, OperationPlan? plan) + { + if (plan is null) + { + return null; + } + + var selections = plan.Operation.RootSelectionSet.Selections; + var names = new string[selections.Length]; + + for (var i = 0; i < selections.Length; i++) + { + names[i] = selections[i].ResponseName; + } + + return BuildOperationDisplayName( + plan.Operation.Definition.Operation, + plan.OperationName, + names.Length, + names); + } + + private static void EnrichOperationWithTags( + Activity activity, + OperationPlan plan, + ExecutionNode node, + OperationSourceText operation, + OperationDocumentInfo operationDocumentInfo, + string schemaName) + { + EnrichNodeWithTags(activity, node, plan); + + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); + + if (!string.IsNullOrEmpty(plan.OperationName)) + { + activity.SetTag(GraphQL.Operation.Name, plan.OperationName); + } + + activity.SetTag(GraphQL.Document.Hash, operationDocumentInfo.Hash.Value); + + activity.SetTag(GraphQL.Source.Name, schemaName); + activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); + activity.SetTag(GraphQL.Source.Operation.Kind, GraphQL.Operation.TypeValues[operation.Type]); + activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); + } + + private static void EnrichNodeWithTags(Activity activity, ExecutionNode node, OperationPlan plan) + { + activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, plan.Id); + } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs index 985b74a2334..8a388692ca2 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs @@ -249,7 +249,7 @@ public override IDisposable ExecuteOperationNode( public override IDisposable ExecuteOperationBatchNode( OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName) { if (_options.SkipExecuteNodes) diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs index 1363edffea5..f9eac94abfd 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs @@ -8,7 +8,7 @@ namespace HotChocolate.Fusion.Diagnostics.Scopes; internal sealed class ExecuteOperationBatchNodeScope( FusionActivityEnricher enricher, OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName, Activity activity) : NodeScopeBase(enricher, context, activity) diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs index 2f81373196f..4012cf3643a 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs @@ -186,7 +186,7 @@ public IDisposable ExecuteOperationNode( public IDisposable ExecuteOperationBatchNode( OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName) { var scopes = new IDisposable[listeners.Length]; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs index f54cd83f3e2..a967a80f601 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs @@ -96,7 +96,7 @@ public virtual IDisposable ExecuteOperationNode( /// public virtual IDisposable ExecuteOperationBatchNode( OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName) => EmptyScope; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs index 56e50633fc0..f25cd9bfa6d 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs @@ -130,7 +130,7 @@ IDisposable ExecuteOperationNode( /// IDisposable ExecuteOperationBatchNode( OperationPlanContext context, - ExecutionNode node, + OperationBatchExecutionNode node, string schemaName); /// diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index ee893fc8dde..1834d40e920 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -139,7 +139,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 4e83d14771f..bc4611185af 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -143,7 +143,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap index d23ac2e0027..f8878620d6d 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap index af67dc00f2a..a3deebad311 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap @@ -135,7 +135,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap index cb703997b7f..5258c929fe8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap index 0a0e356ff68..d9ed8976b32 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index 8095911f16c..e8946f82a2b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -135,7 +135,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index b72c0c8d883..36a0581e3ac 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -131,7 +131,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 96f6b26a2fc..6aa950521fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", @@ -171,7 +171,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 1e218dd9ef1..eaab3f712e6 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -55,7 +55,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 73d3b8606dd..43d2bac42c5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 73d3b8606dd..43d2bac42c5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -123,7 +123,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 5ba02d71030..1c931da2361 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -140,7 +140,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 90ea5e85118..41eb9d6f6c9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -164,7 +164,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index a4ce74cf4f8..c48c8ffe928 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -168,7 +168,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 23ea2424c7f..5ab02fe57f4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -140,7 +140,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index 577ac07d037..b8d858c68be 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -108,7 +108,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 90ea5e85118..41eb9d6f6c9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -164,7 +164,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index cca194af26d..fe194a81538 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -168,7 +168,7 @@ }, { "Key": "graphql.operation.step.kind", - "Value": "Operation" + "Value": "operation" }, { "Key": "graphql.operation.step.plan.id", From 4460065645302afc6cbdd62f2c297eb209fac0db Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:53:30 +0100 Subject: [PATCH 05/37] Cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 6 +-- .../InstrumentationOptionsBase.cs | 21 +-------- .../src/Diagnostics.Core/RequestDetails.cs | 6 +-- .../src/Diagnostics/InstrumentationOptions.cs | 16 +++---- .../ActivityServerDiagnosticListener.cs | 46 ++++++++----------- .../ServerInstrumentationTests.cs | 2 +- ...onTests.Allow_document_to_be_captured.snap | 16 +++++++ ...r_error_that_deletes_the_whole_result.snap | 16 +++++++ ...e_operation_display_name_with_1_field.snap | 12 +++++ ...tion_display_name_with_1_field_and_op.snap | 16 +++++++ ...e_operation_display_name_with_3_field.snap | 12 +++++ ...e_operation_display_name_with_4_field.snap | 12 +++++ ...peration_name_is_used_as_request_name.snap | 16 +++++++ ...rack_events_of_a_simple_query_default.snap | 12 +++++ ...ack_events_of_a_simple_query_detailed.snap | 12 +++++ ...ts.Http_Get_SingleRequest_GetHeroName.snap | 12 +++++ ...s.Http_Post_SingleRequest_GetHeroName.snap | 12 +++++ ...ost_SingleRequest_GetHeroName_Default.snap | 12 +++++ ....Http_Post_add_query_to_http_activity.snap | 12 +++++ ...p_Post_add_variables_to_http_activity.snap | 12 +++++ ...s.Http_Post_capture_deferred_response.snap | 12 +++++ ...t_ensure_list_path_is_correctly_built.snap | 12 +++++ ...not_automatically_added_to_activities.snap | 12 +++++ ...onTests.Http_Post_with_extensions_map.snap | 12 +++++ ...agnosticsFusionGatewayBuilderExtensions.cs | 2 +- .../FusionActivityScopes.cs | 6 +-- .../InstrumentationOptions.cs | 20 ++++---- ...yFusionExecutionDiagnosticEventListener.cs | 8 ++-- ...FusionActivityServerDiagnosticListener.cs} | 35 +++++++------- .../ServerInstrumentationTests.cs | 2 +- 30 files changed, 303 insertions(+), 99 deletions(-) rename src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/{ActivityServerDiagnosticListener.cs => FusionActivityServerDiagnosticListener.cs} (75%) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index ccf42c8e68a..530c5ebbedf 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -102,7 +102,7 @@ public virtual void EnrichSingleRequest( } if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) { activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); } @@ -150,7 +150,7 @@ public virtual void EnrichBatchRequest( } if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) { activity.SetTag(GraphQL.Http.Request.BatchRequest.OperationName(i), request.OperationName); } @@ -196,7 +196,7 @@ public virtual void EnrichOperationBatchRequest( } if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.Operation) == RequestDetails.Operation) + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) { activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs index f5a0854d474..a1d1ec40803 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs @@ -1,12 +1,9 @@ namespace HotChocolate.Diagnostics; -/// -/// Base class for Hot Chocolate instrumentation options. -/// public abstract class InstrumentationOptionsBase { /// - /// Specifies the request detail that shall be included into the tracing activities. + /// Specifies the request details that shall be included into the tracing activities. /// public RequestDetails RequestDetails { get; set; } = RequestDetails.Default; @@ -21,20 +18,4 @@ public abstract class InstrumentationOptionsBase public bool RenameRootActivity { get; set; } internal bool IncludeRequestDetails => RequestDetails is not RequestDetails.None; - - internal abstract bool SkipExecuteHttpRequest { get; } - - internal abstract bool SkipParseHttpRequest { get; } - - internal abstract bool SkipFormatHttpResponse { get; } - - internal abstract bool SkipExecuteRequest { get; } - - internal abstract bool SkipParseDocument { get; } - - internal abstract bool SkipValidateDocument { get; } - - internal abstract bool SkipCoerceVariables { get; } - - internal abstract bool SkipExecuteOperation { get; } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs index 58a8e5d33e1..61169f93417 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs @@ -6,10 +6,10 @@ public enum RequestDetails None = 0, Id = 1, Hash = 2, - Operation = 4, + OperationName = 4, Variables = 8, Extensions = 16, Query = 32, - Default = Id | Hash | Operation | Extensions, - All = Id | Hash | Operation | Variables | Extensions | Query + Default = Id | Hash | OperationName | Extensions, + All = Id | Hash | OperationName | Variables | Extensions | Query } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs index 52815ef7aa2..1da0a36eb94 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/InstrumentationOptions.cs @@ -17,25 +17,25 @@ public sealed class InstrumentationOptions : InstrumentationOptionsBase /// public bool IncludeDataLoaderKeys { get; set; } - internal override bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; + internal bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; - internal override bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; + internal bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; - internal override bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; + internal bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; - internal override bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; + internal bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; - internal override bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; + internal bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; - internal override bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; + internal bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; internal bool SkipAnalyzeComplexity => (Scopes & AnalyzeComplexity) != AnalyzeComplexity; - internal override bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; + internal bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; internal bool SkipCompileOperation => (Scopes & CompileOperation) != CompileOperation; - internal override bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; + internal bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; internal bool SkipResolveFieldValue => (Scopes & ResolveFieldValue) != ResolveFieldValue; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs index 7f803428364..5a4705d3681 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs @@ -8,22 +8,14 @@ namespace HotChocolate.Diagnostics.Listeners; -internal sealed class ActivityServerDiagnosticListener : ServerDiagnosticEventListener +internal sealed class ActivityServerDiagnosticListener( + ActivityEnricher enricher, + InstrumentationOptions options) + : ServerDiagnosticEventListener { - private readonly InstrumentationOptions _options; - private readonly ActivityEnricher _enricher; - - public ActivityServerDiagnosticListener( - ActivityEnricher enricher, - InstrumentationOptions options) - { - _enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - _options = options ?? throw new ArgumentNullException(nameof(options)); - } - public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestKind kind) { - if (_options.SkipExecuteHttpRequest) + if (options.SkipExecuteHttpRequest) { return EmptyScope; } @@ -35,7 +27,7 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK return EmptyScope; } - _enricher.EnrichExecuteHttpRequest(context, kind, activity); + enricher.EnrichExecuteHttpRequest(context, kind, activity); activity.SetStatus(ActivityStatusCode.Ok); context.Items[HttpRequestActivity] = activity; @@ -44,19 +36,19 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK public override void StartSingleRequest(HttpContext context, GraphQLRequest request) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichSingleRequest(context, request, (Activity)activity!); + enricher.EnrichSingleRequest(context, request, (Activity)activity!); } } public override void StartBatchRequest(HttpContext context, IReadOnlyList batch) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichBatchRequest(context, batch, (Activity)activity!); + enricher.EnrichBatchRequest(context, batch, (Activity)activity!); } } @@ -65,10 +57,10 @@ public override void StartOperationBatchRequest( GraphQLRequest request, IReadOnlyList operations) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichOperationBatchRequest( + enricher.EnrichOperationBatchRequest( context, request, operations, @@ -81,7 +73,7 @@ public override void HttpRequestError(HttpContext context, IError error) if (context.Items.TryGetValue(HttpRequestActivity, out var value)) { var activity = (Activity)value!; - _enricher.EnrichHttpRequestError(context, error, activity); + enricher.EnrichHttpRequestError(context, error, activity); activity.SetStatus(Status.Error); } } @@ -91,14 +83,14 @@ public override void HttpRequestError(HttpContext context, Exception exception) if (context.Items.TryGetValue(HttpRequestActivity, out var value)) { var activity = (Activity)value!; - _enricher.EnrichHttpRequestError(context, exception, activity); + enricher.EnrichHttpRequestError(context, exception, activity); activity.SetStatus(Status.Error); } } public override IDisposable ParseHttpRequest(HttpContext context) { - if (_options.SkipParseHttpRequest) + if (options.SkipParseHttpRequest) { return EmptyScope; } @@ -110,7 +102,7 @@ public override IDisposable ParseHttpRequest(HttpContext context) return EmptyScope; } - _enricher.EnrichParseHttpRequest(context, activity); + enricher.EnrichParseHttpRequest(context, activity); activity.SetStatus(Status.Ok); activity.SetStatus(ActivityStatusCode.Ok); context.Items[ParseHttpRequestActivity] = activity; @@ -126,7 +118,7 @@ public override void ParserErrors(HttpContext context, IReadOnlyList err foreach (var error in errors) { - _enricher.EnrichParserErrors(context, error, activity); + enricher.EnrichParserErrors(context, error, activity); } activity.SetStatus(Status.Error); @@ -136,7 +128,7 @@ public override void ParserErrors(HttpContext context, IReadOnlyList err public override IDisposable FormatHttpResponse(HttpContext context, OperationResult result) { - if (_options.SkipFormatHttpResponse) + if (options.SkipFormatHttpResponse) { return EmptyScope; } @@ -148,7 +140,7 @@ public override IDisposable FormatHttpResponse(HttpContext context, OperationRes return EmptyScope; } - _enricher.EnrichFormatHttpResponse(context, activity); + enricher.EnrichFormatHttpResponse(context, activity); activity.SetStatus(ActivityStatusCode.Ok); context.Items[FormatHttpResponseActivity] = activity; diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index bc07c2f38fb..da072e61e60 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -153,7 +153,7 @@ public async Task Http_Post_add_query_to_http_activity() o => { o.Scopes = ActivityScopes.All; - o.RequestDetails = RequestDetails.Default | RequestDetails.Operation; + o.RequestDetails = RequestDetails.Default | RequestDetails.OperationName; }); // act diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 68ebb085e1d..cea207c493a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -77,6 +77,22 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index 2974166579c..236dcdbcf74 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -81,6 +81,22 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap index 4a2b9d77d14..fe926208055 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap @@ -69,6 +69,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap index f16e3a80cd5..3cd67c910f5 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap @@ -73,6 +73,22 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, + { + "Key": "graphql.document.hash", + "Value": "cee0e2939ece72d650cb0331f4be4669" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap index fbc414941b4..cbd6c955b8f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap @@ -69,6 +69,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap index 030ce2f9739..abc094e2f8d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap @@ -69,6 +69,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index 9e676cdd3dd..8a2d9322e0b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -73,6 +73,22 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index c6bb0814344..33769d0516b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -25,6 +25,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index 1e73fddb0a7..fa06636ab55 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -69,6 +69,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 8c4aafda115..872f311509d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 4e4132c18de..123f5bb5133 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index e0912a0b152..d48046891f6 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -78,6 +78,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 19c7b120d6c..1e0ba6e8107 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index a0b7ae9e46a..6608b3caee7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -102,6 +102,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index e8ea02b47ea..4d40516b142 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "3beaca4ee1714ac9c9dfec8e445529df" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 481c91f7c48..0592160ea8b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "668e9631148921208d08dbb69513fa8e" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 19c7b120d6c..1e0ba6e8107 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -98,6 +98,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 75e231aeb38..9f4bc58a107 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -102,6 +102,18 @@ "DisplayName": "Compile Operation", "Status": "Ok", "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + }, { "Key": "otel.status_code", "Value": "OK" diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs index 689f319827a..8a4e4930419 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs @@ -41,7 +41,7 @@ public static IFusionGatewayBuilder AddInstrumentation( sp.GetRequiredService())); builder.AddDiagnosticEventListener( - sp => new ActivityServerDiagnosticListener( + sp => new FusionActivityServerDiagnosticListener( sp.GetService() ?? sp.GetRequiredService(), sp.GetRequiredService())); diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityScopes.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityScopes.cs index f0ef6bd29e2..e2208344cd3 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityScopes.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityScopes.cs @@ -14,13 +14,13 @@ public enum FusionActivityScopes CoerceVariables = 128, PlanOperation = 256, ExecuteOperation = 512, - ExecuteNodes = 1024, + ExecutePlanNodes = 1024, Default = ExecuteHttpRequest | ParseHttpRequest | ValidateDocument | PlanOperation - | ExecuteNodes + | ExecutePlanNodes | FormatHttpResponse, All = ExecuteHttpRequest @@ -33,5 +33,5 @@ public enum FusionActivityScopes | CoerceVariables | PlanOperation | ExecuteOperation - | ExecuteNodes + | ExecutePlanNodes } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs index 3c78f2644ff..9237f91b67a 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/InstrumentationOptions.cs @@ -13,23 +13,25 @@ public sealed class InstrumentationOptions : InstrumentationOptionsBase /// public FusionActivityScopes Scopes { get; set; } = Default; - internal override bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; + internal bool SkipExecuteHttpRequest => (Scopes & ExecuteHttpRequest) != ExecuteHttpRequest; - internal override bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; + internal bool SkipParseHttpRequest => (Scopes & ParseHttpRequest) != ParseHttpRequest; - internal override bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; + internal bool SkipFormatHttpResponse => (Scopes & FormatHttpResponse) != FormatHttpResponse; - internal override bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; + internal bool SkipExecuteRequest => (Scopes & ExecuteRequest) != ExecuteRequest; - internal override bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; + internal bool SkipParseDocument => (Scopes & ParseDocument) != ParseDocument; - internal override bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; + internal bool SkipValidateDocument => (Scopes & ValidateDocument) != ValidateDocument; - internal override bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; + internal bool SkipAnalyzeComplexity => (Scopes & AnalyzeComplexity) != AnalyzeComplexity; + + internal bool SkipCoerceVariables => (Scopes & CoerceVariables) != CoerceVariables; internal bool SkipPlanOperation => (Scopes & PlanOperation) != PlanOperation; - internal override bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; + internal bool SkipExecuteOperation => (Scopes & ExecuteOperation) != ExecuteOperation; - internal bool SkipExecuteNodes => (Scopes & ExecuteNodes) != ExecuteNodes; + internal bool SkipExecutePlanNodes => (Scopes & ExecutePlanNodes) != ExecutePlanNodes; } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs index 8a388692ca2..50d7405768b 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs @@ -232,7 +232,7 @@ public override IDisposable ExecuteOperationNode( OperationExecutionNode node, string schemaName) { - if (_options.SkipExecuteNodes) + if (_options.SkipExecutePlanNodes) { return EmptyScope; } @@ -252,7 +252,7 @@ public override IDisposable ExecuteOperationBatchNode( OperationBatchExecutionNode node, string schemaName) { - if (_options.SkipExecuteNodes) + if (_options.SkipExecutePlanNodes) { return EmptyScope; } @@ -271,7 +271,7 @@ public override IDisposable ExecuteNodeFieldNode( OperationPlanContext context, NodeFieldExecutionNode node) { - if (_options.SkipExecuteNodes) + if (_options.SkipExecutePlanNodes) { return EmptyScope; } @@ -290,7 +290,7 @@ public override IDisposable ExecuteIntrospectionNode( OperationPlanContext context, IntrospectionExecutionNode node) { - if (_options.SkipExecuteNodes) + if (_options.SkipExecutePlanNodes) { return EmptyScope; } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityServerDiagnosticListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs similarity index 75% rename from src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityServerDiagnosticListener.cs rename to src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs index 1eb078b2f3f..3e2b3d49d2d 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs @@ -8,17 +8,14 @@ namespace HotChocolate.Fusion.Diagnostics.Listeners; -internal sealed class ActivityServerDiagnosticListener( +internal sealed class FusionActivityServerDiagnosticListener( FusionActivityEnricher enricher, InstrumentationOptions options) : ServerDiagnosticEventListener { - private readonly InstrumentationOptions _options = options ?? throw new ArgumentNullException(nameof(options)); - private readonly FusionActivityEnricher _enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestKind kind) { - if (_options.SkipExecuteHttpRequest) + if (options.SkipExecuteHttpRequest) { return EmptyScope; } @@ -30,7 +27,7 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK return EmptyScope; } - _enricher.EnrichExecuteHttpRequest(context, kind, activity); + enricher.EnrichExecuteHttpRequest(context, kind, activity); activity.SetStatus(ActivityStatusCode.Ok); context.Items[HttpRequestActivity] = activity; @@ -39,19 +36,19 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK public override void StartSingleRequest(HttpContext context, GraphQLRequest request) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichSingleRequest(context, request, (Activity)activity!); + enricher.EnrichSingleRequest(context, request, (Activity)activity!); } } public override void StartBatchRequest(HttpContext context, IReadOnlyList batch) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichBatchRequest(context, batch, (Activity)activity!); + enricher.EnrichBatchRequest(context, batch, (Activity)activity!); } } @@ -60,10 +57,10 @@ public override void StartOperationBatchRequest( GraphQLRequest request, IReadOnlyList operations) { - if (_options.IncludeRequestDetails + if (options.IncludeRequestDetails && context.Items.TryGetValue(HttpRequestActivity, out var activity)) { - _enricher.EnrichOperationBatchRequest( + enricher.EnrichOperationBatchRequest( context, request, operations, @@ -76,7 +73,7 @@ public override void HttpRequestError(HttpContext context, IError error) if (context.Items.TryGetValue(HttpRequestActivity, out var value)) { var activity = (Activity)value!; - _enricher.EnrichHttpRequestError(context, error, activity); + enricher.EnrichHttpRequestError(context, error, activity); activity.SetStatus(Status.Error); } } @@ -86,14 +83,14 @@ public override void HttpRequestError(HttpContext context, Exception exception) if (context.Items.TryGetValue(HttpRequestActivity, out var value)) { var activity = (Activity)value!; - _enricher.EnrichHttpRequestError(context, exception, activity); + enricher.EnrichHttpRequestError(context, exception, activity); activity.SetStatus(Status.Error); } } public override IDisposable ParseHttpRequest(HttpContext context) { - if (_options.SkipParseHttpRequest) + if (options.SkipParseHttpRequest) { return EmptyScope; } @@ -105,7 +102,7 @@ public override IDisposable ParseHttpRequest(HttpContext context) return EmptyScope; } - _enricher.EnrichParseHttpRequest(context, activity); + enricher.EnrichParseHttpRequest(context, activity); activity.SetStatus(Status.Ok); activity.SetStatus(ActivityStatusCode.Ok); context.Items[ParseHttpRequestActivity] = activity; @@ -121,7 +118,7 @@ public override void ParserErrors(HttpContext context, IReadOnlyList err foreach (var error in errors) { - _enricher.EnrichParserErrors(context, error, activity); + enricher.EnrichParserErrors(context, error, activity); } activity.SetStatus(Status.Error); @@ -131,7 +128,7 @@ public override void ParserErrors(HttpContext context, IReadOnlyList err public override IDisposable FormatHttpResponse(HttpContext context, OperationResult result) { - if (_options.SkipFormatHttpResponse) + if (options.SkipFormatHttpResponse) { return EmptyScope; } @@ -143,7 +140,7 @@ public override IDisposable FormatHttpResponse(HttpContext context, OperationRes return EmptyScope; } - _enricher.EnrichFormatHttpResponse(context, activity); + enricher.EnrichFormatHttpResponse(context, activity); activity.SetStatus(ActivityStatusCode.Ok); context.Items[FormatHttpResponseActivity] = activity; diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index 88927005292..2cef94d5661 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -177,7 +177,7 @@ public async Task Http_Post_Add_Query_To_Http_Activity() o => { o.Scopes = FusionActivityScopes.All; - o.RequestDetails = RequestDetails.Default | RequestDetails.Operation; + o.RequestDetails = RequestDetails.Default | RequestDetails.OperationName; })); using var client = GraphQLHttpClient.Create(gateway.CreateClient()); From e48ba42a47146a6fd5774c517123f361bbae1b7b Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:15:34 +0100 Subject: [PATCH 06/37] Cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 2 +- .../Diagnostics.Core/SemanticConventions.cs | 10 ++++ .../src/Diagnostics/ActivityEnricher.cs | 6 +++ .../ActivityDataLoaderDiagnosticListener.cs | 31 +++++------ ...DataLoaderBatchDispatchCoordinatorScope.cs | 28 ++++++++++ ...tivityDataLoaderDiagnosticListenerTests.cs | 52 +++++++++++++++++++ ...h_Dispatch_Coordinator_Emits_Activity.snap | 16 ++++++ ...ch_Coordinator_Tracks_Dispatch_Events.snap | 35 +++++++++++++ .../FusionActivityEnricher.cs | 8 +-- 9 files changed, 165 insertions(+), 23 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 530c5ebbedf..0d770b31262 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -403,7 +403,7 @@ protected void EnrichCoerceVariablesCore( OperationDefinitionNode? operationDefinition, OperationDocumentInfo documentInfo) { - activity.DisplayName = "Coerce Variable"; + activity.DisplayName = "Coerce Variables"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); // TODO: This is new here. Why do we do this in other places? diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 3129e19cf41..bf6ed0cb948 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -41,6 +41,14 @@ public static class Step public const string Id = "graphql.operation.step.id"; public const string Kind = "graphql.operation.step.kind"; + public static class KindValues + { + public const string Operation = "operation"; + public const string OperationBatch = "operation-batch"; + public const string Introspection = "introspection"; + public const string Node = "node"; + } + public static class Plan { public const string Id = "graphql.operation.step.plan.id"; @@ -92,6 +100,7 @@ public static class Batch public const string Keys = "graphql.dataloader.batch.keys"; } + // TODO: This is unused public static class Cache { public const string HitCount = "graphql.dataloader.cache.hit_count"; @@ -102,6 +111,7 @@ public static class Cache public static class Source { public const string Name = "graphql.source.name"; + // TODO: This is unused public const string Id = "graphql.source.id"; public static class Operation diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 3e586ba6467..d671da21d3b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -172,6 +172,12 @@ public virtual void EnrichDataLoaderBatch( } } + public virtual void EnrichDataLoaderBatchDispatchCoordinator(Activity activity) + { + activity.DisplayName = "Coordinate DataLoader Batches"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); + } + protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) { if (operation is null) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index 0d7d0a2d16e..517c8ff6071 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -2,28 +2,19 @@ using GreenDonut; using HotChocolate.Diagnostics.Scopes; using static HotChocolate.Diagnostics.HotChocolateActivitySource; -using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics.Listeners; -internal sealed class ActivityDataLoaderDiagnosticListener : DataLoaderDiagnosticEventListener +internal sealed class ActivityDataLoaderDiagnosticListener( + ActivityEnricher enricher, + InstrumentationOptions options) + : DataLoaderDiagnosticEventListener { - private readonly InstrumentationOptions _options; - private readonly ActivityEnricher _enricher; - - public ActivityDataLoaderDiagnosticListener( - ActivityEnricher enricher, - InstrumentationOptions options) - { - _enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - _options = options ?? throw new ArgumentNullException(nameof(options)); - } - public override IDisposable ExecuteBatch( IDataLoader dataLoader, IReadOnlyList keys) { - if (_options.SkipDataLoaderBatch) + if (options.SkipDataLoaderBatch) { return EmptyScope; } @@ -35,15 +26,19 @@ public override IDisposable ExecuteBatch( return EmptyScope; } - return new DataLoaderBatchScope(_enricher, dataLoader, keys, activity); + return new DataLoaderBatchScope(enricher, dataLoader, keys, activity); } public override IDisposable RunBatchDispatchCoordinator() { var activity = Source.StartActivity("BatchCoordinator"); - activity?.DisplayName = "Coordinate DataLoader Batches"; - activity?.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); - return activity ?? EmptyScope; + + if (activity is null) + { + return EmptyScope; + } + + return new DataLoaderBatchDispatchCoordinatorScope(enricher, activity); } public override void BatchDispatchError(System.Exception error) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs new file mode 100644 index 00000000000..e9b5dff66b7 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs @@ -0,0 +1,28 @@ +using System.Diagnostics; + +namespace HotChocolate.Diagnostics.Scopes; + +internal sealed class DataLoaderBatchDispatchCoordinatorScope : IDisposable +{ + private readonly ActivityEnricher _enricher; + private readonly Activity _activity; + private bool _disposed; + + public DataLoaderBatchDispatchCoordinatorScope( + ActivityEnricher enricher, + Activity activity) + { + _enricher = enricher; + _activity = activity; + } + + public void Dispose() + { + if (!_disposed) + { + _enricher.EnrichDataLoaderBatchDispatchCoordinator(_activity); + _activity.Dispose(); + _disposed = true; + } + } +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs new file mode 100644 index 00000000000..6b0b0e62b89 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs @@ -0,0 +1,52 @@ +using System.Text; +using Microsoft.Extensions.ObjectPool; +using static HotChocolate.Diagnostics.ActivityTestHelper; + +namespace HotChocolate.Diagnostics; + +[Collection("Instrumentation")] +public class ActivityDataLoaderDiagnosticListenerTests +{ + [Fact] + public void Run_Batch_Dispatch_Coordinator_Emits_Activity() + { + using (CaptureActivities(out var activities)) + { + var listener = CreateListener(ActivityScopes.DataLoaderBatch); + + using (listener.RunBatchDispatchCoordinator()) + { + } + + activities.MatchSnapshot(); + } + } + + [Fact] + public void Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events() + { + using (CaptureActivities(out var activities)) + { + var listener = CreateListener(ActivityScopes.DataLoaderBatch); + + using (listener.RunBatchDispatchCoordinator()) + { + listener.BatchEvaluated(2); + listener.BatchDispatched(1); + } + + activities.MatchSnapshot(); + } + } + + private static Listeners.ActivityDataLoaderDiagnosticListener CreateListener(ActivityScopes scopes) + { + var options = new InstrumentationOptions + { + Scopes = scopes + }; + var pool = new DefaultObjectPoolProvider().Create(new StringBuilderPooledObjectPolicy()); + var enricher = new ActivityEnricher(pool, options); + return new Listeners.ActivityDataLoaderDiagnosticListener(enricher, options); + } +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap new file mode 100644 index 00000000000..d363ced0b63 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap @@ -0,0 +1,16 @@ +{ + "activities": [ + { + "OperationName": "BatchCoordinator", + "DisplayName": "Coordinate DataLoader Batches", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_dispatch" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap new file mode 100644 index 00000000000..4eceff380ce --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap @@ -0,0 +1,35 @@ +{ + "activities": [ + { + "OperationName": "BatchCoordinator", + "DisplayName": "Coordinate DataLoader Batches", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_dispatch" + } + ], + "event": [ + { + "Name": "BatchEvaluated", + "Tags": [ + { + "Key": "openBatches", + "Value": 2 + } + ] + }, + { + "Name": "BatchDispatched", + "Tags": [ + { + "Key": "dispatchedBatches", + "Value": 1 + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index c92b18962e0..02e89b33b9f 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -23,10 +23,10 @@ public class FusionActivityEnricher( private static FrozenDictionary KindValues { get; } = new Dictionary { - [ExecutionNodeType.Operation] = "operation", - [ExecutionNodeType.OperationBatch] = "operation-batch", - [ExecutionNodeType.Introspection] = "introspection", - [ExecutionNodeType.Node] = "node" + [ExecutionNodeType.Operation] = GraphQL.Operation.Step.KindValues.Operation, + [ExecutionNodeType.OperationBatch] = GraphQL.Operation.Step.KindValues.OperationBatch, + [ExecutionNodeType.Introspection] = GraphQL.Operation.Step.KindValues.Introspection, + [ExecutionNodeType.Node] = GraphQL.Operation.Step.KindValues.Node }.ToFrozenDictionary(); public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) From d83edcd5101d4ed5fe0372e4376cf0c0c62a535c Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 15:11:33 +0100 Subject: [PATCH 07/37] Cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 50 ----------------- .../InstrumentationOptionsBase.cs | 5 -- .../Diagnostics.Core/SemanticConventions.cs | 26 +++++++-- .../QueryInstrumentationTests.cs | 49 ++++------------ .../ServerInstrumentationTests.cs | 12 +--- ....Http_Post_add_query_to_http_activity.snap | 2 +- ...p_Post_add_variables_to_http_activity.snap | 2 +- ...not_automatically_added_to_activities.snap | 2 +- ...onTests.Http_Post_with_extensions_map.snap | 2 +- ...g_error_when_rename_root_is_activated.snap | 2 +- ...n_error_when_rename_root_is_activated.snap | 2 +- .../QueryInstrumentationTests.cs | 56 ++++++------------- .../ServerInstrumentationTests.cs | 16 ++---- ....Http_Post_Add_Query_To_Http_Activity.snap | 2 +- ...p_Post_Add_Variables_To_Http_Activity.snap | 2 +- ...ntationTests.Http_Post_Single_Request.snap | 15 +---- ...Not_Automatically_Added_To_Activities.snap | 2 +- ...onTests.Http_Post_With_Extensions_Map.snap | 2 +- ...g_Error_When_Rename_Root_Is_Activated.snap | 2 +- ...n_Error_When_Rename_Root_Is_Activated.snap | 2 +- .../v16/migrating/migrate-from-15-to-16.md | 1 + 21 files changed, 69 insertions(+), 185 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 0d770b31262..49c90b4d2ef 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -50,24 +50,15 @@ public virtual void EnrichExecuteHttpRequest( break; } - if (options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - activity.SetTag(GraphQL.Http.Kind, kind); - var isDefault = false; if (!(context.Items.TryGetValue(SchemaName, out var value) && value is string schemaName)) { schemaName = ISchemaDefinition.DefaultName; - isDefault = true; } - // TODO: Is this needed? activity.SetTag(GraphQL.Schema.Name, schemaName); - activity.SetTag(GraphQL.Schema.IsDefault, isDefault); } public virtual void EnrichSingleRequest( @@ -284,11 +275,6 @@ public virtual void EnrichHttpRequestError( public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) { activity.DisplayName = "Parse HTTP Request"; - - if (options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } } public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) @@ -332,11 +318,6 @@ protected void EnrichExecuteRequestCore( { activity.DisplayName = operationDisplayName ?? "Execute Request"; - if (options.RenameRootActivity && operationDisplayName is not null) - { - UpdateRootActivityName(activity, operationDisplayName); - } - var documentInfo = context.OperationDocumentInfo; activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); @@ -374,11 +355,6 @@ protected void EnrichParseDocumentCore( activity.DisplayName = "Parse Document"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - if (options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - EnrichWithTags(activity, operationDefinition, documentInfo); } @@ -390,11 +366,6 @@ protected void EnrichValidateDocumentCore( activity.DisplayName = "Validate Document"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - if (options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - EnrichWithTags(activity, operationDefinition, documentInfo); } @@ -406,12 +377,6 @@ protected void EnrichCoerceVariablesCore( activity.DisplayName = "Coerce Variables"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - // TODO: This is new here. Why do we do this in other places? - if (options.RenameRootActivity) - { - UpdateRootActivityName(activity, $"Begin {activity.DisplayName}"); - } - EnrichWithTags(activity, operationDefinition, documentInfo); } @@ -539,19 +504,4 @@ protected virtual void EnrichError(IError error, Activity activity) activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } - - private void UpdateRootActivityName(Activity activity, string displayName) - { - var current = activity; - - while (current.Parent is not null) - { - current = current.Parent; - } - - if (current != activity) - { - current.DisplayName = CreateRootActivityName(activity, current, displayName); - } - } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs index a1d1ec40803..adbdac41253 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/InstrumentationOptionsBase.cs @@ -12,10 +12,5 @@ public abstract class InstrumentationOptionsBase /// public bool IncludeDocument { get; set; } - /// - /// Defines if the operation display name shall be included in the root activity. - /// - public bool RenameRootActivity { get; set; } - internal bool IncludeRequestDetails => RequestDetails is not RequestDetails.None; } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index bf6ed0cb948..492b4011da5 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -18,13 +18,19 @@ public static class Document { public const string Id = "graphql.document.id"; public const string Hash = "graphql.document.hash"; + + // Note: This is not part of the OTEL semantic conventions public const string Body = "graphql.document.body"; + + // Note: This is not part of the OTEL semantic conventions public const string Valid = "graphql.document.valid"; } public static class Operation { + // Note: This is not part of the OTEL semantic conventions public const string Id = "graphql.operation.id"; + public const string Name = "graphql.operation.name"; public const string Type = "graphql.operation.type"; @@ -41,10 +47,11 @@ public static class Step public const string Id = "graphql.operation.step.id"; public const string Kind = "graphql.operation.step.kind"; + // Note: This is not part of the OTEL semantic conventions public static class KindValues { public const string Operation = "operation"; - public const string OperationBatch = "operation-batch"; + public const string OperationBatch = "operation_batch"; public const string Introspection = "introspection"; public const string Node = "node"; } @@ -78,6 +85,8 @@ public static class Selection { public const string Name = "graphql.selection.name"; public const string Path = "graphql.selection.path"; + + // Note: This is not part of the OTEL semantic conventions public const string Hierarchy = "graphql.selection.hierarchy"; public static class Field @@ -85,7 +94,11 @@ public static class Field public const string Name = "graphql.selection.field.name"; public const string ParentType = "graphql.selection.field.parent_type"; public const string Coordinate = "graphql.selection.field.coordinate"; + + // Note: This is not part of the OTEL semantic conventions public const string IsDeprecated = "graphql.selection.field.isDeprecated"; + + // Note: This is not part of the OTEL semantic conventions public const string Type = "graphql.selection.type"; } } @@ -100,7 +113,6 @@ public static class Batch public const string Keys = "graphql.dataloader.batch.keys"; } - // TODO: This is unused public static class Cache { public const string HitCount = "graphql.dataloader.cache.hit_count"; @@ -111,8 +123,6 @@ public static class Cache public static class Source { public const string Name = "graphql.source.name"; - // TODO: This is unused - public const string Id = "graphql.source.id"; public static class Operation { @@ -122,6 +132,7 @@ public static class Operation } } + // Note: This is not part of the OTEL semantic conventions public static class Errors { public const string Count = "graphql.errors.count"; @@ -134,6 +145,7 @@ public static class Location } } + // Note: This is not part of the OTEL semantic conventions public static class Http { public const string Kind = "graphql.http.kind"; @@ -149,13 +161,15 @@ public static class Request public const string Variables = "graphql.http.request.variables"; public const string Extensions = "graphql.http.request.extensions"; + // Note: This is not part of the OTEL semantic conventions public static class Types { public const string Single = "single"; public const string Batch = "batch"; - public const string OperationBatch = "operation-batch"; + public const string OperationBatch = "operation_batch"; } + // Note: This is not part of the OTEL semantic conventions public static class BatchRequest { public static string QueryId(int index) => $"graphql.http.request[{index}].query.id"; @@ -173,10 +187,10 @@ public static class BatchRequest } } + // Note: This is not part of the OTEL semantic conventions public static class Schema { public const string Name = "graphql.schema.name"; - public const string IsDefault = "graphql.schema.isDefault"; } } } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index f2c4475cb3d..3497f2627f2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -67,16 +67,12 @@ public async Task Track_events_of_a_simple_query_default_rename_root() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ sayHello }"); // assert - Assert.Equal("CaptureActivities: query { sayHello }", Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -88,16 +84,12 @@ public async Task Parsing_error_when_rename_root_is_activated() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ sayHello"); // assert - Assert.Equal("CaptureActivities: Begin Parse Document", Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -109,17 +101,12 @@ public async Task Validation_error_when_rename_root_is_activated() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ abc123 }"); // assert - Assert.Equal("CaptureActivities: Begin Validate Document", - Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -131,11 +118,7 @@ public async Task Create_operation_display_name_with_1_field() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ a: sayHello }"); @@ -152,11 +135,7 @@ public async Task Create_operation_display_name_with_1_field_and_op() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("query GetA { a: sayHello }"); @@ -173,11 +152,7 @@ public async Task Create_operation_display_name_with_3_field() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ a: sayHello b: sayHello c: sayHello }"); @@ -194,11 +169,7 @@ public async Task Create_operation_display_name_with_4_field() // arrange & act await new ServiceCollection() .AddGraphQL() - .AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = ActivityScopes.All; - }) + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) .AddQueryType() .ExecuteRequestAsync("{ a: sayHello b: sayHello c: sayHello d: sayHello }"); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index da072e61e60..853776ee49e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -328,11 +328,7 @@ public async Task Parsing_error_when_rename_root_is_activated() { // arrange using var server = CreateInstrumentedServer( - o => - { - o.Scopes = ActivityScopes.All; - o.RenameRootActivity = true; - }); + o => o.Scopes = ActivityScopes.All); // act await server.PostRawAsync(new ClientQueryRequest @@ -356,11 +352,7 @@ public async Task Validation_error_when_rename_root_is_activated() { // arrange using var server = CreateInstrumentedServer( - o => - { - o.Scopes = ActivityScopes.All; - o.RenameRootActivity = true; - }); + o => o.Scopes = ActivityScopes.All); // act await server.PostRawAsync(new ClientQueryRequest diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 1e0ba6e8107..c2208c21893 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -119,7 +119,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index 6608b3caee7..ce8edba54f1 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -123,7 +123,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 1e0ba6e8107..c2208c21893 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -119,7 +119,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 9f4bc58a107..19dcf087576 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -123,7 +123,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index f888f28f571..22d387d7a6e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST: Begin Parse HTTP Request", + "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 111ca5e59c5..358ee333471 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST: Begin Validate Document", + "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index 333c442cb85..9d2200193c4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -53,11 +53,8 @@ public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -69,7 +66,7 @@ public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() await executor.ExecuteAsync(request); // assert - Assert.Equal("CaptureActivities: query { sayHello }", Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -87,11 +84,8 @@ public async Task Parsing_Error_When_Rename_Root_Is_Activated() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -103,7 +97,7 @@ public async Task Parsing_Error_When_Rename_Root_Is_Activated() await executor.ExecuteAsync(request); // assert - Assert.Equal("CaptureActivities: Begin Parse Document", Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -121,11 +115,8 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -137,8 +128,7 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() await executor.ExecuteAsync(request); // assert - Assert.Equal("CaptureActivities: Begin Validate Document", - Activity.Current!.DisplayName); + Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); } } @@ -156,11 +146,8 @@ public async Task Create_Operation_Display_Name_With_1_Field() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -190,11 +177,8 @@ public async Task Create_Operation_Display_Name_With_1_Field_And_Op() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -224,11 +208,8 @@ public async Task Create_Operation_Display_Name_With_3_Field() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); @@ -258,11 +239,8 @@ public async Task Create_Operation_Display_Name_With_4_Field() [ ("a", server1) ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.RenameRootActivity = true; - o.Scopes = FusionActivityScopes.All; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); var executor = await gateway.Services.GetRequestExecutorAsync(); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index 2cef94d5661..ed5965ea178 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -340,12 +340,8 @@ public async Task Parsing_Error_When_Rename_Root_Is_Activated() using var gateway = await CreateCompositeSchemaAsync( [("a", server)], - configureGatewayBuilder: b => b.AddInstrumentation( - o => - { - o.Scopes = FusionActivityScopes.All; - o.RenameRootActivity = true; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); using var client = GraphQLHttpClient.Create(gateway.CreateClient()); @@ -372,12 +368,8 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() using var gateway = await CreateCompositeSchemaAsync( [("a", server)], - configureGatewayBuilder: b => b.AddInstrumentation( - o => - { - o.Scopes = FusionActivityScopes.All; - o.RenameRootActivity = true; - })); + configureGatewayBuilder: b => b + .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); using var client = GraphQLHttpClient.Create(gateway.CreateClient()); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 41eb9d6f6c9..5c1a9563ccd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -107,7 +107,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index c48c8ffe928..d2467991da7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -111,7 +111,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 5ab02fe57f4..29abcc0e09a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,18 +2,9 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], + "DisplayName": "ExecuteHttpRequest", + "Status": "Unset", + "tags": [], "event": [], "activities": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 41eb9d6f6c9..5c1a9563ccd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -107,7 +107,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index fe194a81538..9ea8c97c3da 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -111,7 +111,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variable", + "DisplayName": "Coerce Variables", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index 71a7c84c3a4..d2cbe8b5ad6 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST: Begin Parse HTTP Request", + "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 3c55bf0c232..ea8ec609e70 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST: Begin Validate Document", + "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ { diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index 3c15743962b..bdeb88cdafb 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -616,6 +616,7 @@ If you have dashboards or alerts that filter on the old attribute names or value | Attribute | Old Value | New Value | | ------------------------ | ------------------------------------- | ------------------------------------- | | `graphql.operation.type` | `Query` / `Mutation` / `Subscription` | `query` / `mutation` / `subscription` | +| `graphql.http.kind` | `operation-batch` | `operation_batch` | # Deprecations From e361071961cb2d60262ded651458000b72ca7e0d Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:45:03 +0000 Subject: [PATCH 08/37] wip: More cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 224 ++++++++++++------ .../Diagnostics.Core/SemanticConventions.cs | 9 + .../src/Diagnostics/ActivityEnricher.cs | 117 +++------ .../ActivityExecutionDiagnosticListener.cs | 6 +- ...onTests.Allow_document_to_be_captured.snap | 56 ++--- ...r_error_that_deletes_the_whole_result.snap | 62 ++--- ...or_that_deletes_the_whole_result_deep.snap | 45 ++-- ...e_operation_display_name_with_1_field.snap | 48 ++-- ...tion_display_name_with_1_field_and_op.snap | 56 ++--- ...e_operation_display_name_with_3_field.snap | 72 ++---- ...e_operation_display_name_with_4_field.snap | 84 ++----- ...peration_name_is_used_as_request_name.snap | 56 ++--- ...lidation_activity_has_an_error_status.snap | 45 ++-- ...rack_events_of_a_simple_query_default.snap | 24 +- ...ack_events_of_a_simple_query_detailed.snap | 48 ++-- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 44 ++-- ...s.Http_Post_SingleRequest_GetHeroName.snap | 44 ++-- ...ost_SingleRequest_GetHeroName_Default.snap | 36 +-- ....Http_Post_add_query_to_http_activity.snap | 48 ++-- ...p_Post_add_variables_to_http_activity.snap | 48 ++-- ...s.Http_Post_capture_deferred_response.snap | 56 ++--- ...t_ensure_list_path_is_correctly_built.snap | 92 ++----- ...mentationTests.Http_Post_parser_error.snap | 13 +- ...not_automatically_added_to_activities.snap | 48 ++-- ...onTests.Http_Post_with_extensions_map.snap | 48 ++-- ...g_error_when_rename_root_is_activated.snap | 13 +- ...n_error_when_rename_root_is_activated.snap | 29 ++- .../FusionActivityEnricher.cs | 72 +++--- ...onTests.Allow_Document_To_Be_Captured.snap | 52 ++-- ...r_Error_That_Deletes_The_Whole_Result.snap | 52 ++-- ...or_That_Deletes_The_Whole_Result_Deep.snap | 45 ++-- ...e_Operation_Display_Name_With_1_Field.snap | 44 ++-- ...tion_Display_Name_With_1_Field_And_Op.snap | 52 ++-- ...e_Operation_Display_Name_With_3_Field.snap | 44 ++-- ...e_Operation_Display_Name_With_4_Field.snap | 44 ++-- ...peration_Name_Is_Used_As_Request_Name.snap | 52 ++-- ...lidation_Activity_Has_An_Error_Status.snap | 45 ++-- ...onTests.Source_Schema_Transport_Error.snap | 44 ++-- ...ents_Of_A_Query_With_Multiple_Sources.snap | 52 ++-- ...rack_Events_Of_A_Simple_Query_Default.snap | 20 +- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 44 ++-- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 44 ++-- ...entationTests.Http_Get_Single_Request.snap | 36 +-- ....Http_Post_Add_Query_To_Http_Activity.snap | 40 ++-- ...p_Post_Add_Variables_To_Http_Activity.snap | 40 ++-- ...mentationTests.Http_Post_Parser_Error.snap | 13 +- ...ntationTests.Http_Post_Single_Request.snap | 51 ++-- ...ests.Http_Post_Single_Request_Default.snap | 32 +-- ...Not_Automatically_Added_To_Activities.snap | 40 ++-- ...onTests.Http_Post_With_Extensions_Map.snap | 40 ++-- ...g_Error_When_Rename_Root_Is_Activated.snap | 13 +- ...n_Error_When_Rename_Root_Is_Activated.snap | 29 ++- 52 files changed, 1266 insertions(+), 1245 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 49c90b4d2ef..66cdf19be82 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -308,6 +308,18 @@ public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Act activity.DisplayName = "Analyze Operation Complexity"; } + public virtual void EnrichOperationCost( + RequestContext context, + Activity activity, + double fieldCost, + double typeCost) + { + var documentInfo = context.OperationDocumentInfo; + activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); + activity.SetTag(GraphQL.Operation.FieldCost, fieldCost); + activity.SetTag(GraphQL.Operation.TypeCost, typeCost); + } + protected void EnrichExecuteRequestCore( RequestContext context, Activity activity, @@ -316,13 +328,15 @@ protected void EnrichExecuteRequestCore( OperationType? operationType, string? operationName) { - activity.DisplayName = operationDisplayName ?? "Execute Request"; + activity.DisplayName = operationDisplayName ?? "GraphQL Operation"; var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); - activity.SetTag(GraphQL.Document.Valid, documentInfo.IsValidated); - activity.SetTag(GraphQL.Operation.Id, operationId); + activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); + + if (documentInfo.IsPersisted) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } if (operationType is not null) { @@ -340,11 +354,6 @@ protected void EnrichExecuteRequestCore( { activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); } - - if (context.Result is OperationResult { Errors: [_, ..] errors }) - { - activity.SetTag(GraphQL.Errors.Count, errors.Count); - } } protected void EnrichParseDocumentCore( @@ -352,7 +361,7 @@ protected void EnrichParseDocumentCore( OperationDefinitionNode? operationDefinition, OperationDocumentInfo documentInfo) { - activity.DisplayName = "Parse Document"; + activity.DisplayName = "GraphQL Document Parsing"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); EnrichWithTags(activity, operationDefinition, documentInfo); @@ -363,7 +372,7 @@ protected void EnrichValidateDocumentCore( OperationDefinitionNode? operationDefinition, OperationDocumentInfo documentInfo) { - activity.DisplayName = "Validate Document"; + activity.DisplayName = "GraphQL Document Validation"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); EnrichWithTags(activity, operationDefinition, documentInfo); @@ -374,7 +383,7 @@ protected void EnrichCoerceVariablesCore( OperationDefinitionNode? operationDefinition, OperationDocumentInfo documentInfo) { - activity.DisplayName = "Coerce Variables"; + activity.DisplayName = "GraphQL Variable Coercion"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); EnrichWithTags(activity, operationDefinition, documentInfo); @@ -396,7 +405,7 @@ protected static void EnrichWithTags( } } - activity.SetTag(GraphQL.Document.Hash, documentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); if (documentInfo.IsPersisted) { @@ -406,60 +415,15 @@ protected static void EnrichWithTags( protected string BuildOperationDisplayName( OperationType operationType, - string? operationName, - int selectionCount, - IEnumerable selectionResponseNames) + string? operationName) { - var displayName = StringBuilderPool.Get(); - - try + var operationTypeName = GraphQL.Operation.TypeValues[operationType]; + if (!string.IsNullOrEmpty(operationName)) { - displayName.Append('{'); - displayName.Append(' '); - - var count = 0; - foreach (var name in selectionResponseNames) - { - if (count >= 3) - { - break; - } - - if (displayName.Length > 2) - { - displayName.Append(' '); - } - - displayName.Append(name); - count++; - } - - if (selectionCount > 3) - { - displayName.Append(' '); - displayName.Append('.'); - displayName.Append('.'); - displayName.Append('.'); - } - - displayName.Append(' '); - displayName.Append('}'); - - if (operationName is not null) - { - displayName.Insert(0, ' '); - displayName.Insert(0, operationName); - } - - displayName.Insert(0, ' '); - displayName.Insert(0, operationType.ToString().ToLowerInvariant()); - - return displayName.ToString(); - } - finally - { - StringBuilderPool.Return(displayName); + return $"{operationTypeName} {operationName}"; } + + return operationTypeName; } protected virtual string CreateRootActivityName( @@ -488,20 +452,142 @@ protected virtual void EnrichError(IError error, Activity activity) var tags = new ActivityTagsCollection { new(SemanticConventions.Exception.Message, error.Message), - new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR") + new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR"), + new(GraphQL.Errors.Message, error.Message) }; if (error.Path is not null) { - tags[GraphQL.Errors.Path] = error.Path.ToString(); + tags[GraphQL.Errors.Path] = FormatPath(error.Path); } if (error.Locations is { Count: > 0 }) { - tags[GraphQL.Errors.Location.Column] = error.Locations[0].Column; - tags[GraphQL.Errors.Location.Line] = error.Locations[0].Line; + var locations = new object[error.Locations.Count]; + for (var i = 0; i < error.Locations.Count; i++) + { + var location = error.Locations[i]; + locations[i] = new Dictionary + { + ["line"] = location.Line, + ["column"] = location.Column + }; + } + + tags[GraphQL.Errors.Locations] = locations; } activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } + + protected static OperationDefinitionNode? ResolveOperationDefinition( + OperationDefinitionNode? operationDefinition, + OperationDocumentInfo documentInfo, + string? operationName) + { + if (operationDefinition is not null) + { + return operationDefinition; + } + + if (documentInfo.Document is not { } document) + { + return null; + } + + if (string.IsNullOrEmpty(operationName)) + { + OperationDefinitionNode? singleOperation = null; + + foreach (var definition in document.Definitions) + { + if (definition is not OperationDefinitionNode operation) + { + continue; + } + + if (singleOperation is not null) + { + return null; + } + + singleOperation = operation; + } + + return singleOperation; + } + + foreach (var definition in document.Definitions) + { + if (definition is OperationDefinitionNode operation + && string.Equals(operation.Name?.Value, operationName, StringComparison.Ordinal)) + { + return operation; + } + } + + return null; + } + + protected internal static string FormatDocumentHash(OperationDocumentHash hash) + { + if (hash.IsEmpty || string.IsNullOrEmpty(hash.AlgorithmName)) + { + return hash.Value; + } + + var algorithm = hash.AlgorithmName; + + if (algorithm.EndsWith("Hash", System.StringComparison.OrdinalIgnoreCase)) + { + algorithm = algorithm[..^4]; + } + + algorithm = algorithm.ToLowerInvariant(); + + if (algorithm == "sha256") + { + algorithm = "sha25"; + } + + return $"{algorithm}:{hash.Value}"; + } + + protected static string? FormatPath(Path? path) + { + if (path is null || path.IsRoot) + { + return null; + } + + var segments = path.ToList(); + if (segments.Count == 0) + { + return null; + } + + var result = new StringBuilder(); + foreach (var segment in segments) + { + if (segment is string name) + { + if (result.Length > 0) + { + result.Append('.'); + } + + result.Append(name); + continue; + } + + if (segment is int index) + { + result.Append('['); + result.Append(index); + result.Append(']'); + } + } + + return result.ToString(); + } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 492b4011da5..5984a236e6b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -34,6 +34,12 @@ public static class Operation public const string Name = "graphql.operation.name"; public const string Type = "graphql.operation.type"; + // Note: This is not part of the OTEL semantic conventions + public const string FieldCost = "graphql.operation.fieldCost"; + + // Note: This is not part of the OTEL semantic conventions + public const string TypeCost = "graphql.operation.typeCost"; + public static FrozenDictionary TypeValues { get; } = new Dictionary { @@ -123,6 +129,7 @@ public static class Cache public static class Source { public const string Name = "graphql.source.name"; + public const string Id = "graphql.source.id"; public static class Operation { @@ -136,6 +143,8 @@ public static class Operation public static class Errors { public const string Count = "graphql.errors.count"; + public const string Message = "graphql.error.message"; + public const string Locations = "graphql.error.locations"; public const string Path = "graphql.error.path"; public static class Location diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index d671da21d3b..8aa222496c8 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -5,7 +5,6 @@ using HotChocolate.Execution; using HotChocolate.Execution.Processing; using HotChocolate.Resolvers; -using HotChocolate.Types; using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics; @@ -36,111 +35,78 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi public virtual void EnrichParseDocument(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); + var operationDefinition = ResolveOperationDefinition( + operation?.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichParseDocumentCore(activity, operation?.Definition, context.OperationDocumentInfo); + EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); + var operationDefinition = ResolveOperationDefinition( + operation?.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichValidateDocumentCore(activity, operation?.Definition, context.OperationDocumentInfo); + EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); + var operationDefinition = ResolveOperationDefinition( + operation?.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichCoerceVariablesCore(activity, operation?.Definition, context.OperationDocumentInfo); + EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichCompileOperation(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); + var operationDefinition = ResolveOperationDefinition( + operation?.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - activity.DisplayName = "Compile Operation"; - // TODO: Not sure if plan is supposed to be used like this + activity.DisplayName = "GraphQL Operation Planning"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - EnrichWithTags(activity, operation?.Definition, context.OperationDocumentInfo); + EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - activity.DisplayName = - operation?.Name is { } op - ? $"Execute Operation {op}" - : "Execute Operation"; + var operationDefinition = ResolveOperationDefinition( + operation?.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); + + activity.DisplayName = "GraphQL Operation Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - EnrichWithTags(activity, operation?.Definition, context.OperationDocumentInfo); + EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity activity) { - string path; - string hierarchy; - BuildPath(); - var selection = context.Selection; var coordinate = selection.Field.Coordinate; + var path = FormatPath(context.Path); - activity.DisplayName = path; + activity.DisplayName = coordinate.ToString(); activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Resolve); activity.SetTag(GraphQL.Selection.Name, selection.ResponseName); - activity.SetTag(GraphQL.Selection.Field.Type, selection.Field.Type.Print()); activity.SetTag(GraphQL.Selection.Path, path); - activity.SetTag(GraphQL.Selection.Hierarchy, hierarchy); activity.SetTag(GraphQL.Selection.Field.Name, coordinate.MemberName); - activity.SetTag(GraphQL.Selection.Field.Coordinate, coordinate.ToString()); + activity.SetTag(GraphQL.Selection.Field.Coordinate, activity.DisplayName); activity.SetTag(GraphQL.Selection.Field.ParentType, coordinate.Name); - activity.SetTag(GraphQL.Selection.Field.IsDeprecated, selection.Field.IsDeprecated); - - void BuildPath() - { - var p = StringBuilderPool.Get(); - var h = StringBuilderPool.Get(); - var index = StringBuilderPool.Get(); - - var current = context.Path; - - do - { - if (current is NamePathSegment n) - { - p.Insert(0, '/'); - h.Insert(0, '/'); - p.Insert(1, n.Name); - h.Insert(1, n.Name); - - if (index.Length > 0) - { - p.Insert(1 + n.Name.Length, index); - } - - index.Clear(); - } - - if (current is IndexerPathSegment i) - { - var number = i.Index.ToString(); - index.Insert(0, '['); - index.Insert(1, number); - index.Insert(1 + number.Length, ']'); - } - - current = current.Parent; - } while (!current.IsRoot); - - path = p.ToString(); - hierarchy = h.ToString(); - - StringBuilderPool.Return(p); - StringBuilderPool.Return(h); - StringBuilderPool.Return(index); - } } public virtual void EnrichResolverError( @@ -180,23 +146,8 @@ public virtual void EnrichDataLoaderBatchDispatchCoordinator(Activity activity) protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) { - if (operation is null) - { - return null; - } - - var selections = operation.RootSelectionSet.Selections; - var names = new string[selections.Length]; - - for (var i = 0; i < selections.Length; i++) - { - names[i] = selections[i].ResponseName; - } - - return BuildOperationDisplayName( - operation.Definition.Operation, - operation.Name, - names.Length, - names); + return operation is null + ? null + : BuildOperationDisplayName(operation.Definition.Operation, operation.Name); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index e9450965209..a706cc24a13 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -230,11 +230,7 @@ public override void OperationCost(RequestContext context, double fieldCost, dou Debug.Assert(value is not null, "The activity mustn't be null!"); var activity = (Activity)value; - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag("graphql.operation.id", documentInfo.Id.Value); - activity.SetTag("graphql.operation.fieldCost", fieldCost); - activity.SetTag("graphql.operation.typeCost", typeCost); + _enricher.EnrichOperationCost(context, activity, fieldCost, typeCost); } } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index cea207c493a..28b9c24684c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { sayHello }", + "DisplayName": "query SayHelloOperation", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.operation.type", @@ -34,16 +26,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -54,16 +54,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -74,7 +82,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -91,7 +99,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -102,7 +110,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -119,7 +127,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -130,7 +138,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/sayHello", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -141,17 +149,9 @@ "Key": "graphql.selection.name", "Value": "sayHello" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/sayHello" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/sayHello" + "Value": "sayHello" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index 236dcdbcf74..b24c0d59599 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { causeFatalError }", + "DisplayName": "query SayHelloOperation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" - }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "graphql.operation.type", @@ -38,16 +30,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -58,16 +58,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -78,7 +86,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -95,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -106,7 +114,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ { @@ -123,7 +131,7 @@ }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -134,7 +142,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/causeFatalError", + "DisplayName": "SimpleQuery.causeFatalError", "Status": "Error", "tags": [ { @@ -145,17 +153,9 @@ "Key": "graphql.selection.name", "Value": "causeFatalError" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/causeFatalError" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/causeFatalError" + "Value": "causeFatalError" }, { "Key": "graphql.selection.field.name", @@ -186,9 +186,13 @@ "Key": "exception.type", "Value": "GRAPHQL_ERROR" }, + { + "Key": "graphql.error.message", + "Value": "fail" + }, { "Key": "graphql.error.path", - "Value": "/causeFatalError" + "Value": "causeFatalError" } ] } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index b8576551dd2..1d979da5209 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "803df9346db185e9dc0b22dd3909aa70" - }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" }, { "Key": "graphql.document.body", @@ -26,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" }, { "Key": "otel.status_code", @@ -46,7 +50,7 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -57,9 +61,17 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" } ], "event": [ @@ -75,12 +87,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 21 + "Key": "graphql.error.message", + "Value": "The field `causeFatalError` does not exist on the type `Deeper`." }, { - "Key": "graphql.error.location.line", - "Value": 6 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 6, + "column": 21 + } + ] } ] } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap index fe926208055..82a9c3394bd 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" - }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -114,7 +114,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/a", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -125,17 +125,9 @@ "Key": "graphql.selection.name", "Value": "a" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/a" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/a" + "Value": "a" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap index 3cd67c910f5..f0bbdea328b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query GetA { a }", + "DisplayName": "query GetA", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "cee0e2939ece72d650cb0331f4be4669" - }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "graphql.operation.type", @@ -30,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -50,16 +50,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -70,7 +78,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +95,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -98,7 +106,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation GetA", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -115,7 +123,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -126,7 +134,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/a", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -137,17 +145,9 @@ "Key": "graphql.selection.name", "Value": "a" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/a" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/a" + "Value": "a" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap index cbd6c955b8f..2a381aad5ed 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a b c }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" - }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -114,7 +114,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/a", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -125,17 +125,9 @@ "Key": "graphql.selection.name", "Value": "a" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/a" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/a" + "Value": "a" }, { "Key": "graphql.selection.field.name", @@ -158,7 +150,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/b", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -169,17 +161,9 @@ "Key": "graphql.selection.name", "Value": "b" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/b" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/b" + "Value": "b" }, { "Key": "graphql.selection.field.name", @@ -202,7 +186,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/c", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -213,17 +197,9 @@ "Key": "graphql.selection.name", "Value": "c" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/c" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/c" + "Value": "c" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap index abc094e2f8d..171e08b9459 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a b c ... }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" - }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -114,7 +114,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/a", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -125,17 +125,9 @@ "Key": "graphql.selection.name", "Value": "a" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/a" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/a" + "Value": "a" }, { "Key": "graphql.selection.field.name", @@ -158,7 +150,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/b", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -169,17 +161,9 @@ "Key": "graphql.selection.name", "Value": "b" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/b" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/b" + "Value": "b" }, { "Key": "graphql.selection.field.name", @@ -202,7 +186,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/c", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -213,17 +197,9 @@ "Key": "graphql.selection.name", "Value": "c" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/c" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/c" + "Value": "c" }, { "Key": "graphql.selection.field.name", @@ -246,7 +222,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/d", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -257,17 +233,9 @@ "Key": "graphql.selection.name", "Value": "d" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/d" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/d" + "Value": "d" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index 8a2d9322e0b..bc26dff07ae 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { sayHello }", + "DisplayName": "query SayHelloOperation", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.operation.type", @@ -30,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -50,16 +50,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -70,7 +78,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +95,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -98,7 +106,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -115,7 +123,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -126,7 +134,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/sayHello", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -137,17 +145,9 @@ "Key": "graphql.selection.name", "Value": "sayHello" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/sayHello" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/sayHello" + "Value": "sayHello" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index 3b078cb9b83..46a89617361 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" - }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" }, { "Key": "graphql.document.body", @@ -26,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" }, { "Key": "otel.status_code", @@ -46,7 +50,7 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -57,9 +61,17 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" } ], "event": [ @@ -75,12 +87,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 27 + "Key": "graphql.error.message", + "Value": "The field `sayHello_` does not exist on the type `SimpleQuery`." }, { - "Key": "graphql.error.location.line", - "Value": 1 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 27 + } + ] } ] } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 33769d0516b..083c7614560 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -2,16 +2,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -22,7 +26,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -35,7 +39,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -46,7 +50,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/sayHello", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -57,17 +61,9 @@ "Key": "graphql.selection.name", "Value": "sayHello" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/sayHello" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/sayHello" + "Value": "sayHello" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index fa06636ab55..805d6d34b73 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -114,7 +114,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/sayHello", + "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ { @@ -125,17 +125,9 @@ "Key": "graphql.selection.name", "Value": "sayHello" }, - { - "Key": "graphql.selection.type", - "Value": "String!" - }, { "Key": "graphql.selection.path", - "Value": "/sayHello" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/sayHello" + "Value": "sayHello" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 872f311509d..32f2d534925 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "530cb46cabc38757c74c05cc7a96b636" - }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-530cb46cabc38757c74c05cc7a96b636" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "530cb46cabc38757c74c05cc7a96b636" + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -154,17 +150,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 123f5bb5133..24c02e2b527 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "a570a6bff748b5916eadf153261d9c6d" - }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-a570a6bff748b5916eadf153261d9c6d" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "a570a6bff748b5916eadf153261d9c6d" + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -154,17 +150,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index d48046891f6..1f3085c7a99 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Ok", "tags": [ { @@ -13,17 +13,9 @@ "Key": "graphql.http.request.type", "Value": "single" }, - { - "Key": "graphql.document.id", - "Value": "a570a6bff748b5916eadf153261d9c6d" - }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-a570a6bff748b5916eadf153261d9c6d" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "graphql.operation.type", @@ -55,16 +47,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -75,7 +71,7 @@ }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -88,7 +84,7 @@ }, { "Key": "graphql.document.hash", - "Value": "acb8d5d513c260b3cef3e3a12b0e29af" + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" }, { "Key": "otel.status_code", @@ -99,7 +95,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -110,17 +106,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index c2208c21893..32587281361 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" - }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -156,7 +152,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -167,7 +163,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -178,17 +174,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index ce8edba54f1..a5688f9f204 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -34,20 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" - }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "graphql.operation.type", @@ -67,16 +59,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -91,15 +87,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -112,7 +108,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -123,7 +119,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -136,7 +132,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -147,7 +143,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -160,7 +156,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -171,7 +167,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -182,17 +178,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 4d40516b142..ec6bd3d635f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "dd31323224a6428d4dc301134352aeab" - }, { "Key": "graphql.document.hash", - "Value": "3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-dd31323224a6428d4dc301134352aeab" + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "3beaca4ee1714ac9c9dfec8e445529df" + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "dd31323224a6428d4dc301134352aeab" + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "3beaca4ee1714ac9c9dfec8e445529df" + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "3beaca4ee1714ac9c9dfec8e445529df" + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -154,17 +150,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", @@ -187,7 +175,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero/id", + "DisplayName": "Droid.id", "Status": "Ok", "tags": [ { @@ -198,17 +186,9 @@ "Key": "graphql.selection.name", "Value": "id" }, - { - "Key": "graphql.selection.type", - "Value": "ID!" - }, { "Key": "graphql.selection.path", - "Value": "/hero/id" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero/id" + "Value": "hero.id" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 0592160ea8b..2aa08d54ff0 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "c0513b4b6f0cf7430f64de4aa3dcd7c6" - }, { "Key": "graphql.document.hash", - "Value": "668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-c0513b4b6f0cf7430f64de4aa3dcd7c6" + "Value": "md5:668e9631148921208d08dbb69513fa8e" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "668e9631148921208d08dbb69513fa8e" + "Value": "md5:668e9631148921208d08dbb69513fa8e" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "c0513b4b6f0cf7430f64de4aa3dcd7c6" + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "668e9631148921208d08dbb69513fa8e" + "Value": "md5:668e9631148921208d08dbb69513fa8e" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "668e9631148921208d08dbb69513fa8e" + "Value": "md5:668e9631148921208d08dbb69513fa8e" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -154,17 +150,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", @@ -187,7 +175,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero/friends", + "DisplayName": "Droid.friends", "Status": "Ok", "tags": [ { @@ -198,17 +186,9 @@ "Key": "graphql.selection.name", "Value": "friends" }, - { - "Key": "graphql.selection.type", - "Value": "FriendsConnection" - }, { "Key": "graphql.selection.path", - "Value": "/hero/friends" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero/friends" + "Value": "hero.friends" }, { "Key": "graphql.selection.field.name", @@ -231,7 +211,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero/friends/nodes[0]/friends", + "DisplayName": "Human.friends", "Status": "Ok", "tags": [ { @@ -242,17 +222,9 @@ "Key": "graphql.selection.name", "Value": "friends" }, - { - "Key": "graphql.selection.type", - "Value": "FriendsConnection" - }, { "Key": "graphql.selection.path", - "Value": "/hero/friends/nodes[0]/friends" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero/friends/nodes/friends" + "Value": "hero.friends.nodes[0].friends" }, { "Key": "graphql.selection.field.name", @@ -275,7 +247,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero/friends/nodes[1]/friends", + "DisplayName": "Human.friends", "Status": "Ok", "tags": [ { @@ -286,17 +258,9 @@ "Key": "graphql.selection.name", "Value": "friends" }, - { - "Key": "graphql.selection.type", - "Value": "FriendsConnection" - }, { "Key": "graphql.selection.path", - "Value": "/hero/friends/nodes[1]/friends" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero/friends/nodes/friends" + "Value": "hero.friends.nodes[1].friends" }, { "Key": "graphql.selection.field.name", @@ -319,7 +283,7 @@ }, { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero/friends/nodes[2]/friends", + "DisplayName": "Human.friends", "Status": "Ok", "tags": [ { @@ -330,17 +294,9 @@ "Key": "graphql.selection.name", "Value": "friends" }, - { - "Key": "graphql.selection.type", - "Value": "FriendsConnection" - }, { "Key": "graphql.selection.path", - "Value": "/hero/friends/nodes[2]/friends" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero/friends/nodes/friends" + "Value": "hero.friends.nodes[2].friends" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index a0ab4136d02..5c75565887d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -35,12 +35,17 @@ "Value": "HC0011" }, { - "Key": "graphql.error.location.column", - "Value": 37 + "Key": "graphql.error.message", + "Value": "Found a NameStart character `n` (110) following a number, which is disallowed." }, { - "Key": "graphql.error.location.line", - "Value": 10 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 10, + "column": 37 + } + ] } ] } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index c2208c21893..32587281361 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" - }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -87,15 +83,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -108,7 +104,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -119,7 +115,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -132,7 +128,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -143,7 +139,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -156,7 +152,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -167,7 +163,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -178,17 +174,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 19dcf087576..574b90aa608 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -34,20 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { hero }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" - }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.id", - "Value": "_Default-1-1d4bca4d0dff630390ddf48e9085589d" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "graphql.operation.type", @@ -67,16 +59,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -91,15 +87,15 @@ "Status": "Unset", "tags": [ { - "Key": "graphql.operation.id", - "Value": "1d4bca4d0dff630390ddf48e9085589d" + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" } ], "event": [] }, { "OperationName": "CompileOperation", - "DisplayName": "Compile Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -112,7 +108,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -123,7 +119,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -136,7 +132,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -147,7 +143,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -160,7 +156,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cc68dfd8c0c54a586a03c35296c5d1f9" + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" }, { "Key": "otel.status_code", @@ -171,7 +167,7 @@ "activities": [ { "OperationName": "ResolveFieldValue", - "DisplayName": "/hero", + "DisplayName": "Query.hero", "Status": "Ok", "tags": [ { @@ -182,17 +178,9 @@ "Key": "graphql.selection.name", "Value": "hero" }, - { - "Key": "graphql.selection.type", - "Value": "Character" - }, { "Key": "graphql.selection.path", - "Value": "/hero" - }, - { - "Key": "graphql.selection.hierarchy", - "Value": "/hero" + "Value": "hero" }, { "Key": "graphql.selection.field.name", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index 22d387d7a6e..8bd46ce8dbe 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -35,12 +35,17 @@ "Value": "HC0011" }, { - "Key": "graphql.error.location.column", - "Value": 21 + "Key": "graphql.error.message", + "Value": "Expected a `Name`-token, but found a `Integer`-token." }, { - "Key": "graphql.error.location.line", - "Value": 3 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 3, + "column": 21 + } + ] } ] } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 358ee333471..11c6ee7be6c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "e2b13c5332af8a70da160fcb96894e5c" - }, { "Key": "graphql.document.hash", - "Value": "346f68539881f0624dca2927281d1a2f" + "Value": "md5:346f68539881f0624dca2927281d1a2f" }, { "Key": "otel.status_code", @@ -50,7 +46,7 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -61,9 +57,13 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "346f68539881f0624dca2927281d1a2f" + "Value": "md5:346f68539881f0624dca2927281d1a2f" } ], "event": [ @@ -79,12 +79,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 21 + "Key": "graphql.error.message", + "Value": "The field `abc` does not exist on the type `Query`." }, { - "Key": "graphql.error.location.line", - "Value": 3 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 3, + "column": 21 + } + ] } ] } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index 02e89b33b9f..ea6e6fe6a95 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -1,5 +1,6 @@ using System.Collections.Frozen; using System.Diagnostics; +using System.Globalization; using System.Text; using Microsoft.Extensions.ObjectPool; using HotChocolate.Diagnostics; @@ -46,45 +47,63 @@ public virtual void EnrichExecuteRequest(RequestContext context, Activity activi public virtual void EnrichParseDocument(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); + var operationDefinition = ResolveOperationDefinition( + plan?.Operation.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichParseDocumentCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); + EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); + var operationDefinition = ResolveOperationDefinition( + plan?.Operation.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichValidateDocumentCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); + EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); + var operationDefinition = ResolveOperationDefinition( + plan?.Operation.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - EnrichCoerceVariablesCore(activity, plan?.Operation.Definition, context.OperationDocumentInfo); + EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichPlanOperationScope(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); + var operationDefinition = ResolveOperationDefinition( + plan?.Operation.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); - activity.DisplayName = "Plan Operation"; + activity.DisplayName = "GraphQL Operation Planning"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - EnrichWithTags(activity, plan?.Operation.Definition, context.OperationDocumentInfo); + EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) { var plan = context.GetOperationPlan(); - activity.DisplayName = - plan?.OperationName is { } op - ? $"Execute Operation {op}" - : "Execute Operation"; + var operationDefinition = ResolveOperationDefinition( + plan?.Operation.Definition, + context.OperationDocumentInfo, + context.Request.OperationName); + + activity.DisplayName = "GraphQL Operation Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - EnrichWithTags(activity, plan?.Operation.Definition, context.OperationDocumentInfo); + EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichExecuteOperationNode( @@ -93,7 +112,7 @@ public virtual void EnrichExecuteOperationNode( string schemaName, Activity activity) { - activity.DisplayName = $"Execute Operation Node ({schemaName})"; + activity.DisplayName = "GraphQL Step Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); EnrichOperationWithTags( @@ -111,7 +130,7 @@ public virtual void EnrichExecuteOperationBatchNode( string schemaName, Activity activity) { - activity.DisplayName = $"Execute Operation Batch Node ({schemaName})"; + activity.DisplayName = "GraphQL Step Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); EnrichOperationWithTags( @@ -128,7 +147,7 @@ public virtual void EnrichExecuteNodeFieldNode( NodeFieldExecutionNode node, Activity activity) { - activity.DisplayName = "Execute Node Field Node"; + activity.DisplayName = "GraphQL Step Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); EnrichNodeWithTags(activity, node, context.OperationPlan); @@ -139,7 +158,7 @@ public virtual void EnrichExecuteIntrospectionNode( IntrospectionExecutionNode node, Activity activity) { - activity.DisplayName = "Execute Introspection Node"; + activity.DisplayName = "GraphQL Step Execution"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); EnrichNodeWithTags(activity, node, context.OperationPlan); @@ -162,24 +181,9 @@ public virtual void EnrichSourceSchemaError( protected virtual string? CreateOperationDisplayName(RequestContext context, OperationPlan? plan) { - if (plan is null) - { - return null; - } - - var selections = plan.Operation.RootSelectionSet.Selections; - var names = new string[selections.Length]; - - for (var i = 0; i < selections.Length; i++) - { - names[i] = selections[i].ResponseName; - } - - return BuildOperationDisplayName( - plan.Operation.Definition.Operation, - plan.OperationName, - names.Length, - names); + return plan is null + ? null + : BuildOperationDisplayName(plan.Operation.Definition.Operation, plan.OperationName); } private static void EnrichOperationWithTags( @@ -199,7 +203,7 @@ private static void EnrichOperationWithTags( activity.SetTag(GraphQL.Operation.Name, plan.OperationName); } - activity.SetTag(GraphQL.Document.Hash, operationDocumentInfo.Hash.Value); + activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(operationDocumentInfo.Hash)); activity.SetTag(GraphQL.Source.Name, schemaName); activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); @@ -209,7 +213,7 @@ private static void EnrichOperationWithTags( private static void EnrichNodeWithTags(Activity activity, ExecutionNode node, OperationPlan plan) { - activity.SetTag(GraphQL.Operation.Step.Id, node.Id); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); activity.SetTag(GraphQL.Operation.Step.Plan.Id, plan.Id); } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index 1834d40e920..c24c4fe1dfe 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { sayHello }", + "DisplayName": "query SayHelloOperation", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.id", - "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.operation.type", @@ -34,16 +26,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -54,16 +54,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -74,7 +82,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -91,7 +99,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -102,7 +110,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -119,7 +127,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -130,13 +138,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -155,7 +167,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index bc4611185af..8d75efb8373 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { causeFatalError }", + "DisplayName": "query SayHelloOperation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" - }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "graphql.operation.id", - "Value": "5f75eb886568e255310bed3eb3e1f7f1c91f1a22f71ac7c36f00d8df27400d8e" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "graphql.operation.type", @@ -38,16 +30,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -58,16 +58,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -78,7 +86,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -95,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -106,7 +114,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ { @@ -123,7 +131,7 @@ }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "otel.status_code", @@ -134,13 +142,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -159,7 +171,7 @@ }, { "Key": "graphql.document.hash", - "Value": "851fb754d9ba6b5cc5a55ebcbea2621d" + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index b8576551dd2..1d979da5209 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "803df9346db185e9dc0b22dd3909aa70" - }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" }, { "Key": "graphql.document.body", @@ -26,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" }, { "Key": "otel.status_code", @@ -46,7 +50,7 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -57,9 +61,17 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "803df9346db185e9dc0b22dd3909aa70" + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" } ], "event": [ @@ -75,12 +87,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 21 + "Key": "graphql.error.message", + "Value": "The field `causeFatalError` does not exist on the type `Deeper`." }, { - "Key": "graphql.error.location.line", - "Value": 6 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 6, + "column": 21 + } + ] } ] } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap index f8878620d6d..2a09e4799e4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" - }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "graphql.operation.id", - "Value": "91d3f369067488892e5c81c27598c0d43b5ecfe5ad824925965ac60c70351919" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "452ea802c4d1bf2a81a7411b0b361d9f" + "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap index a3deebad311..e98e0aba956 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query GetA { a }", + "DisplayName": "query GetA", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "cee0e2939ece72d650cb0331f4be4669" - }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "graphql.operation.id", - "Value": "155189958e55686347a7f921c0f7a1ef143f829f5b116365a297651606d5703f" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "graphql.operation.type", @@ -30,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -50,16 +50,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetA" + }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -70,7 +78,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +95,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -98,7 +106,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation GetA", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -115,7 +123,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "otel.status_code", @@ -126,13 +134,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -151,7 +163,7 @@ }, { "Key": "graphql.document.hash", - "Value": "cee0e2939ece72d650cb0331f4be4669" + "Value": "md5:cee0e2939ece72d650cb0331f4be4669" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap index 5258c929fe8..2af5ebb43cb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a b c }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" - }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "graphql.operation.id", - "Value": "8b26a2633c9b68833461d6b2249f54600493dfc632399469d5c108e79410ca7b" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "2e55fbe10a9e3ddf26935a8f8d15ec89" + "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap index d9ed8976b32..c8a394ccd41 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { a b c ... }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" - }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "graphql.operation.id", - "Value": "1c020b5562fde1e7673b1f4750bdf6d35f2789819d03bb6b5d088bf445231501" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "a5f924bb2f5f8651014e92e1cc2428c7" + "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index e8946f82a2b..bcba591c833 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation { sayHello }", + "DisplayName": "query SayHelloOperation", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.id", - "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.operation.type", @@ -30,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -50,16 +50,24 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -70,7 +78,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +95,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -98,7 +106,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation SayHelloOperation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -115,7 +123,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "otel.status_code", @@ -126,13 +134,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -151,7 +163,7 @@ }, { "Key": "graphql.document.hash", - "Value": "6af18618ae20c266f6ffc352b78cb69b" + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index 070b1c738ca..0adb46c6d65 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" - }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" }, { "Key": "graphql.document.body", @@ -26,16 +22,24 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" }, { "Key": "otel.status_code", @@ -46,7 +50,7 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -57,9 +61,17 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", - "Value": "bb1d246465341a97bdc727d6cd8ead5c" + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" } ], "event": [ @@ -75,12 +87,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 27 + "Key": "graphql.error.message", + "Value": "The field `sayHello_` does not exist on the type `Query`." }, { - "Key": "graphql.error.location.line", - "Value": 1 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 27 + } + ] } ] } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 36a0581e3ac..fb303651688 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -34,16 +26,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -54,16 +50,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -74,7 +74,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +87,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -98,7 +98,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ { @@ -111,7 +111,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -122,13 +122,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -143,7 +147,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 6aa950521fc..b420122648b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello sayGoodbye }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "073bf7696c078e52587c88890ef21bbe" - }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "graphql.operation.id", - "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "graphql.source.name", @@ -162,13 +166,17 @@ }, { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (b)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "2" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -183,7 +191,7 @@ }, { "Key": "graphql.document.hash", - "Value": "073bf7696c078e52587c88890ef21bbe" + "Value": "md5:073bf7696c078e52587c88890ef21bbe" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index eaab3f712e6..45ea1e6f1d7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -2,16 +2,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -22,7 +26,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -35,7 +39,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -46,13 +50,17 @@ }, { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -67,7 +75,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 43d2bac42c5..dc988cb37e7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 43d2bac42c5..dc988cb37e7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -26,16 +18,20 @@ "activities": [ { "OperationName": "ParseDocument", - "DisplayName": "Parse Document", + "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "parse" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -46,16 +42,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -66,7 +66,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -79,7 +79,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -90,7 +90,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -103,7 +103,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -114,13 +114,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -135,7 +139,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 1c931da2361..58d0ce937c4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -83,7 +79,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -96,7 +92,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -107,7 +103,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -120,7 +116,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -131,13 +127,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -152,7 +152,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 5c1a9563ccd..1b684b9db01 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { greeting }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" - }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -83,7 +79,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -96,7 +92,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -107,7 +103,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -120,7 +116,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -131,7 +127,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -144,7 +140,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -155,13 +151,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -176,7 +176,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index d2467991da7..39f5a3227e2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -34,20 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { greeting }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" - }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.operation.type", @@ -67,16 +59,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -87,7 +83,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -100,7 +96,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -111,7 +107,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -124,7 +120,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -135,7 +131,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -148,7 +144,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -159,13 +155,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -180,7 +180,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index 28a52eca1ac..e38b50e4018 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -35,12 +35,17 @@ "Value": "HC0011" }, { - "Key": "graphql.error.location.column", - "Value": 13 + "Key": "graphql.error.message", + "Value": "Found a NameStart character `d` (100) following a number, which is disallowed." }, { - "Key": "graphql.error.location.line", - "Value": 4 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 4, + "column": 13 + } + ] } ] } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 29abcc0e09a..b98fbc938f3 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,9 +2,18 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "ExecuteHttpRequest", - "Status": "Unset", - "tags": [], + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], "event": [], "activities": [ { @@ -21,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -54,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -74,7 +79,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -87,7 +92,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -98,7 +103,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -111,7 +116,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -122,13 +127,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -143,7 +152,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index b8d858c68be..9ce4ae617ed 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "query { sayHello }", + "DisplayName": "query", "Status": "Ok", "tags": [ { @@ -13,17 +13,9 @@ "Key": "graphql.http.request.type", "Value": "single" }, - { - "Key": "graphql.document.id", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.operation.type", @@ -55,16 +47,20 @@ }, { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -75,7 +71,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -88,7 +84,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "otel.status_code", @@ -99,13 +95,17 @@ }, { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -120,7 +120,7 @@ }, { "Key": "graphql.document.hash", - "Value": "f7e9989fbb67af7fa747a9983313c9e5" + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 5c1a9563ccd..1b684b9db01 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -30,20 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { greeting }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" - }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.operation.type", @@ -63,16 +55,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -83,7 +79,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -96,7 +92,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -107,7 +103,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -120,7 +116,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -131,7 +127,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -144,7 +140,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -155,13 +151,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -176,7 +176,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 9ea8c97c3da..e0b763f3881 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -34,20 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query { greeting }", + "DisplayName": "query", "Status": "Unset", "tags": [ - { - "Key": "graphql.document.id", - "Value": "bfa5986a5299f46421057dd3eb27ec5c" - }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.operation.type", @@ -67,16 +59,20 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -87,7 +83,7 @@ }, { "OperationName": "PlanOperation", - "DisplayName": "Plan Operation", + "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ { @@ -100,7 +96,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -111,7 +107,7 @@ }, { "OperationName": "CoerceVariables", - "DisplayName": "Coerce Variables", + "DisplayName": "GraphQL Variable Coercion", "Status": "Ok", "tags": [ { @@ -124,7 +120,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -135,7 +131,7 @@ }, { "OperationName": "ExecuteOperation", - "DisplayName": "Execute Operation", + "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ { @@ -148,7 +144,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "otel.status_code", @@ -159,13 +155,17 @@ "activities": [ { "OperationName": "ExecuteOperationNode", - "DisplayName": "Execute Operation Node (a)", + "DisplayName": "GraphQL Step Execution", "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, { "Key": "graphql.operation.step.kind", "Value": "operation" @@ -180,7 +180,7 @@ }, { "Key": "graphql.document.hash", - "Value": "c46cf8c9811934ddea095f10ee722dc4" + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" }, { "Key": "graphql.source.name", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index d2cbe8b5ad6..acf40a7ecb2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -35,12 +35,17 @@ "Value": "HC0011" }, { - "Key": "graphql.error.location.column", - "Value": 3 + "Key": "graphql.error.message", + "Value": "Expected a `Name`-token, but found a `Integer`-token." }, { - "Key": "graphql.error.location.line", - "Value": 1 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] } ] } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index ea8ec609e70..90c5e6da598 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "Execute Request", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.document.id", - "Value": "346f68539881f0624dca2927281d1a2f" - }, { "Key": "graphql.document.hash", - "Value": "346f68539881f0624dca2927281d1a2f" + "Value": "md5:346f68539881f0624dca2927281d1a2f" }, { "Key": "otel.status_code", @@ -50,7 +46,7 @@ "activities": [ { "OperationName": "ValidateDocument", - "DisplayName": "Validate Document", + "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ { @@ -61,9 +57,13 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", - "Value": "346f68539881f0624dca2927281d1a2f" + "Value": "md5:346f68539881f0624dca2927281d1a2f" } ], "event": [ @@ -79,12 +79,17 @@ "Value": "GRAPHQL_ERROR" }, { - "Key": "graphql.error.location.column", - "Value": 3 + "Key": "graphql.error.message", + "Value": "The field `abc` does not exist on the type `Query`." }, { - "Key": "graphql.error.location.line", - "Value": 1 + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] } ] } From 3f8e8c7b2703cddcfa5476a4a209ac3f8bfc32f3 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 15:56:00 +0100 Subject: [PATCH 09/37] More cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 89 ++------------- .../src/Diagnostics/ActivityEnricher.cs | 69 +++++------- .../FusionActivityEnricher.cs | 102 ++++++------------ 3 files changed, 71 insertions(+), 189 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 66cdf19be82..fa43e3cb7c0 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -323,12 +323,11 @@ public virtual void EnrichOperationCost( protected void EnrichExecuteRequestCore( RequestContext context, Activity activity, - string? operationDisplayName, - object? operationId, - OperationType? operationType, + string operationDisplayName, + OperationType operationType, string? operationName) { - activity.DisplayName = operationDisplayName ?? "GraphQL Operation"; + activity.DisplayName = operationDisplayName; var documentInfo = context.OperationDocumentInfo; activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); @@ -338,16 +337,11 @@ protected void EnrichExecuteRequestCore( activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - if (operationType is not null) - { - activity.SetTag( - GraphQL.Operation.Type, - GraphQL.Operation.TypeValues[operationType.Value]); + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); } if (options.IncludeDocument && documentInfo.Document is not null) @@ -413,7 +407,7 @@ protected static void EnrichWithTags( } } - protected string BuildOperationDisplayName( + protected string GetOperationDisplayName( OperationType operationType, string? operationName) { @@ -426,22 +420,6 @@ protected string BuildOperationDisplayName( return operationTypeName; } - protected virtual string CreateRootActivityName( - Activity activity, - Activity root, - string displayName) - { - const string key = "originalDisplayName"; - - if (root.GetCustomProperty(key) is not string rootDisplayName) - { - rootDisplayName = root.DisplayName; - root.SetCustomProperty(key, rootDisplayName); - } - - return $"{rootDisplayName}: {displayName}"; - } - protected virtual void EnrichError(IError error, Activity activity) { if (error.Exception is { } exception) @@ -480,55 +458,7 @@ protected virtual void EnrichError(IError error, Activity activity) activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); } - protected static OperationDefinitionNode? ResolveOperationDefinition( - OperationDefinitionNode? operationDefinition, - OperationDocumentInfo documentInfo, - string? operationName) - { - if (operationDefinition is not null) - { - return operationDefinition; - } - - if (documentInfo.Document is not { } document) - { - return null; - } - - if (string.IsNullOrEmpty(operationName)) - { - OperationDefinitionNode? singleOperation = null; - - foreach (var definition in document.Definitions) - { - if (definition is not OperationDefinitionNode operation) - { - continue; - } - - if (singleOperation is not null) - { - return null; - } - - singleOperation = operation; - } - - return singleOperation; - } - - foreach (var definition in document.Definitions) - { - if (definition is OperationDefinitionNode operation - && string.Equals(operation.Name?.Value, operationName, StringComparison.Ordinal)) - { - return operation; - } - } - - return null; - } - + // TODO: Get rid of this protected internal static string FormatDocumentHash(OperationDocumentHash hash) { if (hash.IsEmpty || string.IsNullOrEmpty(hash.AlgorithmName)) @@ -547,6 +477,7 @@ protected internal static string FormatDocumentHash(OperationDocumentHash hash) if (algorithm == "sha256") { + // TODO: wtf algorithm = "sha25"; } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 8aa222496c8..303c060b85f 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -3,7 +3,6 @@ using Microsoft.Extensions.ObjectPool; using GreenDonut; using HotChocolate.Execution; -using HotChocolate.Execution.Processing; using HotChocolate.Resolvers; using static HotChocolate.Diagnostics.SemanticConventions; @@ -20,25 +19,25 @@ public class ActivityEnricher( { public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { - context.TryGetOperation(out var operation); - var operationDisplayName = CreateOperationDisplayName(context, operation); - - EnrichExecuteRequestCore( - context, - activity, - operationDisplayName, - operation?.Id, - operation?.Kind, - operation?.Name); + // TODO: We won't ever have this here... + if (context.TryGetOperation(out var operation)) + { + var operationDisplayName = GetOperationDisplayName(operation.Kind, operation.Name); + + EnrichExecuteRequestCore( + context, + activity, + operationDisplayName, + operation.Kind, + operation.Name); + } } public virtual void EnrichParseDocument(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - var operationDefinition = ResolveOperationDefinition( - operation?.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + // TODO: We won't ever have this here... + var operationDefinition = operation?.Definition; EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } @@ -46,10 +45,8 @@ public virtual void EnrichParseDocument(RequestContext context, Activity activit public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - var operationDefinition = ResolveOperationDefinition( - operation?.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + // TODO: We won't ever have this here... + var operationDefinition = operation?.Definition; EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } @@ -57,10 +54,8 @@ public virtual void EnrichValidateDocument(RequestContext context, Activity acti public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - var operationDefinition = ResolveOperationDefinition( - operation?.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + // TODO: We won't ever have this here... + var operationDefinition = operation?.Definition; EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); } @@ -68,10 +63,8 @@ public virtual void EnrichCoerceVariables(RequestContext context, Activity activ public virtual void EnrichCompileOperation(RequestContext context, Activity activity) { context.TryGetOperation(out var operation); - var operationDefinition = ResolveOperationDefinition( - operation?.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + // TODO: We won't ever have this here... + var operationDefinition = operation?.Definition; activity.DisplayName = "GraphQL Operation Planning"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); @@ -81,17 +74,14 @@ public virtual void EnrichCompileOperation(RequestContext context, Activity acti public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) { - context.TryGetOperation(out var operation); - var operationDefinition = ResolveOperationDefinition( - operation?.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); - - activity.DisplayName = "GraphQL Operation Execution"; + if (context.TryGetOperation(out var operation)) + { + activity.DisplayName = "GraphQL Operation Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); + EnrichWithTags(activity, operation.Definition, context.OperationDocumentInfo); + } } public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity activity) @@ -143,11 +133,4 @@ public virtual void EnrichDataLoaderBatchDispatchCoordinator(Activity activity) activity.DisplayName = "Coordinate DataLoader Batches"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); } - - protected virtual string? CreateOperationDisplayName(RequestContext context, Operation? operation) - { - return operation is null - ? null - : BuildOperationDisplayName(operation.Definition.Operation, operation.Name); - } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index ea6e6fe6a95..e3adda4d11d 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -32,58 +32,54 @@ public class FusionActivityEnricher( public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) { - var plan = context.GetOperationPlan(); - var operationDisplayName = CreateOperationDisplayName(context, plan); - - EnrichExecuteRequestCore( - context, - activity, - operationDisplayName, - plan?.Id, - plan?.Operation.Definition.Operation, - plan?.OperationName); + // TODO: We won't ever have this here... + if (context.GetOperationPlan() is { } plan) + { + var operationType = plan.Operation.Definition.Operation; + var operationName = plan.OperationName; + var operationDisplayName = GetOperationDisplayName(operationType, operationName); + + EnrichExecuteRequestCore( + context, + activity, + operationDisplayName, + operationType, + operationName); + } } public virtual void EnrichParseDocument(RequestContext context, Activity activity) { + // TODO: We won't ever have this here... var plan = context.GetOperationPlan(); - var operationDefinition = ResolveOperationDefinition( - plan?.Operation.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + var operationDefinition = plan?.Operation.Definition; EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichValidateDocument(RequestContext context, Activity activity) { + // TODO: We won't ever have this here... var plan = context.GetOperationPlan(); - var operationDefinition = ResolveOperationDefinition( - plan?.Operation.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + var operationDefinition = plan?.Operation.Definition; EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) { + // TODO: We won't ever have this here... var plan = context.GetOperationPlan(); - var operationDefinition = ResolveOperationDefinition( - plan?.Operation.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + var operationDefinition = plan?.Operation.Definition; EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); } public virtual void EnrichPlanOperationScope(RequestContext context, Activity activity) { + // TODO: We won't ever have this here... var plan = context.GetOperationPlan(); - var operationDefinition = ResolveOperationDefinition( - plan?.Operation.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); + var operationDefinition = plan?.Operation.Definition; activity.DisplayName = "GraphQL Operation Planning"; activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); @@ -93,17 +89,13 @@ public virtual void EnrichPlanOperationScope(RequestContext context, Activity ac public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) { - var plan = context.GetOperationPlan(); - var operationDefinition = ResolveOperationDefinition( - plan?.Operation.Definition, - context.OperationDocumentInfo, - context.Request.OperationName); - - activity.DisplayName = "GraphQL Operation Execution"; - - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + if (context.GetOperationPlan() is { } plan) + { + activity.DisplayName = "GraphQL Operation Execution"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); + EnrichWithTags(activity, plan.Operation.Definition, context.OperationDocumentInfo); + } } public virtual void EnrichExecuteOperationNode( @@ -111,58 +103,38 @@ public virtual void EnrichExecuteOperationNode( OperationExecutionNode node, string schemaName, Activity activity) - { - activity.DisplayName = "GraphQL Step Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - - EnrichOperationWithTags( + => EnrichOperationWithTags( activity, context.OperationPlan, node, node.Operation, context.RequestContext.OperationDocumentInfo, schemaName); - } public virtual void EnrichExecuteOperationBatchNode( OperationPlanContext context, OperationBatchExecutionNode node, string schemaName, Activity activity) - { - activity.DisplayName = "GraphQL Step Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - - EnrichOperationWithTags( + => EnrichOperationWithTags( activity, context.OperationPlan, node, node.Operation, context.RequestContext.OperationDocumentInfo, schemaName); - } public virtual void EnrichExecuteNodeFieldNode( OperationPlanContext context, NodeFieldExecutionNode node, Activity activity) - { - activity.DisplayName = "GraphQL Step Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - - EnrichNodeWithTags(activity, node, context.OperationPlan); - } + => EnrichNodeWithTags(activity, node, context.OperationPlan); public virtual void EnrichExecuteIntrospectionNode( OperationPlanContext context, IntrospectionExecutionNode node, Activity activity) - { - activity.DisplayName = "GraphQL Step Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - - EnrichNodeWithTags(activity, node, context.OperationPlan); - } + => EnrichNodeWithTags(activity, node, context.OperationPlan); public virtual void EnrichExecutionNodeError( OperationPlanContext context, @@ -179,13 +151,6 @@ public virtual void EnrichSourceSchemaError( Activity activity) => activity.RecordException(error); - protected virtual string? CreateOperationDisplayName(RequestContext context, OperationPlan? plan) - { - return plan is null - ? null - : BuildOperationDisplayName(plan.Operation.Definition.Operation, plan.OperationName); - } - private static void EnrichOperationWithTags( Activity activity, OperationPlan plan, @@ -213,6 +178,9 @@ private static void EnrichOperationWithTags( private static void EnrichNodeWithTags(Activity activity, ExecutionNode node, OperationPlan plan) { + activity.DisplayName = "GraphQL Step Execution"; + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); activity.SetTag(GraphQL.Operation.Step.Plan.Id, plan.Id); From dbdca5dc0d70870eba2106159862ccd720439a6a Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:16:12 +0100 Subject: [PATCH 10/37] wip: refactor --- .../Pipeline/AuthorizeRequestMiddleware.cs | 2 +- .../Extensions/RequestContextExtensions.cs | 2 +- .../Core/src/Execution.Abstractions/Path.cs | 20 +- .../AggregateExecutionDiagnosticEvents.cs | 44 --- .../IExecutionDiagnosticEvents.cs | 58 --- .../ErrorBuilderTests.cs | 4 +- .../ErrorTests.cs | 2 +- .../Execution.Abstractions.Tests/PathTests.cs | 37 +- .../CostAnalysis/CostAnalyzerMiddleware.cs | 2 +- .../Diagnostics.Core/ActivityEnricherBase.cs | 243 ++---------- .../Extensions/ActivityExtensions.cs | 68 ++++ .../Extensions/DocumentNodeExtensions.cs | 51 +++ .../src/Diagnostics.Core/RequestDetails.cs | 4 +- .../Diagnostics.Core/SemanticConventions.cs | 11 +- .../Spans/AnalyzeOperationComplexitySpan.cs | 67 ++++ .../Spans/ExecuteOperationSpan.cs | 63 +++ .../Spans/ExecuteRequestSpan.cs | 69 ++++ .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 57 +++ .../src/Diagnostics.Core/Spans/SpanBase.cs | 24 ++ .../Diagnostics.Core/Spans/ValidationSpan.cs | 58 +++ .../Spans/VariableCoercionSpan.cs | 59 +++ .../src/Diagnostics/ActivityEnricher.cs | 128 +------ .../src/Diagnostics/ContextKeys.cs | 13 - .../ActivityDataLoaderDiagnosticListener.cs | 24 +- .../ActivityExecutionDiagnosticListener.cs | 283 +++++--------- .../Scopes/AnalyzeOperationComplexityScope.cs | 18 - .../Scopes/CoerceVariablesScope.cs | 28 -- .../Scopes/CompileOperationScope.cs | 28 -- ...DataLoaderBatchDispatchCoordinatorScope.cs | 28 -- .../Scopes/DataLoaderBatchScope.cs | 35 -- .../Scopes/ExecuteOperationScope.cs | 33 -- .../Diagnostics/Scopes/ExecuteRequestScope.cs | 28 -- .../Diagnostics/Scopes/ParseDocumentScope.cs | 28 -- .../Diagnostics/Scopes/RequestScopeBase.cs | 40 -- .../Scopes/ValidateDocumentScope.cs | 28 -- .../Diagnostics/Spans/CompileOperationSpan.cs | 57 +++ .../Diagnostics/Spans/DataLoaderBatchSpan.cs | 30 ++ .../Spans/DataLoaderDispatchSpan.cs | 23 ++ .../src/Diagnostics/Spans/ResolveFieldSpan.cs | 41 ++ .../QueryInstrumentationTests.cs | 68 ---- ...h_Dispatch_Coordinator_Emits_Activity.snap | 2 +- ...ch_Coordinator_Tracks_Dispatch_Events.snap | 2 +- ...onTests.Allow_document_to_be_captured.snap | 26 +- ...r_error_that_deletes_the_whole_result.snap | 34 +- ...or_that_deletes_the_whole_result_deep.snap | 24 -- ...e_operation_display_name_with_1_field.snap | 156 -------- ...tion_display_name_with_1_field_and_op.snap | 176 --------- ...e_operation_display_name_with_3_field.snap | 228 ----------- ...e_operation_display_name_with_4_field.snap | 264 ------------- ...peration_name_is_used_as_request_name.snap | 26 +- ...lidation_activity_has_an_error_status.snap | 24 -- ...rack_events_of_a_simple_query_default.snap | 4 - ...ack_events_of_a_simple_query_detailed.snap | 14 +- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 19 +- ...s.Http_Post_SingleRequest_GetHeroName.snap | 19 +- ...ost_SingleRequest_GetHeroName_Default.snap | 10 +- ....Http_Post_add_query_to_http_activity.snap | 19 +- ...p_Post_add_variables_to_http_activity.snap | 19 +- ...s.Http_Post_capture_deferred_response.snap | 19 +- ...t_ensure_list_path_is_correctly_built.snap | 19 +- ...mentationTests.Http_Post_parser_error.snap | 8 +- ...not_automatically_added_to_activities.snap | 19 +- ...onTests.Http_Post_with_extensions_map.snap | 19 +- ...g_error_when_rename_root_is_activated.snap | 8 +- ...n_error_when_rename_root_is_activated.snap | 12 - .../src/Fusion.Diagnostics/ContextKeys.cs | 10 - ...agnosticsFusionGatewayBuilderExtensions.cs | 2 +- .../FusionActivityEnricher.cs | 178 +-------- .../HotChocolateFusionActivitySource.cs | 4 +- ...yFusionExecutionDiagnosticEventListener.cs | 358 ------------------ ...ctivityExecutionDiagnosticEventListener.cs | 277 ++++++++++++++ .../FusionActivityServerDiagnosticListener.cs | 1 - .../Scopes/CoerceVariablesScope.cs | 24 -- .../Scopes/ExecuteIntrospectionNodeScope.cs | 23 -- .../Scopes/ExecuteNodeFieldNodeScope.cs | 23 -- .../Scopes/ExecuteOperationBatchNodeScope.cs | 24 -- .../Scopes/ExecuteOperationNodeScope.cs | 24 -- .../Scopes/ExecuteOperationScope.cs | 29 -- .../Scopes/ExecuteRequestScope.cs | 24 -- .../Scopes/NodeScopeBase.cs | 40 -- .../Scopes/ParseDocumentScope.cs | 24 -- .../Scopes/PlanOperationScope.cs | 24 -- .../Scopes/RequestScopeBase.cs | 40 -- .../Scopes/ValidateDocumentScope.cs | 24 -- .../Spans/ExecutePlanNodeSpan.cs | 64 ++++ .../Spans/PlanOperationSpan.cs | 57 +++ .../Extensions/OperationResolverHelper.cs | 44 ++- .../HotChocolate.Fusion.Utilities.csproj | 1 + .../QueryInstrumentationTests.cs | 124 ------ ...onTests.Allow_Document_To_Be_Captured.snap | 28 +- ...r_Error_That_Deletes_The_Whole_Result.snap | 28 +- ...or_That_Deletes_The_Whole_Result_Deep.snap | 24 -- ...e_Operation_Display_Name_With_1_Field.snap | 172 --------- ...tion_Display_Name_With_1_Field_And_Op.snap | 196 ---------- ...e_Operation_Display_Name_With_3_Field.snap | 172 --------- ...e_Operation_Display_Name_With_4_Field.snap | 172 --------- ...peration_Name_Is_Used_As_Request_Name.snap | 28 +- ...lidation_Activity_Has_An_Error_Status.snap | 24 -- ...onTests.Source_Schema_Transport_Error.snap | 16 +- ...ents_Of_A_Query_With_Multiple_Sources.snap | 18 +- ...rack_Events_Of_A_Simple_Query_Default.snap | 6 +- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 16 +- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 16 +- ...entationTests.Http_Get_Single_Request.snap | 12 +- ....Http_Post_Add_Query_To_Http_Activity.snap | 12 +- ...p_Post_Add_Variables_To_Http_Activity.snap | 12 +- ...mentationTests.Http_Post_Parser_Error.snap | 8 +- ...ntationTests.Http_Post_Single_Request.snap | 27 +- ...ests.Http_Post_Single_Request_Default.snap | 12 +- ...Not_Automatically_Added_To_Activities.snap | 12 +- ...onTests.Http_Post_With_Extensions_Map.snap | 12 +- ...g_Error_When_Rename_Root_Is_Activated.snap | 8 +- ...n_Error_When_Rename_Root_Is_Activated.snap | 12 - .../Language.Web/DocumentHashProviderBase.cs | 8 +- .../src/Language.Web/IDocumentHashProvider.cs | 5 + .../Language.Web/MD5DocumentHashProvider.cs | 2 + .../Language.Web/Sha1DocumentHashProvider.cs | 2 + .../Sha256DocumentHashProvider.cs | 2 + .../Language.Web/Utf8GraphQLRequestParser.cs | 2 +- .../Utf8GraphQLRequestParserTests.cs | 2 +- .../ReadPersistedOperationMiddleware.cs | 2 +- .../v16/migrating/migrate-from-15-to-16.md | 8 +- 122 files changed, 1404 insertions(+), 4191 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/ContextKeys.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/AnalyzeOperationComplexityScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CoerceVariablesScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CompileOperationScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ParseDocumentScope.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/RequestScopeBase.cs delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ValidateDocumentScope.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderBatchSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/ContextKeys.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs create mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/CoerceVariablesScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteIntrospectionNodeScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteNodeFieldNodeScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationNodeScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteRequestScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/NodeScopeBase.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ParseDocumentScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/PlanOperationScope.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/RequestScopeBase.cs delete mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ValidateDocumentScope.cs create mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs create mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap diff --git a/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs b/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs index c17c494a8c3..b00334fdffd 100644 --- a/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs +++ b/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs @@ -9,7 +9,7 @@ internal sealed class AuthorizeRequestMiddleware( { public async ValueTask InvokeAsync(RequestContext context) { - if (!context.TryGetOperationDocument(out var document, out var documentId)) + if (!context.TryGetDocument(out var document, out var documentId)) { throw new InvalidOperationException( "The document or document id is not set."); diff --git a/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs b/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs index 6062965289d..ab086f7bf1b 100644 --- a/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs +++ b/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs @@ -29,7 +29,7 @@ public static bool IsPersistedOperationDocument(this RequestContext context) return context.OperationDocumentInfo.IsPersisted; } - public static bool TryGetOperationDocument( + public static bool TryGetDocument( this RequestContext context, [NotNullWhen(true)] out DocumentNode? document, out OperationDocumentId documentId) diff --git a/src/HotChocolate/Core/src/Execution.Abstractions/Path.cs b/src/HotChocolate/Core/src/Execution.Abstractions/Path.cs index 506e38d3417..e4f1644a208 100644 --- a/src/HotChocolate/Core/src/Execution.Abstractions/Path.cs +++ b/src/HotChocolate/Core/src/Execution.Abstractions/Path.cs @@ -131,7 +131,7 @@ public string Print() { if (this is RootPathSegment) { - return "/"; + return string.Empty; } // On first pass we calculate the total length @@ -147,7 +147,11 @@ public string Print() break; case NamePathSegment name: - totalLength += 1 + name.Name.Length; // '/' + name + totalLength += name.Name.Length; + if (current.Parent is not RootPathSegment) + { + totalLength++; + } break; default: @@ -158,10 +162,13 @@ public string Print() } // On second pass we fill from right to left using string.Create - return string.Create(totalLength, this, static (span, path) => + return string.Create( + totalLength, + this, + static (span, state) => { var pos = span.Length; - var current = path; + var current = state; while (current is not RootPathSegment) { @@ -188,7 +195,10 @@ public string Print() case NamePathSegment name: pos -= name.Name.Length; name.Name.AsSpan().CopyTo(span[pos..]); - span[--pos] = '/'; + if (current.Parent is not RootPathSegment) + { + span[--pos] = '.'; + } break; } diff --git a/src/HotChocolate/Core/src/Types/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Types/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs index 6b7d1a7c81e..b05de0028f0 100644 --- a/src/HotChocolate/Core/src/Types/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Core/src/Types/Execution/Instrumentation/AggregateExecutionDiagnosticEvents.cs @@ -186,30 +186,6 @@ public IDisposable ExecuteOperation(RequestContext context) return new AggregateActivityScope(scopes); } - public IDisposable ExecuteStream(IOperation operation) - { - var scopes = new IDisposable[_listeners.Length]; - - for (var i = 0; i < _listeners.Length; i++) - { - scopes[i] = _listeners[i].ExecuteStream(operation); - } - - return new AggregateActivityScope(scopes); - } - - public IDisposable ExecuteDeferredTask() - { - var scopes = new IDisposable[_listeners.Length]; - - for (var i = 0; i < _listeners.Length; i++) - { - scopes[i] = _listeners[i].ExecuteDeferredTask(); - } - - return new AggregateActivityScope(scopes); - } - public IDisposable ResolveFieldValue(IMiddlewareContext context) { if (_resolverListener.Length == 0) @@ -235,14 +211,6 @@ public void ResolverError(IMiddlewareContext context, IError error) } } - public void ResolverError(RequestContext context, ISelection selection, IError error) - { - for (var i = 0; i < _listeners.Length; i++) - { - _listeners[i].ResolverError(context, selection, error); - } - } - public IDisposable RunTask(IExecutionTask task) { if (_resolverListener.Length == 0) @@ -316,18 +284,6 @@ public void SubscriptionEventError(RequestContext context, ulong subscriptionId, } } - public IDisposable DispatchBatch(RequestContext context) - { - var scopes = new IDisposable[_listeners.Length]; - - for (var i = 0; i < _listeners.Length; i++) - { - scopes[i] = _listeners[i].DispatchBatch(context); - } - - return new AggregateActivityScope(scopes); - } - public void ExecutorCreated(string name, IRequestExecutor executor) { for (var i = 0; i < _listeners.Length; i++) diff --git a/src/HotChocolate/Core/src/Types/Execution/Instrumentation/IExecutionDiagnosticEvents.cs b/src/HotChocolate/Core/src/Types/Execution/Instrumentation/IExecutionDiagnosticEvents.cs index c5082be738b..99d7bcd44c9 100644 --- a/src/HotChocolate/Core/src/Types/Execution/Instrumentation/IExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Core/src/Types/Execution/Instrumentation/IExecutionDiagnosticEvents.cs @@ -79,29 +79,6 @@ public interface IExecutionDiagnosticEvents : ICoreExecutionDiagnosticEvents /// IDisposable CompileOperation(RequestContext context); - /// - /// Called within the execute operation scope when the result is a streamed result. - /// The ExecuteStream scope will run longer than the ExecuteOperation scope. - /// The ExecuteOperation scope completes once the initial operation is executed, - /// while all deferred elements are executed and delivered within the ExecuteStream scope. - /// - /// - /// The compiled operation that is being streamed. - /// - /// - /// A scope that will be disposed when the streaming execution has finished. - /// - IDisposable ExecuteStream(IOperation operation); - - /// - /// Called when starting to execute a deferred part of an operation - /// within the ExecuteStream scope or ExecuteSubscription scope. - /// - /// - /// A scope that will be disposed when the deferred task execution has finished. - /// - IDisposable ExecuteDeferredTask(); - /// /// Called when starting to resolve a field value. /// @@ -131,26 +108,6 @@ public interface IExecutionDiagnosticEvents : ICoreExecutionDiagnosticEvents /// void ResolverError(IMiddlewareContext context, IError error); - /// - /// Called for field errors that occur outside the resolver task execution, - /// typically during result processing or validation. - /// - /// - /// The request context encapsulates all GraphQL-specific information about an - /// individual GraphQL request. - /// - /// - /// The field selection that is affected by the error. - /// - /// - /// The error that occurred during field processing. - /// - /// - /// Some field-level errors are handled after the resolver completes and these - /// are processed in the request scope rather than the resolver scope. - /// - void ResolverError(RequestContext context, ISelection selection, IError error); - /// /// Called when starting to execute an execution engine task. /// @@ -215,19 +172,4 @@ public interface IExecutionDiagnosticEvents : ICoreExecutionDiagnosticEvents /// individual GraphQL request. /// void RetrievedOperationFromCache(RequestContext context); - - /// - /// Called when the execution engine dispatches deferred execution batches. - /// During execution, components like DataLoader defer data resolver execution - /// to be processed in batches. When the execution engine has no immediate work, - /// these batches are dispatched for execution. - /// - /// - /// The request context encapsulates all GraphQL-specific information about an - /// individual GraphQL request. - /// - /// - /// A scope that will be disposed when the batch dispatch has finished. - /// - IDisposable DispatchBatch(RequestContext context); } diff --git a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorBuilderTests.cs b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorBuilderTests.cs index f4ef80d374f..b057bc5eeb4 100644 --- a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorBuilderTests.cs +++ b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorBuilderTests.cs @@ -192,7 +192,7 @@ public void SetPath_Foo_PathIsFooWithCount1() .Build(); // assert - Assert.Equal("/foo", error.Path?.Print()); + Assert.Equal("foo", error.Path?.Print()); } [Fact] @@ -206,7 +206,7 @@ public void SetPathObject_Foo_PathIsFooWithCount1() .Build(); // assert - Assert.Equal("/foo", error.Path?.Print()); + Assert.Equal("foo", error.Path?.Print()); } [Fact] diff --git a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorTests.cs b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorTests.cs index c3492e593dc..545a35c5fe6 100644 --- a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorTests.cs +++ b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/ErrorTests.cs @@ -204,6 +204,6 @@ public void WithPath() error = error.WithPath(Path.FromList(["foo"])); // assert - Assert.Equal("/foo", error.Path!.Print()); + Assert.Equal("foo", error.Path!.Print()); } } diff --git a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/PathTests.cs b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/PathTests.cs index e1edf4dada5..7b8058db7e4 100644 --- a/src/HotChocolate/Core/test/Execution.Abstractions.Tests/PathTests.cs +++ b/src/HotChocolate/Core/test/Execution.Abstractions.Tests/PathTests.cs @@ -28,7 +28,30 @@ public void Path_ToString() var result = path.ToString(); // assert - Assert.Equal("/hero/friends[0]/name", result); + Assert.Equal("hero.friends[0].name", result); + } + + [Fact] + public void Path_Print() + { + // arrange + var path = Path.Root.Append("person").Append(0).Append("address"); + + // act + var result = path.Print(); + + // assert + Assert.Equal("person[0].address", result); + } + + [Fact] + public void Path_Print_Root() + { + // act + var result = Path.Root.Print(); + + // assert + Assert.Equal(string.Empty, result); } [Fact] @@ -172,12 +195,12 @@ public void Complex_Ordering() string[] expected = [ - "/bar", - "/bar[3]", - "/bar[3][2]", - "/bar[3]/foo", - "/foo", - "/foo[0]" + "bar", + "bar[3]", + "bar[3][2]", + "bar[3].foo", + "foo", + "foo[0]" ]; for (var i = 0; i < paths.Length; i++) diff --git a/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs b/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs index ac3c5f85507..716d0aec273 100644 --- a/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs +++ b/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs @@ -22,7 +22,7 @@ internal sealed class CostAnalyzerMiddleware( { public async ValueTask InvokeAsync(RequestContext context) { - if (!context.TryGetOperationDocument(out var document, out var documentId) + if (!context.TryGetDocument(out var document, out var documentId) || documentId.IsEmpty) { context.Result = ResultHelper.StateInvalidForCostAnalysis(); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index fa43e3cb7c0..7444e04ac0c 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -1,9 +1,7 @@ using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Text; using System.Text.Json; using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.ObjectPool; using HotChocolate.AspNetCore.Instrumentation; using HotChocolate.Execution; using HotChocolate.Language; @@ -18,17 +16,10 @@ namespace HotChocolate.Diagnostics; /// Base class for activity enrichers that provides shared enrichment logic /// for HTTP request handling, error handling, and common span enrichment. /// -public abstract class ActivityEnricherBase( - ObjectPool stringBuilderPool, - InstrumentationOptionsBase options) +public abstract class ActivityEnricherBase(InstrumentationOptionsBase options) { private readonly ConditionalWeakTable _queryCache = []; - /// - /// Gets the pool used by this enricher. - /// - protected ObjectPool StringBuilderPool { get; } = stringBuilderPool; - public virtual void EnrichExecuteHttpRequest( HttpContext context, HttpRequestKind kind, @@ -81,7 +72,7 @@ public virtual void EnrichSingleRequest( } if (request.Document is not null - && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) { if (!_queryCache.TryGetValue(request.Document, out var query)) { @@ -135,7 +126,7 @@ public virtual void EnrichBatchRequest( } if (request.Document is not null - && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) { activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryBody(i), request.Document.Print()); } @@ -181,7 +172,7 @@ public virtual void EnrichOperationBatchRequest( } if (request.Document is not null - && (options.RequestDetails & RequestDetails.Query) == RequestDetails.Query) + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) { activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); } @@ -263,164 +254,42 @@ public virtual void EnrichHttpRequestError( HttpContext context, IError error, Activity activity) - => EnrichError(error, activity); + => EnrichError(activity, error); public virtual void EnrichHttpRequestError( HttpContext context, - System.Exception exception, + Exception exception, Activity activity) - { - } + => activity.RecordException(exception); public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) { activity.DisplayName = "Parse HTTP Request"; } - public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) - => EnrichError(error, activity); - public virtual void EnrichFormatHttpResponse(HttpContext context, Activity activity) { activity.DisplayName = "Format HTTP Response"; } - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - System.Exception error) - => EnrichError(ErrorBuilder.FromException(error).Build(), activity); + public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) + => EnrichError(activity, error); public virtual void EnrichRequestError( RequestContext context, Activity activity, - IError error) - => EnrichError(error, activity); - - public virtual void EnrichValidationError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(error, activity); - - public virtual void EnrichAnalyzeOperationComplexity(RequestContext context, Activity activity) + Exception exception) { - activity.DisplayName = "Analyze Operation Complexity"; + activity.RecordException(exception); } - public virtual void EnrichOperationCost( - RequestContext context, - Activity activity, - double fieldCost, - double typeCost) - { - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); - activity.SetTag(GraphQL.Operation.FieldCost, fieldCost); - activity.SetTag(GraphQL.Operation.TypeCost, typeCost); - } - - protected void EnrichExecuteRequestCore( + public virtual void EnrichRequestError( RequestContext context, Activity activity, - string operationDisplayName, - OperationType operationType, - string? operationName) - { - activity.DisplayName = operationDisplayName; - - var documentInfo = context.OperationDocumentInfo; - activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } - - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - - if (options.IncludeDocument && documentInfo.Document is not null) - { - activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); - } - } - - protected void EnrichParseDocumentCore( - Activity activity, - OperationDefinitionNode? operationDefinition, - OperationDocumentInfo documentInfo) - { - activity.DisplayName = "GraphQL Document Parsing"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - - EnrichWithTags(activity, operationDefinition, documentInfo); - } - - protected void EnrichValidateDocumentCore( - Activity activity, - OperationDefinitionNode? operationDefinition, - OperationDocumentInfo documentInfo) - { - activity.DisplayName = "GraphQL Document Validation"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - - EnrichWithTags(activity, operationDefinition, documentInfo); - } - - protected void EnrichCoerceVariablesCore( - Activity activity, - OperationDefinitionNode? operationDefinition, - OperationDocumentInfo documentInfo) - { - activity.DisplayName = "GraphQL Variable Coercion"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - - EnrichWithTags(activity, operationDefinition, documentInfo); - } - - protected static void EnrichWithTags( - Activity activity, - OperationDefinitionNode? operationDefinition, - OperationDocumentInfo documentInfo) - { - if (operationDefinition is not null) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationDefinition.Operation]); - - var operationName = operationDefinition.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - - activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(documentInfo.Hash)); - - if (documentInfo.IsPersisted) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } - } - - protected string GetOperationDisplayName( - OperationType operationType, - string? operationName) - { - var operationTypeName = GraphQL.Operation.TypeValues[operationType]; - if (!string.IsNullOrEmpty(operationName)) - { - return $"{operationTypeName} {operationName}"; - } - - return operationTypeName; - } + IError error) + => EnrichError(activity, error); - protected virtual void EnrichError(IError error, Activity activity) + protected virtual void EnrichError(Activity activity, IError error) { if (error.Exception is { } exception) { @@ -429,14 +298,17 @@ protected virtual void EnrichError(IError error, Activity activity) var tags = new ActivityTagsCollection { - new(SemanticConventions.Exception.Message, error.Message), - new(SemanticConventions.Exception.Type, error.Code ?? "GRAPHQL_ERROR"), - new(GraphQL.Errors.Message, error.Message) + [GraphQL.Error.Message] = error.Message }; if (error.Path is not null) { - tags[GraphQL.Errors.Path] = FormatPath(error.Path); + tags[GraphQL.Error.Path] = error.Path.Print(); + } + + if (!string.IsNullOrEmpty(error.Code)) + { + tags[GraphQL.Error.Code] = error.Code; } if (error.Locations is { Count: > 0 }) @@ -445,80 +317,17 @@ protected virtual void EnrichError(IError error, Activity activity) for (var i = 0; i < error.Locations.Count; i++) { var location = error.Locations[i]; - locations[i] = new Dictionary + locations[i] = new Dictionary { ["line"] = location.Line, ["column"] = location.Column }; } - tags[GraphQL.Errors.Locations] = locations; - } - - activity.AddEvent(new ActivityEvent(SemanticConventions.Exception.EventName, default, tags)); - } - - // TODO: Get rid of this - protected internal static string FormatDocumentHash(OperationDocumentHash hash) - { - if (hash.IsEmpty || string.IsNullOrEmpty(hash.AlgorithmName)) - { - return hash.Value; - } - - var algorithm = hash.AlgorithmName; - - if (algorithm.EndsWith("Hash", System.StringComparison.OrdinalIgnoreCase)) - { - algorithm = algorithm[..^4]; - } - - algorithm = algorithm.ToLowerInvariant(); - - if (algorithm == "sha256") - { - // TODO: wtf - algorithm = "sha25"; - } - - return $"{algorithm}:{hash.Value}"; - } - - protected static string? FormatPath(Path? path) - { - if (path is null || path.IsRoot) - { - return null; - } - - var segments = path.ToList(); - if (segments.Count == 0) - { - return null; - } - - var result = new StringBuilder(); - foreach (var segment in segments) - { - if (segment is string name) - { - if (result.Length > 0) - { - result.Append('.'); - } - - result.Append(name); - continue; - } - - if (segment is int index) - { - result.Append('['); - result.Append(index); - result.Append(']'); - } + tags[GraphQL.Error.Locations] = locations; } - return result.ToString(); + // TODO: Not sure if this is correct according to the spec + activity.AddEvent(new ActivityEvent("exception", default, tags)); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs new file mode 100644 index 00000000000..14ca67ca0ad --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs @@ -0,0 +1,68 @@ +using System.Diagnostics; +using System.Runtime.CompilerServices; +using OpenTelemetry.Trace; +using Status = OpenTelemetry.Trace.Status; + +namespace HotChocolate.Diagnostics; + +internal static class ActivityExtensions +{ + extension(Activity activity) + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void MarkAsSuccess() + { + activity.SetStatus(Status.Ok); + activity.SetStatus(ActivityStatusCode.Ok); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void MarkAsError() + { + activity.SetStatus(Status.Error); + activity.SetStatus(ActivityStatusCode.Error); + } + + public void RecordError(IError error) + { + if (error.Exception is { } exception) + { + activity.RecordException(exception); + } + + var tags = new ActivityTagsCollection + { + [SemanticConventions.GraphQL.Error.Message] = error.Message + }; + + if (error.Path is not null) + { + tags[SemanticConventions.GraphQL.Error.Path] = error.Path.Print(); + } + + if (!string.IsNullOrEmpty(error.Code)) + { + tags[SemanticConventions.GraphQL.Error.Code] = error.Code; + } + + if (error.Locations is { Count: > 0 }) + { + var locations = new object[error.Locations.Count]; + for (var i = 0; i < error.Locations.Count; i++) + { + var location = error.Locations[i]; + locations[i] = new Dictionary + { + ["line"] = location.Line, + ["column"] = location.Column + }; + } + + tags[SemanticConventions.GraphQL.Error.Locations] = locations; + } + + // TODO: Not sure if this is correct according to the spec + activity.AddEvent(new ActivityEvent("exception", default, tags)); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs new file mode 100644 index 00000000000..a9f5032718e --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs @@ -0,0 +1,51 @@ +using HotChocolate.Language; + +namespace HotChocolate.Diagnostics; + +internal static class DocumentNodeExtensions +{ + public static OperationDefinitionNode? GetOperation( + this DocumentNode document, + string? operationName) + { + if (string.IsNullOrEmpty(operationName)) + { + OperationDefinitionNode? operation = null; + var definitions = document.Definitions; + var length = definitions.Count; + + for (var i = 0; i < length; i++) + { + if (definitions[i] is not OperationDefinitionNode op) + { + continue; + } + + if (operation is null) + { + operation = op; + } + else + { + // More than one operation in document. + return null; + } + } + + return operation; + } + else + { + for (var i = 0; i < document.Definitions.Count; i++) + { + if (document.Definitions[i] is OperationDefinitionNode { Name: not null } op + && op.Name!.Value.Equals(operationName, StringComparison.Ordinal)) + { + return op; + } + } + + return null; + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs index 61169f93417..5ae53788ea1 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/RequestDetails.cs @@ -9,7 +9,7 @@ public enum RequestDetails OperationName = 4, Variables = 8, Extensions = 16, - Query = 32, + Document = 32, Default = Id | Hash | OperationName | Extensions, - All = Id | Hash | OperationName | Variables | Extensions | Query + All = Id | Hash | OperationName | Variables | Extensions | Document } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 5984a236e6b..a71d3b966b9 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -5,13 +5,6 @@ namespace HotChocolate.Diagnostics; internal static class SemanticConventions { - public static class Exception - { - public const string EventName = "exception"; - public const string Type = "exception.type"; - public const string Message = "exception.message"; - } - public static class GraphQL { public static class Document @@ -140,12 +133,12 @@ public static class Operation } // Note: This is not part of the OTEL semantic conventions - public static class Errors + public static class Error { - public const string Count = "graphql.errors.count"; public const string Message = "graphql.error.message"; public const string Locations = "graphql.error.locations"; public const string Path = "graphql.error.path"; + public const string Code = "graphql.error.code"; public static class Location { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs new file mode 100644 index 00000000000..96bab84e9ab --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -0,0 +1,67 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class AnalyzeOperationComplexitySpan(Activity activity) : SpanBase(activity) +{ + private bool _costSet; + + public static AnalyzeOperationComplexitySpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Complexity Analyzation"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); + + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new AnalyzeOperationComplexitySpan(activity); + } + + public void SetCost(double fieldCost, double typeCost) + { + Activity.SetTag(GraphQL.Operation.FieldCost, fieldCost); + Activity.SetTag(GraphQL.Operation.TypeCost, typeCost); + + _costSet = true; + } + + protected override void OnComplete() + { + if (_costSet) + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs new file mode 100644 index 00000000000..c7db9607428 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -0,0 +1,63 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ExecuteOperationSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Operation Execution"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + + // TODO: This should get it from the operation + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.Result is null or OperationResult { Errors: [_, ..] }) + { + Activity.MarkAsError(); + } + else + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs new file mode 100644 index 00000000000..835c344619e --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -0,0 +1,69 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using HotChocolate.Language.Utilities; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +// TODO: Needs additional tags probably +internal sealed class ExecuteRequestSpan( + Activity activity, + RequestContext context, + bool shouldDisposeActivity) : IDisposable +{ + private bool _disposed; + + public Activity Activity { get; } = activity; + + public static ExecuteRequestSpan? Start( + ActivitySource source, + RequestContext context, + InstrumentationOptionsBase options) + { + var activity = source.StartActivity("GraphQL Operation", ActivityKind.Server); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + + var documentInfo = context.OperationDocumentInfo; + + if (options.IncludeDocument && documentInfo.Document is not null) + { + activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); + } + + return new ExecuteRequestSpan(activity, context, true); + } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + + OnComplete(); + + if (shouldDisposeActivity) + { + Activity.Dispose(); + } + } + } + + private void OnComplete() + { + if (context.Result is null or OperationResult { Errors: [_, ..] }) + { + Activity.MarkAsError(); + } + else + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs new file mode 100644 index 00000000000..a1bec79ef1f --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -0,0 +1,57 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ParsingSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Document Parsing"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.TryGetDocument(out var document, out _)) + { + if (document.GetOperation(context.Request.OperationName) is { } operation) + { + Activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs new file mode 100644 index 00000000000..d6f891dcfa4 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs @@ -0,0 +1,24 @@ +using System.Diagnostics; + +namespace HotChocolate.Diagnostics; + +internal abstract class SpanBase(Activity activity) : IDisposable +{ + private bool _disposed; + + public Activity Activity { get; } = activity; + + protected virtual void OnComplete() { } + + public void Dispose() + { + if (!_disposed) + { + _disposed = true; + + OnComplete(); + + Activity.Dispose(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs new file mode 100644 index 00000000000..0d279483515 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -0,0 +1,58 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ValidationSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity( "GraphQL Document Validation"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); + + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.IsOperationDocumentValid()) + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs new file mode 100644 index 00000000000..62ba0039020 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -0,0 +1,59 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class VariableCoercionSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Variable Coercion"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); + + // TODO: This should get it from the operation + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.VariableValues.Length > 0) + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 303c060b85f..9126c518808 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -1,11 +1,3 @@ -using System.Diagnostics; -using System.Text; -using Microsoft.Extensions.ObjectPool; -using GreenDonut; -using HotChocolate.Execution; -using HotChocolate.Resolvers; -using static HotChocolate.Diagnostics.SemanticConventions; - namespace HotChocolate.Diagnostics; /// @@ -13,124 +5,6 @@ namespace HotChocolate.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class ActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) : ActivityEnricherBase(stringBuilderPool, options) +public class ActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase(options) { - public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - if (context.TryGetOperation(out var operation)) - { - var operationDisplayName = GetOperationDisplayName(operation.Kind, operation.Name); - - EnrichExecuteRequestCore( - context, - activity, - operationDisplayName, - operation.Kind, - operation.Name); - } - } - - public virtual void EnrichParseDocument(RequestContext context, Activity activity) - { - context.TryGetOperation(out var operation); - // TODO: We won't ever have this here... - var operationDefinition = operation?.Definition; - - EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichValidateDocument(RequestContext context, Activity activity) - { - context.TryGetOperation(out var operation); - // TODO: We won't ever have this here... - var operationDefinition = operation?.Definition; - - EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) - { - context.TryGetOperation(out var operation); - // TODO: We won't ever have this here... - var operationDefinition = operation?.Definition; - - EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichCompileOperation(RequestContext context, Activity activity) - { - context.TryGetOperation(out var operation); - // TODO: We won't ever have this here... - var operationDefinition = operation?.Definition; - - activity.DisplayName = "GraphQL Operation Planning"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - - EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) - { - if (context.TryGetOperation(out var operation)) - { - activity.DisplayName = "GraphQL Operation Execution"; - - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - - EnrichWithTags(activity, operation.Definition, context.OperationDocumentInfo); - } - } - - public virtual void EnrichResolveFieldValue(IMiddlewareContext context, Activity activity) - { - var selection = context.Selection; - var coordinate = selection.Field.Coordinate; - var path = FormatPath(context.Path); - - activity.DisplayName = coordinate.ToString(); - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Resolve); - activity.SetTag(GraphQL.Selection.Name, selection.ResponseName); - activity.SetTag(GraphQL.Selection.Path, path); - activity.SetTag(GraphQL.Selection.Field.Name, coordinate.MemberName); - activity.SetTag(GraphQL.Selection.Field.Coordinate, activity.DisplayName); - activity.SetTag(GraphQL.Selection.Field.ParentType, coordinate.Name); - } - - public virtual void EnrichResolverError( - RequestContext context, - IError error, - Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichResolverError( - IMiddlewareContext middlewareContext, - IError error, - Activity activity) - => EnrichError(error, activity); - - public virtual void EnrichDataLoaderBatch( - IDataLoader dataLoader, - IReadOnlyList keys, - Activity activity) - where TKey : notnull - { - activity.DisplayName = $"Execute {dataLoader.GetType().Name} Batch"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderBatch); - activity.SetTag(GraphQL.DataLoader.Batch.Size, keys.Count); - - if (options.IncludeDataLoaderKeys) - { - var temp = keys.Select(t => t.ToString()).ToArray(); - activity.SetTag(GraphQL.DataLoader.Batch.Keys, temp); - } - } - - public virtual void EnrichDataLoaderBatchDispatchCoordinator(Activity activity) - { - activity.DisplayName = "Coordinate DataLoader Batches"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); - } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ContextKeys.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ContextKeys.cs deleted file mode 100644 index d2771522e7a..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ContextKeys.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace HotChocolate.Diagnostics; - -internal static class ContextKeys -{ - public const string HttpRequestActivity = "HotChocolate.Diagnostics.HttpRequest"; - public const string ParseHttpRequestActivity = "HotChocolate.Diagnostics.ParseHttpRequest"; - public const string FormatHttpResponseActivity = "HotChocolate.Diagnostics.FormatHttpResponse"; - public const string WebSocketSessionActivity = "HotChocolate.Diagnostics.WebSocketSession"; - public const string RequestActivity = "HotChocolate.Diagnostics.Request"; - public const string ValidateActivity = "HotChocolate.Diagnostics.Validate"; - public const string ComplexityActivity = "HotChocolate.Diagnostics.AnalyzeOperationComplexity"; - public const string ResolverActivity = "HotChocolate.Diagnostics.Resolver"; -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index 517c8ff6071..03c0506367b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using GreenDonut; -using HotChocolate.Diagnostics.Scopes; using static HotChocolate.Diagnostics.HotChocolateActivitySource; namespace HotChocolate.Diagnostics.Listeners; @@ -19,29 +18,30 @@ public override IDisposable ExecuteBatch( return EmptyScope; } - var activity = Source.StartActivity(); + var span = DataLoaderBatchSpan.Start(Source, dataLoader, keys); - if (activity is null) + if (span is null) { return EmptyScope; } - return new DataLoaderBatchScope(enricher, dataLoader, keys, activity); + if (options.IncludeDataLoaderKeys) + { + var temp = keys.Select(t => t.ToString()).ToArray(); + span.Activity.SetTag(SemanticConventions.GraphQL.DataLoader.Batch.Keys, temp); + } + + return span; } public override IDisposable RunBatchDispatchCoordinator() { - var activity = Source.StartActivity("BatchCoordinator"); - - if (activity is null) - { - return EmptyScope; - } + var span = DataLoaderDispatchSpan.Start(Source); - return new DataLoaderBatchDispatchCoordinatorScope(enricher, activity); + return span ?? EmptyScope; } - public override void BatchDispatchError(System.Exception error) + public override void BatchDispatchError(Exception error) { #if NET9_0_OR_GREATER Activity.Current?.AddException(error); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index a706cc24a13..98c186b5a5e 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -1,46 +1,32 @@ using System.Diagnostics; -using HotChocolate.Diagnostics.Scopes; using HotChocolate.Execution; using HotChocolate.Execution.Instrumentation; using HotChocolate.Resolvers; using Microsoft.AspNetCore.Http; using OpenTelemetry.Trace; -using static HotChocolate.Diagnostics.ContextKeys; using static HotChocolate.Diagnostics.HotChocolateActivitySource; namespace HotChocolate.Diagnostics.Listeners; -internal sealed class ActivityExecutionDiagnosticListener : ExecutionDiagnosticEventListener +internal sealed class ActivityExecutionDiagnosticListener( + ActivityEnricher enricher, + InstrumentationOptions options) : ExecutionDiagnosticEventListener { - private readonly InstrumentationOptions _options; - private readonly ActivityEnricher _enricher; - - public ActivityExecutionDiagnosticListener( - ActivityEnricher enricher, - InstrumentationOptions options) - { - ArgumentNullException.ThrowIfNull(enricher); - ArgumentNullException.ThrowIfNull(options); - - _enricher = enricher; - _options = options; - } - public override bool EnableResolveFieldValue => true; public override IDisposable ExecuteRequest(RequestContext context) { - Activity? activity = null; + Activity? httpContextActivity = null; - if (_options.SkipExecuteRequest) + if (options.SkipExecuteRequest) { - if (!_options.SkipExecuteHttpRequest - && context.ContextData.TryGetValue(nameof(HttpContext), out var value) - && value is HttpContext httpContext - && httpContext.Items.TryGetValue(HttpRequestActivity, out value) - && value is not null) + if (!options.SkipExecuteHttpRequest + && context.Features.TryGet(out var httpContext) + // TODO: Fix this + && httpContext.Items.TryGetValue("TODO context key", out var untypedActivity) + && untypedActivity is Activity activity) { - activity = (Activity)value; + httpContextActivity = activity; } else { @@ -48,253 +34,183 @@ public override IDisposable ExecuteRequest(RequestContext context) } } - activity ??= Source.StartActivity(); + var span = httpContextActivity is not null + ? new ExecuteRequestSpan(httpContextActivity, context, false) + : ExecuteRequestSpan.Start(Source, context, options); - if (activity is null) + if (span is null) { return EmptyScope; } - context.ContextData[RequestActivity] = activity; + context.Features.Set(span); - return new ExecuteRequestScope(_enricher, context, activity); + return span; } - public override void RetrievedDocumentFromCache(RequestContext context) + public override void RequestError(RequestContext context, Exception error) { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) + if (context.Features.TryGet(out var span)) { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(RetrievedDocumentFromCache))); - } - } + var activity = span.Activity; - public override void RetrievedDocumentFromStorage(RequestContext context) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(RetrievedDocumentFromStorage))); + activity.RecordException(error); + activity.MarkAsError(); } } - public override void AddedDocumentToCache(RequestContext context) + public override void RequestError(RequestContext context, IError error) { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) + if (context.Features.TryGet(out var span)) { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(AddedDocumentToCache))); - } - } + var activity = span.Activity; - public override void AddedOperationToCache(RequestContext context) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(AddedOperationToCache))); + activity.RecordError(error); + activity.MarkAsError(); } } public override IDisposable ParseDocument(RequestContext context) { - if (_options.SkipParseDocument) + if (options.SkipParseDocument) { return EmptyScope; } - var activity = Source.StartActivity(); + var span = ParsingSpan.Start(Source, context); - if (activity is null) - { - return EmptyScope; - } - - context.ContextData[RequestActivity] = activity; - - return new ParseDocumentScope(_enricher, context, activity); + return span ?? EmptyScope; } - public override void RequestError(RequestContext context, Exception error) - { - if (context.ContextData.TryGetValue(RequestActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - _enricher.EnrichRequestError(context, activity, error); - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } - } + // TODO: A dedicated event for parsing errors would be nice - public override void RequestError(RequestContext context, IError error) + public override IDisposable ValidateDocument(RequestContext context) { - if (context.ContextData.TryGetValue(RequestActivity, out var value)) + if (options.SkipValidateDocument) { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - _enricher.EnrichRequestError(context, activity, error); - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); + return EmptyScope; } - } - - public override void ValidationErrors(RequestContext context, IReadOnlyList errors) - { - if (context.ContextData.TryGetValue(ValidateActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - - foreach (var error in errors) - { - _enricher.EnrichValidationError(context, activity, error); - } - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } - } + var span = ValidationSpan.Start(Source, context); - public override void ResolverError(IMiddlewareContext context, IError error) - { - if (context.LocalContextData.TryGetValue(ResolverActivity, out var localValue) - && localValue is Activity activity) + if (span is null) { - _enricher.EnrichResolverError(context, error, activity); - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); + return EmptyScope; } - } - public override void ResolverError(RequestContext context, ISelection selection, IError error) - { - if (context.ContextData.TryGetValue(RequestActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; + context.Features.Set(span); - _enricher.EnrichResolverError(context, error, activity); - - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } + return span; } - public override IDisposable ValidateDocument(RequestContext context) + public override void ValidationErrors(RequestContext context, IReadOnlyList errors) { - if (_options.SkipValidateDocument) + if (!context.Features.TryGet(out var span)) { - return EmptyScope; + return; } - var activity = Source.StartActivity(); + var activity = span.Activity; - if (activity is null) + foreach (var error in errors) { - return EmptyScope; + activity.RecordError(error); } - context.ContextData[ValidateActivity] = activity; - - return new ValidateDocumentScope(_enricher, context, activity); + activity.MarkAsError(); } public override IDisposable AnalyzeOperationCost(RequestContext context) { - if (_options.SkipAnalyzeComplexity) + if (options.SkipAnalyzeComplexity) { return EmptyScope; } - var activity = Source.StartActivity(); + var span = AnalyzeOperationComplexitySpan.Start(Source, context); - if (activity is null) + if (span is null) { return EmptyScope; } - context.ContextData[ComplexityActivity] = activity; + context.Features.Set(span); - return new AnalyzeOperationComplexityScope(_enricher, context, activity); + return span; } public override void OperationCost(RequestContext context, double fieldCost, double typeCost) { - if (context.ContextData.TryGetValue(ComplexityActivity, out var value)) + if (!context.Features.TryGet(out var span)) { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - _enricher.EnrichOperationCost(context, activity, fieldCost, typeCost); + return; } + + span.SetCost(fieldCost, typeCost); } - public override IDisposable CoerceVariables(RequestContext context) + public override IDisposable CompileOperation(RequestContext context) { - if (_options.SkipCoerceVariables) + if (options.SkipCompileOperation) { return EmptyScope; } - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } + var span = CompileOperationSpan.Start(Source, context); - return new CoerceVariablesScope(_enricher, context, activity); + return span ?? EmptyScope; } - public override IDisposable CompileOperation(RequestContext context) + public override IDisposable CoerceVariables(RequestContext context) { - if (_options.SkipCompileOperation) + if (options.SkipCoerceVariables) { return EmptyScope; } - var activity = Source.StartActivity(); + var span = VariableCoercionSpan.Start(Source, context); - if (activity is null) + return span ?? EmptyScope; + } + + public override IDisposable ExecuteOperation(RequestContext context) + { + if (options.SkipExecuteOperation) { return EmptyScope; } - return new CompileOperationScope(_enricher, context, activity); + var span = ExecuteOperationSpan.Start(Source, context); + + return span ?? EmptyScope; } - public override IDisposable ExecuteOperation(RequestContext context) + public override IDisposable ResolveFieldValue(IMiddlewareContext context) { - if (_options.SkipExecuteOperation) + if (options.SkipResolveFieldValue) { return EmptyScope; } - var activity = Source.StartActivity(); + var span = ResolveFieldSpan.Start(Source, context); - if (activity is null) + if (span is null) { return EmptyScope; } - return new ExecuteOperationScope(_enricher, context, activity); + context.Features.Set(span); + + return span; } - public override IDisposable ExecuteStream(IOperation operation) + public override void ResolverError(IMiddlewareContext context, IError error) { - var activity = Source.StartActivity(); - - if (activity is null) + if (context.Features.TryGet(out var span)) { - return EmptyScope; + span.Activity.RecordError(error); + span.Activity.MarkAsError(); } - - return activity; } public override IDisposable OnSubscriptionEvent(RequestContext context, ulong subscriptionId) @@ -309,26 +225,35 @@ public override IDisposable OnSubscriptionEvent(RequestContext context, ulong su return activity; } - public override IDisposable ResolveFieldValue(IMiddlewareContext context) + public override void RetrievedDocumentFromCache(RequestContext context) { - if (_options.SkipResolveFieldValue) + if (context.Features.TryGet(out var span)) { - return EmptyScope; + span.Activity.AddEvent(new(nameof(RetrievedDocumentFromCache))); } + } - var activity = Source.StartActivity(); - - if (activity is null) + public override void RetrievedDocumentFromStorage(RequestContext context) + { + if (context.Features.TryGet(out var span)) { - return EmptyScope; + span.Activity.AddEvent(new(nameof(RetrievedDocumentFromStorage))); } + } - _enricher.EnrichResolveFieldValue(context, activity); - activity.SetStatus(Status.Ok); - activity.SetStatus(ActivityStatusCode.Ok); - - context.SetLocalState(ResolverActivity, activity); + public override void AddedDocumentToCache(RequestContext context) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(AddedDocumentToCache))); + } + } - return activity; + public override void AddedOperationToCache(RequestContext context) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(AddedOperationToCache))); + } } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/AnalyzeOperationComplexityScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/AnalyzeOperationComplexityScope.cs deleted file mode 100644 index f4845164f4b..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/AnalyzeOperationComplexityScope.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class AnalyzeOperationComplexityScope : RequestScopeBase -{ - public AnalyzeOperationComplexityScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichAnalyzeOperationComplexity(Context, Activity); -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CoerceVariablesScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CoerceVariablesScope.cs deleted file mode 100644 index 258f8d78059..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CoerceVariablesScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class CoerceVariablesScope : RequestScopeBase -{ - public CoerceVariablesScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichCoerceVariables(Context, Activity); - - protected override void SetStatus() - { - if (Context.VariableValues.Length > 0) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CompileOperationScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CompileOperationScope.cs deleted file mode 100644 index ed07a17dea6..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/CompileOperationScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class CompileOperationScope : RequestScopeBase -{ - public CompileOperationScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichCompileOperation(Context, Activity); - - protected override void SetStatus() - { - if (Context.TryGetOperation(out _)) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs deleted file mode 100644 index e9b5dff66b7..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchDispatchCoordinatorScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class DataLoaderBatchDispatchCoordinatorScope : IDisposable -{ - private readonly ActivityEnricher _enricher; - private readonly Activity _activity; - private bool _disposed; - - public DataLoaderBatchDispatchCoordinatorScope( - ActivityEnricher enricher, - Activity activity) - { - _enricher = enricher; - _activity = activity; - } - - public void Dispose() - { - if (!_disposed) - { - _enricher.EnrichDataLoaderBatchDispatchCoordinator(_activity); - _activity.Dispose(); - _disposed = true; - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchScope.cs deleted file mode 100644 index 245b0481fac..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/DataLoaderBatchScope.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Diagnostics; -using GreenDonut; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class DataLoaderBatchScope : IDisposable where TKey : notnull -{ - private readonly ActivityEnricher _enricher; - private readonly IDataLoader _dataLoader; - private readonly IReadOnlyList _keys; - private readonly Activity _activity; - private bool _disposed; - - public DataLoaderBatchScope( - ActivityEnricher enricher, - IDataLoader dataLoader, - IReadOnlyList keys, - Activity activity) - { - _enricher = enricher; - _dataLoader = dataLoader; - _keys = keys; - _activity = activity; - } - - public void Dispose() - { - if (!_disposed) - { - _enricher.EnrichDataLoaderBatch(_dataLoader, _keys, _activity); - _activity.Dispose(); - _disposed = true; - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs deleted file mode 100644 index 2c7915ad6d0..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteOperationScope.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class ExecuteOperationScope : RequestScopeBase -{ - public ExecuteOperationScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichExecuteOperation(Context, Activity); - - protected override void SetStatus() - { - if (Context.Result is null or OperationResult { Errors: [_, ..] }) - { - Activity.SetStatus(Status.Error); - Activity.SetStatus(ActivityStatusCode.Error); - } - else - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs deleted file mode 100644 index 32c4affad3f..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ExecuteRequestScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class ExecuteRequestScope : RequestScopeBase -{ - public ExecuteRequestScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichExecuteRequest(Context, Activity); - - protected override void SetStatus() - { - if (Context.Result is null or OperationResult { Errors: [_, ..] }) - { - Activity.SetStatus(Status.Error); - Activity.SetStatus(ActivityStatusCode.Error); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ParseDocumentScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ParseDocumentScope.cs deleted file mode 100644 index 3a3d26c166a..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ParseDocumentScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class ParseDocumentScope : RequestScopeBase -{ - public ParseDocumentScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichParseDocument(Context, Activity); - - protected override void SetStatus() - { - if (Context.TryGetOperationDocument(out _, out _)) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/RequestScopeBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/RequestScopeBase.cs deleted file mode 100644 index 00e263db91a..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/RequestScopeBase.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; - -namespace HotChocolate.Diagnostics.Scopes; - -internal class RequestScopeBase : IDisposable -{ - private bool _disposed; - - protected RequestScopeBase( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - { - Enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - Context = context ?? throw new ArgumentNullException(nameof(context)); - Activity = activity ?? throw new ArgumentNullException(nameof(activity)); - } - - protected ActivityEnricher Enricher { get; } - - protected RequestContext Context { get; } - - protected Activity Activity { get; } - - protected virtual void EnrichActivity() { } - - protected virtual void SetStatus() { } - - public void Dispose() - { - if (!_disposed) - { - EnrichActivity(); - SetStatus(); - Activity.Dispose(); - _disposed = true; - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ValidateDocumentScope.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ValidateDocumentScope.cs deleted file mode 100644 index 291126ba469..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Scopes/ValidateDocumentScope.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Diagnostics.Scopes; - -internal sealed class ValidateDocumentScope : RequestScopeBase -{ - public ValidateDocumentScope( - ActivityEnricher enricher, - RequestContext context, - Activity activity) - : base(enricher, context, activity) - { - } - - protected override void EnrichActivity() - => Enricher.EnrichValidateDocument(Context, Activity); - - protected override void SetStatus() - { - if (Context.IsOperationDocumentValid()) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs new file mode 100644 index 00000000000..64dd6d36703 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs @@ -0,0 +1,57 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class CompileOperationSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Operation Planning"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); + + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.TryGetOperation(out _)) + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderBatchSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderBatchSpan.cs new file mode 100644 index 00000000000..c8c85bbe880 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderBatchSpan.cs @@ -0,0 +1,30 @@ +using System.Diagnostics; +using GreenDonut; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class DataLoaderBatchSpan(Activity activity) : SpanBase(activity) +{ + public static DataLoaderBatchSpan? Start( + ActivitySource source, + IDataLoader dataLoader, + IReadOnlyList keys) + { + var dataLoaderName = dataLoader.GetType().Name; + + var activity = source.StartActivity($"GraphQL DataLoader Batch {dataLoaderName}"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderBatch); + + activity.SetTag(GraphQL.DataLoader.Name, dataLoaderName); + activity.SetTag(GraphQL.DataLoader.Batch.Size, keys.Count); + + return new DataLoaderBatchSpan(activity); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs new file mode 100644 index 00000000000..060f0c8d726 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs @@ -0,0 +1,23 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class DataLoaderDispatchSpan(Activity activity) : SpanBase(activity) +{ + public static DataLoaderDispatchSpan? Start(ActivitySource source) + { + var activity = source.StartActivity("GraphQL DataLoader Dispatch"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); + + return new DataLoaderDispatchSpan(activity); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs new file mode 100644 index 00000000000..83ea7913bfb --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs @@ -0,0 +1,41 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using HotChocolate.Resolvers; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ResolveFieldSpan(Activity activity) : SpanBase(activity) +{ + public static ResolveFieldSpan? Start(ActivitySource source, IMiddlewareContext context) + { + var selection = context.Selection; + var coordinate = selection.Field.Coordinate; + + var activity = source.StartActivity(coordinate.ToString()); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Resolve); + + activity.SetTag(GraphQL.Selection.Name, selection.ResponseName); + activity.SetTag(GraphQL.Selection.Path, context.Path.Print()); + activity.SetTag(GraphQL.Selection.Field.Name, coordinate.MemberName); + activity.SetTag(GraphQL.Selection.Field.Coordinate, activity.DisplayName); + activity.SetTag(GraphQL.Selection.Field.ParentType, coordinate.Name); + + // TODO: Re-add this + // context.SetLocalState(ResolverActivity, activity); + + return new ResolveFieldSpan(activity); + } + + protected override void OnComplete() + { + Activity.MarkAsSuccess(); + } +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index 3497f2627f2..2e8e3c8fdf0 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -110,74 +110,6 @@ public async Task Validation_error_when_rename_root_is_activated() } } - [Fact] - public async Task Create_operation_display_name_with_1_field() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ a: sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_operation_display_name_with_1_field_and_op() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("query GetA { a: sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_operation_display_name_with_3_field() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ a: sayHello b: sayHello c: sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_operation_display_name_with_4_field() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ a: sayHello b: sayHello c: sayHello d: sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Track_events_of_a_simple_query_detailed() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap index d363ced0b63..417bc6c07ca 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "BatchCoordinator", - "DisplayName": "Coordinate DataLoader Batches", + "DisplayName": "GraphQL DataLoader Dispatch", "Status": "Unset", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap index 4eceff380ce..aac7842e7f6 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "BatchCoordinator", - "DisplayName": "Coordinate DataLoader Batches", + "DisplayName": "GraphQL DataLoader Dispatch", "Status": "Unset", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 28b9c24684c..1f433ab3552 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -2,21 +2,13 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.body", "Value": "query SayHelloOperation {\n sayHello\n}" @@ -33,14 +25,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -61,14 +45,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index b24c0d59599..b13a9ba2a99 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -2,21 +2,13 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.body", "Value": "query SayHelloOperation {\n causeFatalError\n}" @@ -37,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -65,14 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -178,14 +154,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "fail" - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "fail" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index 1d979da5209..b62d7b855e7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -29,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -61,14 +53,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -78,14 +62,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `causeFatalError` does not exist on the type `Deeper`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `causeFatalError` does not exist on the type `Deeper`." diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap deleted file mode 100644 index 82a9c3394bd..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field.snap +++ /dev/null @@ -1,156 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "a" - }, - { - "Key": "graphql.selection.path", - "Value": "a" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap deleted file mode 100644 index f0bbdea328b..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_1_field_and_op.snap +++ /dev/null @@ -1,176 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query GetA", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "a" - }, - { - "Key": "graphql.selection.path", - "Value": "a" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap deleted file mode 100644 index 2a381aad5ed..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_3_field.snap +++ /dev/null @@ -1,228 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "a" - }, - { - "Key": "graphql.selection.path", - "Value": "a" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "b" - }, - { - "Key": "graphql.selection.path", - "Value": "b" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "c" - }, - { - "Key": "graphql.selection.path", - "Value": "c" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap deleted file mode 100644 index 171e08b9459..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_operation_display_name_with_4_field.snap +++ /dev/null @@ -1,264 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "a" - }, - { - "Key": "graphql.selection.path", - "Value": "a" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "b" - }, - { - "Key": "graphql.selection.path", - "Value": "b" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "c" - }, - { - "Key": "graphql.selection.path", - "Value": "c" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "d" - }, - { - "Key": "graphql.selection.path", - "Value": "d" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index bc26dff07ae..e84b80f0967 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" } ], "event": [], @@ -29,14 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -57,14 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index 46a89617361..bf77ede87d1 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -29,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -61,14 +53,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -78,14 +62,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `sayHello_` does not exist on the type `SimpleQuery`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `sayHello_` does not exist on the type `SimpleQuery`." diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 083c7614560..6cea4c9d956 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index 805d6d34b73..df78879f806 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [], @@ -25,10 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -49,10 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 32f2d534925..ffd191fca0b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 24c02e2b527..baf4330a517 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index 1f3085c7a99..671c8838b14 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Ok", "tags": [ { @@ -16,10 +16,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -54,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 32587281361..99dc4cafd2e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index a5688f9f204..9da449e2fd2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -34,16 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -66,10 +62,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -83,14 +75,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index ec6bd3d635f..3922695aff4 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 2aa08d54ff0..4897ecb4922 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:668e9631148921208d08dbb69513fa8e" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index 5c75565887d..2a9fd28a838 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -27,17 +27,13 @@ "Name": "exception", "Tags": [ { - "Key": "exception.message", + "Key": "graphql.error.message", "Value": "Found a NameStart character `n` (110) following a number, which is disallowed." }, { - "Key": "exception.type", + "Key": "graphql.error.code", "Value": "HC0011" }, - { - "Key": "graphql.error.message", - "Value": "Found a NameStart character `n` (110) following a number, which is disallowed." - }, { "Key": "graphql.error.locations", "Value": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 32587281361..99dc4cafd2e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -79,14 +71,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 574b90aa608..108db891d7b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -34,16 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -66,10 +62,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -83,14 +75,9 @@ }, { "OperationName": "AnalyzeOperationCost", - "DisplayName": "Analyze Operation Complexity", + "DisplayName": "GraphQL Complexity Analyzation", "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], + "tags": [], "event": [] }, { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index 8bd46ce8dbe..5b2e774ad0d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -27,17 +27,13 @@ "Name": "exception", "Tags": [ { - "Key": "exception.message", + "Key": "graphql.error.message", "Value": "Expected a `Name`-token, but found a `Integer`-token." }, { - "Key": "exception.type", + "Key": "graphql.error.code", "Value": "HC0011" }, - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, { "Key": "graphql.error.locations", "Value": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 11c6ee7be6c..0f04b5ae931 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -70,14 +66,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `abc` does not exist on the type `Query`." diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/ContextKeys.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/ContextKeys.cs deleted file mode 100644 index f35bd4946f0..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/ContextKeys.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace HotChocolate.Fusion.Diagnostics; - -internal static class ContextKeys -{ - public const string HttpRequestActivity = "HotChocolate.Fusion.Diagnostics.HttpRequest"; - public const string ParseHttpRequestActivity = "HotChocolate.Fusion.Diagnostics.ParseHttpRequest"; - public const string FormatHttpResponseActivity = "HotChocolate.Fusion.Diagnostics.FormatHttpResponse"; - public const string RequestActivity = "HotChocolate.Fusion.Diagnostics.Request"; - public const string ValidateActivity = "HotChocolate.Fusion.Diagnostics.Validate"; -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs index 8a4e4930419..b6825ab8cdf 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs @@ -35,7 +35,7 @@ public static IFusionGatewayBuilder AddInstrumentation( builder.AddApplicationService(); builder.AddDiagnosticEventListener( - sp => new ActivityFusionExecutionDiagnosticEventListener( + sp => new FusionActivityExecutionDiagnosticEventListener( sp.GetService() ?? sp.GetRequiredService(), sp.GetRequiredService())); diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index e3adda4d11d..fd73ca8ec5d 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -1,14 +1,4 @@ -using System.Collections.Frozen; -using System.Diagnostics; -using System.Globalization; -using System.Text; -using Microsoft.Extensions.ObjectPool; using HotChocolate.Diagnostics; -using HotChocolate.Execution; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; -using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Fusion.Diagnostics; @@ -17,172 +7,6 @@ namespace HotChocolate.Fusion.Diagnostics; /// You can inherit from this class and override the enricher methods to provide more or /// less information. /// -public class FusionActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) : ActivityEnricherBase(stringBuilderPool, options) +public class FusionActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase(options) { - private static FrozenDictionary KindValues { get; } = - new Dictionary - { - [ExecutionNodeType.Operation] = GraphQL.Operation.Step.KindValues.Operation, - [ExecutionNodeType.OperationBatch] = GraphQL.Operation.Step.KindValues.OperationBatch, - [ExecutionNodeType.Introspection] = GraphQL.Operation.Step.KindValues.Introspection, - [ExecutionNodeType.Node] = GraphQL.Operation.Step.KindValues.Node - }.ToFrozenDictionary(); - - public virtual void EnrichExecuteRequest(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - if (context.GetOperationPlan() is { } plan) - { - var operationType = plan.Operation.Definition.Operation; - var operationName = plan.OperationName; - var operationDisplayName = GetOperationDisplayName(operationType, operationName); - - EnrichExecuteRequestCore( - context, - activity, - operationDisplayName, - operationType, - operationName); - } - } - - public virtual void EnrichParseDocument(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - var plan = context.GetOperationPlan(); - var operationDefinition = plan?.Operation.Definition; - - EnrichParseDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichValidateDocument(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - var plan = context.GetOperationPlan(); - var operationDefinition = plan?.Operation.Definition; - - EnrichValidateDocumentCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichCoerceVariables(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - var plan = context.GetOperationPlan(); - var operationDefinition = plan?.Operation.Definition; - - EnrichCoerceVariablesCore(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichPlanOperationScope(RequestContext context, Activity activity) - { - // TODO: We won't ever have this here... - var plan = context.GetOperationPlan(); - var operationDefinition = plan?.Operation.Definition; - - activity.DisplayName = "GraphQL Operation Planning"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - - EnrichWithTags(activity, operationDefinition, context.OperationDocumentInfo); - } - - public virtual void EnrichExecuteOperation(RequestContext context, Activity activity) - { - if (context.GetOperationPlan() is { } plan) - { - activity.DisplayName = "GraphQL Operation Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - - EnrichWithTags(activity, plan.Operation.Definition, context.OperationDocumentInfo); - } - } - - public virtual void EnrichExecuteOperationNode( - OperationPlanContext context, - OperationExecutionNode node, - string schemaName, - Activity activity) - => EnrichOperationWithTags( - activity, - context.OperationPlan, - node, - node.Operation, - context.RequestContext.OperationDocumentInfo, - schemaName); - - public virtual void EnrichExecuteOperationBatchNode( - OperationPlanContext context, - OperationBatchExecutionNode node, - string schemaName, - Activity activity) - => EnrichOperationWithTags( - activity, - context.OperationPlan, - node, - node.Operation, - context.RequestContext.OperationDocumentInfo, - schemaName); - - public virtual void EnrichExecuteNodeFieldNode( - OperationPlanContext context, - NodeFieldExecutionNode node, - Activity activity) - => EnrichNodeWithTags(activity, node, context.OperationPlan); - - public virtual void EnrichExecuteIntrospectionNode( - OperationPlanContext context, - IntrospectionExecutionNode node, - Activity activity) - => EnrichNodeWithTags(activity, node, context.OperationPlan); - - public virtual void EnrichExecutionNodeError( - OperationPlanContext context, - ExecutionNode node, - System.Exception error, - Activity activity) - => activity.RecordException(error); - - public virtual void EnrichSourceSchemaError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - System.Exception error, - Activity activity) - => activity.RecordException(error); - - private static void EnrichOperationWithTags( - Activity activity, - OperationPlan plan, - ExecutionNode node, - OperationSourceText operation, - OperationDocumentInfo operationDocumentInfo, - string schemaName) - { - EnrichNodeWithTags(activity, node, plan); - - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[plan.Operation.Definition.Operation]); - - if (!string.IsNullOrEmpty(plan.OperationName)) - { - activity.SetTag(GraphQL.Operation.Name, plan.OperationName); - } - - activity.SetTag(GraphQL.Document.Hash, FormatDocumentHash(operationDocumentInfo.Hash)); - - activity.SetTag(GraphQL.Source.Name, schemaName); - activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); - activity.SetTag(GraphQL.Source.Operation.Kind, GraphQL.Operation.TypeValues[operation.Type]); - activity.SetTag(GraphQL.Source.Operation.Hash, operation.Hash); - } - - private static void EnrichNodeWithTags(Activity activity, ExecutionNode node, OperationPlan plan) - { - activity.DisplayName = "GraphQL Step Execution"; - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); - - activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); - activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); - activity.SetTag(GraphQL.Operation.Step.Plan.Id, plan.Id); - } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolateFusionActivitySource.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolateFusionActivitySource.cs index dda5993f72b..dd6db410510 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolateFusionActivitySource.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/HotChocolateFusionActivitySource.cs @@ -8,8 +8,8 @@ internal static class HotChocolateFusionActivitySource public static ActivitySource Source { get; } = new(GetName(), GetVersion()); public static string GetName() - => typeof(ActivityFusionExecutionDiagnosticEventListener).Assembly.GetName().Name!; + => typeof(FusionActivityExecutionDiagnosticEventListener).Assembly.GetName().Name!; private static string GetVersion() - => typeof(ActivityFusionExecutionDiagnosticEventListener).Assembly.GetName().Version!.ToString(); + => typeof(FusionActivityExecutionDiagnosticEventListener).Assembly.GetName().Version!.ToString(); } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs deleted file mode 100644 index 50d7405768b..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/ActivityFusionExecutionDiagnosticEventListener.cs +++ /dev/null @@ -1,358 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Diagnostics.Scopes; -using HotChocolate.Execution; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using Microsoft.AspNetCore.Http; -using OpenTelemetry.Trace; -using static HotChocolate.Fusion.Diagnostics.ContextKeys; -using static HotChocolate.Fusion.Diagnostics.HotChocolateFusionActivitySource; - -namespace HotChocolate.Fusion.Diagnostics.Listeners; - -internal sealed class ActivityFusionExecutionDiagnosticEventListener : FusionExecutionDiagnosticEventListener -{ - private readonly InstrumentationOptions _options; - private readonly FusionActivityEnricher _enricher; - - public ActivityFusionExecutionDiagnosticEventListener( - FusionActivityEnricher enricher, - InstrumentationOptions options) - { - ArgumentNullException.ThrowIfNull(enricher); - ArgumentNullException.ThrowIfNull(options); - - _enricher = enricher; - _options = options; - } - - public override IDisposable ExecuteRequest(RequestContext context) - { - Activity? activity = null; - - if (_options.SkipExecuteRequest) - { - if (!_options.SkipExecuteHttpRequest - && context.ContextData.TryGetValue(nameof(HttpContext), out var value) - && value is HttpContext httpContext - && httpContext.Items.TryGetValue(HttpRequestActivity, out value) - && value is not null) - { - activity = (Activity)value; - } - else - { - return EmptyScope; - } - } - - activity ??= Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - context.ContextData[RequestActivity] = activity; - - return new ExecuteRequestScope(_enricher, context, activity); - } - - public override void RetrievedDocumentFromCache(RequestContext context) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(RetrievedDocumentFromCache))); - } - } - - public override void RetrievedDocumentFromStorage(RequestContext context) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(RetrievedDocumentFromStorage))); - } - } - - public override void AddedDocumentToCache(RequestContext context) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(AddedDocumentToCache))); - } - } - - public override void AddedOperationPlanToCache(RequestContext context, string operationPlanId) - { - if (context.ContextData.TryGetValue(RequestActivity, out var activity)) - { - Debug.Assert(activity is not null, "The activity mustn't be null!"); - ((Activity)activity).AddEvent(new(nameof(AddedOperationPlanToCache))); - } - } - - public override IDisposable ParseDocument(RequestContext context) - { - if (_options.SkipParseDocument) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - context.ContextData[RequestActivity] = activity; - - return new ParseDocumentScope(_enricher, context, activity); - } - - public override void RequestError(RequestContext context, Exception error) - { - if (context.ContextData.TryGetValue(RequestActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - _enricher.EnrichRequestError(context, activity, error); - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } - } - - public override void RequestError(RequestContext context, IError error) - { - if (context.ContextData.TryGetValue(RequestActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - _enricher.EnrichRequestError(context, activity, error); - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } - } - - public override void ValidationErrors(RequestContext context, IReadOnlyList errors) - { - if (context.ContextData.TryGetValue(ValidateActivity, out var value)) - { - Debug.Assert(value is not null, "The activity mustn't be null!"); - - var activity = (Activity)value; - - foreach (var error in errors) - { - _enricher.EnrichValidationError(context, activity, error); - } - - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); - } - } - - public override IDisposable ValidateDocument(RequestContext context) - { - if (_options.SkipValidateDocument) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - context.ContextData[ValidateActivity] = activity; - - return new ValidateDocumentScope(_enricher, context, activity); - } - - public override IDisposable CoerceVariables(RequestContext context) - { - if (_options.SkipCoerceVariables) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new CoerceVariablesScope(_enricher, context, activity); - } - - public override IDisposable PlanOperation(RequestContext context, string operationPlanId) - { - if (_options.SkipPlanOperation) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new PlanOperationScope(_enricher, context, activity); - } - - public override IDisposable ExecuteOperation(RequestContext context) - { - if (_options.SkipExecuteOperation) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new ExecuteOperationScope(_enricher, context, activity); - } - - public override IDisposable ExecuteOperationNode( - OperationPlanContext context, - OperationExecutionNode node, - string schemaName) - { - if (_options.SkipExecutePlanNodes) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new ExecuteOperationNodeScope(_enricher, context, node, schemaName, activity); - } - - public override IDisposable ExecuteOperationBatchNode( - OperationPlanContext context, - OperationBatchExecutionNode node, - string schemaName) - { - if (_options.SkipExecutePlanNodes) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new ExecuteOperationBatchNodeScope(_enricher, context, node, schemaName, activity); - } - - public override IDisposable ExecuteNodeFieldNode( - OperationPlanContext context, - NodeFieldExecutionNode node) - { - if (_options.SkipExecutePlanNodes) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new ExecuteNodeFieldNodeScope(_enricher, context, node, activity); - } - - public override IDisposable ExecuteIntrospectionNode( - OperationPlanContext context, - IntrospectionExecutionNode node) - { - if (_options.SkipExecutePlanNodes) - { - return EmptyScope; - } - - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return new ExecuteIntrospectionNodeScope(_enricher, context, node, activity); - } - - public override void ExecutionNodeError( - OperationPlanContext context, - ExecutionNode node, - Exception error) - { - if (Activity.Current is { } activity) - { - _enricher.EnrichExecutionNodeError(context, node, error, activity); - } - } - - public override void SourceSchemaTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - Exception error) - { - if (Activity.Current is { } activity) - { - _enricher.EnrichSourceSchemaError(context, node, schemaName, error, activity); - } - } - - public override void SourceSchemaStoreError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - Exception error) - { - if (Activity.Current is { } activity) - { - _enricher.EnrichSourceSchemaError(context, node, schemaName, error, activity); - } - } - - public override IDisposable OnSubscriptionEvent( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId) - { - var activity = Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - return activity; - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs new file mode 100644 index 00000000000..1a6bc0eb45d --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -0,0 +1,277 @@ +using System.Diagnostics; +using HotChocolate.Diagnostics; +using HotChocolate.Execution; +using HotChocolate.Fusion.Execution; +using HotChocolate.Fusion.Execution.Nodes; +using Microsoft.AspNetCore.Http; +using OpenTelemetry.Trace; +using static HotChocolate.Fusion.Diagnostics.HotChocolateFusionActivitySource; + +namespace HotChocolate.Fusion.Diagnostics.Listeners; + +internal sealed class FusionActivityExecutionDiagnosticEventListener( + FusionActivityEnricher enricher, + InstrumentationOptions options) : FusionExecutionDiagnosticEventListener +{ + public override IDisposable ExecuteRequest(RequestContext context) + { + Activity? httpContextActivity = null; + + if (options.SkipExecuteRequest) + { + if (!options.SkipExecuteHttpRequest + && context.Features.TryGet(out var httpContext) + // TODO: Fix this + && httpContext.Items.TryGetValue("TODO context key", out var untypedActivity) + && untypedActivity is Activity activity) + { + httpContextActivity = activity; + } + else + { + return EmptyScope; + } + } + + var span = httpContextActivity is not null + ? new ExecuteRequestSpan(httpContextActivity, context, false) + : ExecuteRequestSpan.Start(Source, context, options); + + if (span is null) + { + return EmptyScope; + } + + context.Features.Set(span); + + return span; + } + + public override void RequestError(RequestContext context, Exception error) + { + if (context.Features.TryGet(out var span)) + { + var activity = span.Activity; + + activity.RecordException(error); + activity.MarkAsError(); + } + } + + public override void RequestError(RequestContext context, IError error) + { + if (context.Features.TryGet(out var span)) + { + var activity = span.Activity; + + activity.RecordError(error); + activity.MarkAsError(); + } + } + + public override IDisposable ParseDocument(RequestContext context) + { + if (options.SkipParseDocument) + { + return EmptyScope; + } + + var span = ParsingSpan.Start(Source, context); + + return span ?? EmptyScope; + } + + // TODO: A dedicated event for parsing errors would be nice + + public override IDisposable ValidateDocument(RequestContext context) + { + if (options.SkipValidateDocument) + { + return EmptyScope; + } + + var span = ValidationSpan.Start(Source, context); + + if (span is null) + { + return EmptyScope; + } + + context.Features.Set(span); + + return span; + } + + public override void ValidationErrors(RequestContext context, IReadOnlyList errors) + { + if (!context.Features.TryGet(out var span)) + { + return; + } + + var activity = span.Activity; + + foreach (var error in errors) + { + activity.RecordError(error); + } + + activity.MarkAsError(); + } + + public override IDisposable PlanOperation(RequestContext context, string operationPlanId) + { + if (options.SkipPlanOperation) + { + return EmptyScope; + } + + var span = PlanOperationSpan.Start(Source, context); + + return span ?? EmptyScope; + } + + public override IDisposable CoerceVariables(RequestContext context) + { + if (options.SkipCoerceVariables) + { + return EmptyScope; + } + + var span = VariableCoercionSpan.Start(Source, context); + + return span ?? EmptyScope; + } + + public override IDisposable ExecuteOperation(RequestContext context) + { + if (options.SkipExecuteOperation) + { + return EmptyScope; + } + + var span = ExecuteOperationSpan.Start(Source, context); + + return span ?? EmptyScope; + } + + public override IDisposable ExecuteOperationNode( + OperationPlanContext context, + OperationExecutionNode node, + string schemaName) + => ExecuteNode(context, node, schemaName); + + public override IDisposable ExecuteOperationBatchNode( + OperationPlanContext context, + OperationBatchExecutionNode node, + string schemaName) + => ExecuteNode(context, node, schemaName); + + public override IDisposable ExecuteNodeFieldNode( + OperationPlanContext context, + NodeFieldExecutionNode node) + => ExecuteNode(context, node, null); + + public override IDisposable ExecuteIntrospectionNode( + OperationPlanContext context, + IntrospectionExecutionNode node) + => ExecuteNode(context, node, null); + + public override void ExecutionNodeError( + OperationPlanContext context, + ExecutionNode node, + Exception error) + { + if (Activity.Current is { } activity) + { + activity.RecordException(error); + activity.MarkAsError(); + } + } + + public override void SourceSchemaTransportError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + Exception error) + { + if (Activity.Current is { } activity) + { + activity.RecordException(error); + activity.MarkAsError(); + } + } + + public override void SourceSchemaStoreError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + Exception error) + { + if (Activity.Current is { } activity) + { + activity.RecordException(error); + activity.MarkAsError(); + } + } + + public override IDisposable OnSubscriptionEvent( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId) + { + var activity = Source.StartActivity(); + + if (activity is null) + { + return EmptyScope; + } + + return activity; + } + + public override void RetrievedDocumentFromCache(RequestContext context) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(RetrievedDocumentFromCache))); + } + } + + public override void RetrievedDocumentFromStorage(RequestContext context) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(RetrievedDocumentFromStorage))); + } + } + + public override void AddedDocumentToCache(RequestContext context) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(AddedDocumentToCache))); + } + } + + public override void AddedOperationPlanToCache(RequestContext context, string operationPlanId) + { + if (context.Features.TryGet(out var span)) + { + span.Activity.AddEvent(new(nameof(AddedOperationPlanToCache))); + } + } + + private IDisposable ExecuteNode(OperationPlanContext context, ExecutionNode node, string? schemaName) + { + if (options.SkipExecutePlanNodes) + { + return EmptyScope; + } + + var span = ExecutePlanNodeSpan.Start(Source, context, node, schemaName); + + return span ?? EmptyScope; + } +} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs index 3e2b3d49d2d..b56704b9e84 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs @@ -4,7 +4,6 @@ using HotChocolate.Execution; using HotChocolate.Language; using OpenTelemetry.Trace; -using static HotChocolate.Fusion.Diagnostics.ContextKeys; namespace HotChocolate.Fusion.Diagnostics.Listeners; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/CoerceVariablesScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/CoerceVariablesScope.cs deleted file mode 100644 index 8361d9d044d..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/CoerceVariablesScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class CoerceVariablesScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichCoerceVariables(Context, Activity); - - protected override void SetStatus() - { - if (Context.VariableValues.Length > 0) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteIntrospectionNodeScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteIntrospectionNodeScope.cs deleted file mode 100644 index 622397a1e7d..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteIntrospectionNodeScope.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteIntrospectionNodeScope( - FusionActivityEnricher enricher, - OperationPlanContext context, - IntrospectionExecutionNode node, - Activity activity) - : NodeScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteIntrospectionNode(Context, node, Activity); - - protected override void SetStatus() - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteNodeFieldNodeScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteNodeFieldNodeScope.cs deleted file mode 100644 index 867b33786e5..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteNodeFieldNodeScope.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteNodeFieldNodeScope( - FusionActivityEnricher enricher, - OperationPlanContext context, - NodeFieldExecutionNode node, - Activity activity) - : NodeScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteNodeFieldNode(Context, node, Activity); - - protected override void SetStatus() - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs deleted file mode 100644 index f9eac94abfd..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationBatchNodeScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteOperationBatchNodeScope( - FusionActivityEnricher enricher, - OperationPlanContext context, - OperationBatchExecutionNode node, - string schemaName, - Activity activity) - : NodeScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteOperationBatchNode(Context, node, schemaName, Activity); - - protected override void SetStatus() - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationNodeScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationNodeScope.cs deleted file mode 100644 index 58e19e11185..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationNodeScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Execution; -using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteOperationNodeScope( - FusionActivityEnricher enricher, - OperationPlanContext context, - OperationExecutionNode node, - string schemaName, - Activity activity) - : NodeScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteOperationNode(Context, node, schemaName, Activity); - - protected override void SetStatus() - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationScope.cs deleted file mode 100644 index 1f69711d4e6..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteOperationScope.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteOperationScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteOperation(Context, Activity); - - protected override void SetStatus() - { - if (Context.Result is null or OperationResult { Errors: [_, ..] }) - { - Activity.SetStatus(Status.Error); - Activity.SetStatus(ActivityStatusCode.Error); - } - else - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteRequestScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteRequestScope.cs deleted file mode 100644 index 6ecca09cc07..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ExecuteRequestScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ExecuteRequestScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichExecuteRequest(Context, Activity); - - protected override void SetStatus() - { - if (Context.Result is null or OperationResult { Errors: [_, ..] }) - { - Activity.SetStatus(Status.Error); - Activity.SetStatus(ActivityStatusCode.Error); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/NodeScopeBase.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/NodeScopeBase.cs deleted file mode 100644 index e0c04291939..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/NodeScopeBase.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Fusion.Execution; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal class NodeScopeBase : IDisposable -{ - private bool _disposed; - - protected NodeScopeBase( - FusionActivityEnricher enricher, - OperationPlanContext context, - Activity activity) - { - Enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - Context = context ?? throw new ArgumentNullException(nameof(context)); - Activity = activity ?? throw new ArgumentNullException(nameof(activity)); - } - - protected FusionActivityEnricher Enricher { get; } - - protected OperationPlanContext Context { get; } - - protected Activity Activity { get; } - - protected virtual void EnrichActivity() { } - - protected virtual void SetStatus() { } - - public void Dispose() - { - if (!_disposed) - { - EnrichActivity(); - SetStatus(); - Activity.Dispose(); - _disposed = true; - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ParseDocumentScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ParseDocumentScope.cs deleted file mode 100644 index 048af8072b1..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ParseDocumentScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ParseDocumentScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichParseDocument(Context, Activity); - - protected override void SetStatus() - { - if (Context.TryGetOperationDocument(out _, out _)) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/PlanOperationScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/PlanOperationScope.cs deleted file mode 100644 index aad6df000df..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/PlanOperationScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class PlanOperationScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichPlanOperationScope(Context, Activity); - - protected override void SetStatus() - { - if (Context.GetOperationPlan() is not null) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/RequestScopeBase.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/RequestScopeBase.cs deleted file mode 100644 index 69403a62676..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/RequestScopeBase.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal class RequestScopeBase : IDisposable -{ - private bool _disposed; - - protected RequestScopeBase( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - { - Enricher = enricher ?? throw new ArgumentNullException(nameof(enricher)); - Context = context ?? throw new ArgumentNullException(nameof(context)); - Activity = activity ?? throw new ArgumentNullException(nameof(activity)); - } - - protected FusionActivityEnricher Enricher { get; } - - protected RequestContext Context { get; } - - protected Activity Activity { get; } - - protected virtual void EnrichActivity() { } - - protected virtual void SetStatus() { } - - public void Dispose() - { - if (!_disposed) - { - EnrichActivity(); - SetStatus(); - Activity.Dispose(); - _disposed = true; - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ValidateDocumentScope.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ValidateDocumentScope.cs deleted file mode 100644 index 2f4b9dc58cf..00000000000 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Scopes/ValidateDocumentScope.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; - -namespace HotChocolate.Fusion.Diagnostics.Scopes; - -internal sealed class ValidateDocumentScope( - FusionActivityEnricher enricher, - RequestContext context, - Activity activity) - : RequestScopeBase(enricher, context, activity) -{ - protected override void EnrichActivity() - => Enricher.EnrichValidateDocument(Context, Activity); - - protected override void SetStatus() - { - if (Context.IsOperationDocumentValid()) - { - Activity.SetStatus(Status.Ok); - Activity.SetStatus(ActivityStatusCode.Ok); - } - } -} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs new file mode 100644 index 00000000000..1348fd31433 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs @@ -0,0 +1,64 @@ +using System.Collections.Frozen; +using System.Diagnostics; +using System.Globalization; +using HotChocolate.Fusion.Execution; +using HotChocolate.Fusion.Execution.Nodes; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ExecutePlanNodeSpan(Activity activity) : SpanBase(activity) +{ + private static FrozenDictionary KindValues { get; } = + new Dictionary + { + [ExecutionNodeType.Operation] = GraphQL.Operation.Step.KindValues.Operation, + [ExecutionNodeType.OperationBatch] = GraphQL.Operation.Step.KindValues.OperationBatch, + [ExecutionNodeType.Introspection] = GraphQL.Operation.Step.KindValues.Introspection, + [ExecutionNodeType.Node] = GraphQL.Operation.Step.KindValues.Node + }.ToFrozenDictionary(); + + public static ExecutePlanNodeSpan? Start( + ActivitySource source, + OperationPlanContext context, + ExecutionNode node, + string? schemaName) + { + var activity = source.StartActivity("GraphQL Step Execution"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + + activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); + activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); + activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); + + if (node is OperationExecutionNode operationExecutionNode) + { + SetSourceSchemaTags(activity, operationExecutionNode.Operation, schemaName); + } + else if (node is OperationBatchExecutionNode batchExecutionNode) + { + SetSourceSchemaTags(activity, batchExecutionNode.Operation, schemaName); + } + + return new ExecutePlanNodeSpan(activity); + } + + private static void SetSourceSchemaTags(Activity activity, OperationSourceText operation, string? schemaName) + { + if (!string.IsNullOrWhiteSpace(schemaName)) + { + activity.SetTag(GraphQL.Source.Name, schemaName); + } + + activity.SetTag(GraphQL.Source.Operation.Name, operation.Name); + activity.SetTag(GraphQL.Source.Operation.Kind, GraphQL.Operation.TypeValues[operation.Type]); + activity.SetTag(GraphQL.Source.Operation.Hash, $"sha256:{operation.Hash}"); + } +} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs new file mode 100644 index 00000000000..9157d4d0f54 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -0,0 +1,57 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class PlanOperationSpan(Activity activity, RequestContext context) : SpanBase(activity) +{ + public static ParsingSpan? Start(ActivitySource source, RequestContext context) + { + var activity = source.StartActivity("GraphQL Operation Planning"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); + + if (context.TryGetDocument(out var document, out _) + && document.GetOperation(context.Request.OperationName) is { } operation) + { + activity.SetTag(GraphQL.Operation.Type, operation.Operation); + } + + var operationName = context.Request.OperationName; + // TODO: This should be conditional + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + // TODO: We need a good mechanism to determine if persisted operations are enabled + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + return new ParsingSpan(activity, context); + } + + protected override void OnComplete() + { + if (context.GetOperationPlan() is not null) + { + Activity.MarkAsSuccess(); + } + } +} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs index 42a6c4696d3..efe60f15948 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs @@ -2,8 +2,18 @@ namespace HotChocolate.Fusion.Planning; +// TODO: Should be internal and match filename public static class FusionDocumentNodeExtensions { + private const string NoOperationFoundMessage = + "There are no operations in the GraphQL document."; + + private const string MultipleOperationMessage = + "The operation name can only be omitted if there is just one operation in a GraphQL document."; + + private const string InvalidOperationNameMessage = + "The specified operation `{0}` cannot be found."; + public static OperationDefinitionNode GetOperation( this DocumentNode document, string? operationName) @@ -27,15 +37,13 @@ public static OperationDefinitionNode GetOperation( } else { - // TODO : EXCEPTION - throw new Exception("OperationResolverHelper_MultipleOperation"); + throw OperationResolverHelper_MultipleOperation(operation, op); } } if (operation is null) { - // TODO : EXCEPTION - throw new Exception("OperationResolverHelper_NoOperationFound"); + throw OperationResolverHelper_NoOperationFound(document); } return operation; @@ -51,8 +59,7 @@ public static OperationDefinitionNode GetOperation( } } - // TODO : EXCEPTION - throw new Exception("OperationResolverHelper_InvalidOperationName"); + throw OperationResolverHelper_InvalidOperationName(document, operationName); } } @@ -73,4 +80,29 @@ public static Dictionary GetFragments( return map; } + + private static GraphQLException OperationResolverHelper_NoOperationFound( + DocumentNode documentNode) => + new(ErrorBuilder.New() + .SetMessage(NoOperationFoundMessage) + .AddLocation(documentNode) + .Build()); + + private static GraphQLException OperationResolverHelper_MultipleOperation( + OperationDefinitionNode firstOperation, + OperationDefinitionNode secondOperation) => + new(ErrorBuilder.New() + .SetMessage(MultipleOperationMessage) + .AddLocation(firstOperation) + .AddLocation(secondOperation) + .Build()); + + private static GraphQLException OperationResolverHelper_InvalidOperationName( + DocumentNode documentNode, + string operationName) => + new(ErrorBuilder.New() + .SetMessage(InvalidOperationNameMessage, operationName) + .AddLocation(documentNode) + .SetExtension("operationName", operationName) + .Build()); } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj index 0fcb3b3147e..52e0cb9bc72 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj @@ -6,6 +6,7 @@ + diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index 9d2200193c4..bc887e92352 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -132,130 +132,6 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() } } - [Fact] - public async Task Create_Operation_Display_Name_With_1_Field() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ a: sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_Operation_Display_Name_With_1_Field_And_Op() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("query GetA { a: sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_Operation_Display_Name_With_3_Field() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ a: sayHello b: sayHello c: sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Create_Operation_Display_Name_With_4_Field() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ a: sayHello b: sayHello c: sayHello d: sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Track_Events_Of_A_Simple_Query_Detailed() { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index c24c4fe1dfe..578794f38b0 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -2,21 +2,13 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.body", "Value": "query SayHelloOperation {\n sayHello\n}" @@ -33,14 +25,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -61,14 +45,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -183,7 +159,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" + "Value": "sha256:80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 8d75efb8373..21d2d60f6f7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -2,21 +2,13 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.body", "Value": "query SayHelloOperation {\n causeFatalError\n}" @@ -37,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -65,14 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -187,7 +163,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "1b35e9142c2e8235f31d2b3ae0de3d2ba54692a7aa6481803c3841fd135f4c4c" + "Value": "sha256:1b35e9142c2e8235f31d2b3ae0de3d2ba54692a7aa6481803c3841fd135f4c4c" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index 1d979da5209..b62d7b855e7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -29,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -61,14 +53,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -78,14 +62,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `causeFatalError` does not exist on the type `Deeper`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `causeFatalError` does not exist on the type `Deeper`." diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap deleted file mode 100644 index 2a09e4799e4..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field.snap +++ /dev/null @@ -1,172 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "91d3f369067488892e5c81c27598c0d43b5ecfe5ad824925965ac60c70351919" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:452ea802c4d1bf2a81a7411b0b361d9f" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_452ea802_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "fe5043810b215e414a23ad906fe02c57ac0adb87cbef5e925297ea3922dea294" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap deleted file mode 100644 index e98e0aba956..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_1_Field_And_Op.snap +++ /dev/null @@ -1,196 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query GetA", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "155189958e55686347a7f921c0f7a1ef143f829f5b116365a297651606d5703f" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetA" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cee0e2939ece72d650cb0331f4be4669" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "GetA_cee0e293_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "dfd8c2288a98a5ade0836a3fb80cd00374fc36f2a66aaa71e170afca30b22517" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap deleted file mode 100644 index 2af5ebb43cb..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_3_Field.snap +++ /dev/null @@ -1,172 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "8b26a2633c9b68833461d6b2249f54600493dfc632399469d5c108e79410ca7b" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2e55fbe10a9e3ddf26935a8f8d15ec89" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_2e55fbe1_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "8826181dc487d072381743cb4417bc07e557ea4fdb3163add5c0fb664febfe31" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap deleted file mode 100644 index c8a394ccd41..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Create_Operation_Display_Name_With_4_Field.snap +++ /dev/null @@ -1,172 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteRequest", - "DisplayName": "query", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseDocument", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "1c020b5562fde1e7673b1f4750bdf6d35f2789819d03bb6b5d088bf445231501" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:a5f924bb2f5f8651014e92e1cc2428c7" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_a5f924bb_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "78fb01a8827e80543966f0f5d34e2dbe7283145ac5de0ce2842af14783f9caeb" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index bcba591c833..e76e057ae62 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -2,20 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query SayHelloOperation", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" } ], "event": [], @@ -29,14 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -57,14 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -179,7 +155,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" + "Value": "sha256:80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index 0adb46c6d65..aef6b71e41a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -29,14 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -61,14 +53,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -78,14 +62,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `sayHello_` does not exist on the type `Query`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `sayHello_` does not exist on the type `Query`." diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index fb303651688..29943780bc9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -2,17 +2,13 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.body", "Value": "{\n sayHello\n}" @@ -33,10 +29,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -57,10 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -163,7 +151,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index b420122648b..712b90f3925 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [], @@ -25,10 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -49,10 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -155,7 +143,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "b6db85f78e867baa06bf8b4f45ed381a2b6bc9f7abd15948f0bfff0967fbc308" + "Value": "sha256:b6db85f78e867baa06bf8b4f45ed381a2b6bc9f7abd15948f0bfff0967fbc308" }, { "Key": "otel.status_code", @@ -207,7 +195,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" + "Value": "sha256:1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 45ea1e6f1d7..d8f906dcc30 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -91,7 +87,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index dc988cb37e7..1432ac4bafb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [], @@ -25,10 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -49,10 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -155,7 +143,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index dc988cb37e7..1432ac4bafb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -2,16 +2,12 @@ "activities": [ { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [], @@ -25,10 +21,6 @@ "Key": "graphql.processing.type", "Value": "parse" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -49,10 +41,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -155,7 +143,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 58d0ce937c4..ce229f83daf 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -168,7 +160,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 1b684b9db01..942049224c0 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -192,7 +184,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 39f5a3227e2..852bdcb51a8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -34,16 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -66,10 +62,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -196,7 +188,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index e38b50e4018..c5c238e14c2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -27,17 +27,13 @@ "Name": "exception", "Tags": [ { - "Key": "exception.message", + "Key": "graphql.error.message", "Value": "Found a NameStart character `d` (100) following a number, which is disallowed." }, { - "Key": "exception.type", + "Key": "graphql.error.code", "Value": "HC0011" }, - { - "Key": "graphql.error.message", - "Value": "Found a NameStart character `d` (100) following a number, which is disallowed." - }, { "Key": "graphql.error.locations", "Value": [ diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index b98fbc938f3..3e36ee1cfa2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,18 +2,9 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], + "DisplayName": "ExecuteHttpRequest", + "Status": "Unset", + "tags": [], "event": [], "activities": [ { @@ -30,16 +21,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -168,7 +151,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index 9ce4ae617ed..3c9fb7d86e2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -2,7 +2,7 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Ok", "tags": [ { @@ -16,10 +16,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -54,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -136,7 +128,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 1b684b9db01..942049224c0 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -30,16 +30,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -62,10 +58,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -192,7 +184,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index e0b763f3881..a2d2538ab6c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -34,16 +34,12 @@ }, { "OperationName": "ExecuteRequest", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Unset", "tags": [ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.type", - "Value": "query" } ], "event": [ @@ -66,10 +62,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -196,7 +188,7 @@ }, { "Key": "graphql.source.operation.hash", - "Value": "a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" }, { "Key": "otel.status_code", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index acf40a7ecb2..2e69b5918d9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -27,17 +27,13 @@ "Name": "exception", "Tags": [ { - "Key": "exception.message", + "Key": "graphql.error.message", "Value": "Expected a `Name`-token, but found a `Integer`-token." }, { - "Key": "exception.type", + "Key": "graphql.error.code", "Value": "HC0011" }, - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, { "Key": "graphql.error.locations", "Value": [ diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 90c5e6da598..20129998150 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -70,14 +66,6 @@ { "Name": "exception", "Tags": [ - { - "Key": "exception.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "exception.type", - "Value": "GRAPHQL_ERROR" - }, { "Key": "graphql.error.message", "Value": "The field `abc` does not exist on the type `Query`." diff --git a/src/HotChocolate/Language/src/Language.Web/DocumentHashProviderBase.cs b/src/HotChocolate/Language/src/Language.Web/DocumentHashProviderBase.cs index 82495992d0d..fa72800232b 100644 --- a/src/HotChocolate/Language/src/Language.Web/DocumentHashProviderBase.cs +++ b/src/HotChocolate/Language/src/Language.Web/DocumentHashProviderBase.cs @@ -15,6 +15,8 @@ internal DocumentHashProviderBase(HashFormat format) public abstract string Name { get; } + public abstract string AlgorithmName { get; } + public HashFormat Format { get; } public OperationDocumentHash ComputeHash(ReadOnlySpan document) @@ -27,7 +29,7 @@ public OperationDocumentHash ComputeHash(ReadOnlySpan document) { var hash = ComputeHash(rented, document.Length); var formattedHash = FormatHash(hash, Format); - return new OperationDocumentHash(formattedHash, Name, Format); + return new OperationDocumentHash(formattedHash, AlgorithmName, Format); } finally { @@ -35,7 +37,7 @@ public OperationDocumentHash ComputeHash(ReadOnlySpan document) } #else var hash = ComputeHash(document, Format); - return new OperationDocumentHash(hash, Name, Format); + return new OperationDocumentHash(hash, AlgorithmName, Format); #endif } @@ -65,7 +67,7 @@ public OperationDocumentHash ComputeHash(ReadOnlySequence document) } #else var hash = ComputeHash(document, Format); - return new OperationDocumentHash(hash, Name, Format); + return new OperationDocumentHash(hash, AlgorithmName, Format); #endif } diff --git a/src/HotChocolate/Language/src/Language.Web/IDocumentHashProvider.cs b/src/HotChocolate/Language/src/Language.Web/IDocumentHashProvider.cs index e0264a71342..47c4ccc1d35 100644 --- a/src/HotChocolate/Language/src/Language.Web/IDocumentHashProvider.cs +++ b/src/HotChocolate/Language/src/Language.Web/IDocumentHashProvider.cs @@ -12,6 +12,11 @@ public interface IDocumentHashProvider /// string Name { get; } + /// + /// The name of the algorithm used for hashing. + /// + string AlgorithmName { get; } + /// /// Gets the format of the document hash. /// diff --git a/src/HotChocolate/Language/src/Language.Web/MD5DocumentHashProvider.cs b/src/HotChocolate/Language/src/Language.Web/MD5DocumentHashProvider.cs index 70afad060b5..0196bba9b2b 100644 --- a/src/HotChocolate/Language/src/Language.Web/MD5DocumentHashProvider.cs +++ b/src/HotChocolate/Language/src/Language.Web/MD5DocumentHashProvider.cs @@ -18,6 +18,8 @@ public MD5DocumentHashProvider(HashFormat format) public override string Name => "md5Hash"; + public override string AlgorithmName => "md5"; + #if NETSTANDARD2_0 protected override byte[] ComputeHash(byte[] document, int length) { diff --git a/src/HotChocolate/Language/src/Language.Web/Sha1DocumentHashProvider.cs b/src/HotChocolate/Language/src/Language.Web/Sha1DocumentHashProvider.cs index 0d3547d1933..38f7e62f81e 100644 --- a/src/HotChocolate/Language/src/Language.Web/Sha1DocumentHashProvider.cs +++ b/src/HotChocolate/Language/src/Language.Web/Sha1DocumentHashProvider.cs @@ -22,6 +22,8 @@ public Sha1DocumentHashProvider(HashFormat format) public override string Name => "sha1Hash"; + public override string AlgorithmName => "sha1"; + #if NETSTANDARD2_0 protected override byte[] ComputeHash(byte[] document, int length) => _sha.Value!.ComputeHash(document, 0, length); diff --git a/src/HotChocolate/Language/src/Language.Web/Sha256DocumentHashProvider.cs b/src/HotChocolate/Language/src/Language.Web/Sha256DocumentHashProvider.cs index 0bdfa968d02..6412260f720 100644 --- a/src/HotChocolate/Language/src/Language.Web/Sha256DocumentHashProvider.cs +++ b/src/HotChocolate/Language/src/Language.Web/Sha256DocumentHashProvider.cs @@ -22,6 +22,8 @@ public Sha256DocumentHashProvider(HashFormat format) public override string Name => "sha256Hash"; + public override string AlgorithmName => "sha256"; + #if NETSTANDARD2_0 protected override byte[] ComputeHash(byte[] document, int length) { diff --git a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.cs b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.cs index 014e690e2a3..f2cf19074eb 100644 --- a/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.cs +++ b/src/HotChocolate/Language/src/Language.Web/Utf8GraphQLRequestParser.cs @@ -328,7 +328,7 @@ private readonly GraphQLRequest ParseRequest(ref Utf8JsonReader reader, Operatio && TryExtractHash(extensions, out var hash)) { documentId = new OperationDocumentId(hash); - documentHash = new OperationDocumentHash(hash, _hashProvider!.Name, _hashProvider.Format); + documentHash = new OperationDocumentHash(hash, _hashProvider!.AlgorithmName, _hashProvider.Format); } // Parse the GraphQL document if provided diff --git a/src/HotChocolate/Language/test/Language.Web.Tests/Utf8GraphQLRequestParserTests.cs b/src/HotChocolate/Language/test/Language.Web.Tests/Utf8GraphQLRequestParserTests.cs index cd729e3471c..cba67360c1c 100644 --- a/src/HotChocolate/Language/test/Language.Web.Tests/Utf8GraphQLRequestParserTests.cs +++ b/src/HotChocolate/Language/test/Language.Web.Tests/Utf8GraphQLRequestParserTests.cs @@ -458,7 +458,7 @@ public void Parse_Apollo_AQP_SignatureQuery() Assert.True(request.Extensions!.RootElement.TryGetProperty("persistedQuery", out _)); Assert.Null(request.Document); Assert.Equal("hashOfQuery", request.DocumentHash?.Value); - Assert.Equal("sha256Hash", request.DocumentHash?.AlgorithmName); + Assert.Equal("sha256", request.DocumentHash?.AlgorithmName); } [Fact] diff --git a/src/HotChocolate/PersistedOperations/src/PersistedOperations.Pipeline/Execution/Pipeline/ReadPersistedOperationMiddleware.cs b/src/HotChocolate/PersistedOperations/src/PersistedOperations.Pipeline/Execution/Pipeline/ReadPersistedOperationMiddleware.cs index 43f23ce6e04..0905fb5d30d 100644 --- a/src/HotChocolate/PersistedOperations/src/PersistedOperations.Pipeline/Execution/Pipeline/ReadPersistedOperationMiddleware.cs +++ b/src/HotChocolate/PersistedOperations/src/PersistedOperations.Pipeline/Execution/Pipeline/ReadPersistedOperationMiddleware.cs @@ -86,7 +86,7 @@ private static DocumentNode GetOrParseDocument(IOperationDocument document) private OperationDocumentHash GetDocumentHash(IOperationDocument document) { if (document is IOperationDocumentHashProvider hashProvider - && _documentHashAlgorithm.Name.Equals(hashProvider.Hash.AlgorithmName) + && _documentHashAlgorithm.AlgorithmName.Equals(hashProvider.Hash.AlgorithmName) && _documentHashAlgorithm.Format.Equals(hashProvider.Hash.Format)) { return hashProvider.Hash; diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index bdeb88cdafb..b018a87beb2 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -598,10 +598,16 @@ builder.Services ## OpenTelemetry span attribute changes -The OpenTelemetry span attributes emitted by `AddInstrumentation()` have been updated to align with the [proposed OpenTelemetry semantic conventions for GraphQL](https://github.com/graphql/otel-wg/blob/main/spec/spans.yml). +The OpenTelemetry span attributes emitted by `AddInstrumentation()` have been updated to align with the [proposed OpenTelemetry semantic conventions for GraphQL](https://github.com/graphql/otel-wg/blob/main/spec). If you have dashboards or alerts that filter on the old attribute names or values, update them accordingly. +## Removed attributes + +| Attribute | +| --------- | +| TODO | + ### Renamed attributes | Old Attribute | New Attribute | From d6b2c4519a463a09e7d8d15b6354196451a81c5e Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 21:35:42 +0100 Subject: [PATCH 11/37] wip: more cleanup --- .../Diagnostics.Core/ActivityEnricherBase.cs | 312 ------------------ .../Spans/Http/ExecuteHttpRequestSpan.cs | 227 +++++++++++++ .../Spans/Http/FormatHttpResponseSpan.cs | 21 ++ .../Spans/Http/ParseHttpRequestSpan.cs | 31 ++ ...nosticsRequestExecutorBuilderExtensions.cs | 5 +- .../ActivityDataLoaderDiagnosticListener.cs | 2 + .../ActivityExecutionDiagnosticListener.cs | 8 +- .../ActivityServerDiagnosticListener.cs | 80 ++--- ...agnosticsFusionGatewayBuilderExtensions.cs | 5 +- ...ctivityExecutionDiagnosticEventListener.cs | 2 + .../FusionActivityServerDiagnosticListener.cs | 80 ++--- 11 files changed, 340 insertions(+), 433 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 7444e04ac0c..67c8d979572 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -18,316 +18,4 @@ namespace HotChocolate.Diagnostics; /// public abstract class ActivityEnricherBase(InstrumentationOptionsBase options) { - private readonly ConditionalWeakTable _queryCache = []; - - public virtual void EnrichExecuteHttpRequest( - HttpContext context, - HttpRequestKind kind, - Activity activity) - { - switch (kind) - { - case HttpRequestKind.HttpPost: - activity.DisplayName = "GraphQL HTTP POST"; - break; - case HttpRequestKind.HttpMultiPart: - activity.DisplayName = "GraphQL HTTP POST MultiPart"; - break; - case HttpRequestKind.HttpGet: - activity.DisplayName = "GraphQL HTTP GET"; - break; - case HttpRequestKind.HttpGetSchema: - activity.DisplayName = "GraphQL HTTP GET SDL"; - break; - } - - activity.SetTag(GraphQL.Http.Kind, kind); - - if (!(context.Items.TryGetValue(SchemaName, out var value) - && value is string schemaName)) - { - schemaName = ISchemaDefinition.DefaultName; - } - - activity.SetTag(GraphQL.Schema.Name, schemaName); - } - - public virtual void EnrichSingleRequest( - HttpContext context, - GraphQLRequest request, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Single); - - if (request.DocumentId is not null - && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) - { - if (!_queryCache.TryGetValue(request.Document, out var query)) - { - query = request.Document.Print(); - _queryCache.Add(request.Document, query); - } - - activity.SetTag(GraphQL.Http.Request.QueryBody, query); - } - - if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) - { - activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); - } - - if (request.Variables is not null - && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - public virtual void EnrichBatchRequest( - HttpContext context, - IReadOnlyList batch, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Batch); - - for (var i = 0; i < batch.Count; i++) - { - var request = batch[i]; - - if (request.DocumentId is not null - && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryId(i), request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryHash(i), request.DocumentHash.Value); - } - - if (request.Document is not null - && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) - { - activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryBody(i), request.Document.Print()); - } - - if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) - { - activity.SetTag(GraphQL.Http.Request.BatchRequest.OperationName(i), request.OperationName); - } - - if (request.Variables is not null - && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichBatchVariables(context, request, request.Variables, i, activity); - } - - if (request.Extensions is not null - && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichBatchExtensions(context, request, request.Extensions, i, activity); - } - } - } - - public virtual void EnrichOperationBatchRequest( - HttpContext context, - GraphQLRequest request, - IReadOnlyList operations, - Activity activity) - { - activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.OperationBatch); - - if (request.DocumentId is not null - && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) - { - activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); - } - - if (request.DocumentHash is not null - && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) - { - activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); - } - - if (request.Document is not null - && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) - { - activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); - } - - if (request.OperationName is not null - && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) - { - activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); - } - - if (request.Variables is not null - && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) - { - EnrichRequestVariables(context, request, request.Variables, activity); - } - - if (request.Extensions is not null - && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) - { - EnrichRequestExtensions(context, request, request.Extensions, activity); - } - } - - protected virtual void EnrichRequestVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - Activity activity) - => activity.SetTag(GraphQL.Http.Request.Variables, variables.RootElement.ToString()); - - protected virtual void EnrichBatchVariables( - HttpContext context, - GraphQLRequest request, - JsonDocument variables, - int index, - Activity activity) - => activity.SetTag( - GraphQL.Http.Request.BatchRequest.Variables(index), - variables.RootElement.ToString()); - - protected virtual void EnrichRequestExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - Activity activity) - { - try - { - activity.SetTag( - GraphQL.Http.Request.Extensions, - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - protected virtual void EnrichBatchExtensions( - HttpContext context, - GraphQLRequest request, - JsonDocument extensions, - int index, - Activity activity) - { - try - { - activity.SetTag( - GraphQL.Http.Request.BatchRequest.Extensions(index), - extensions.RootElement.ToString()); - } - catch - { - // Ignore any errors - } - } - - public virtual void EnrichHttpRequestError( - HttpContext context, - IError error, - Activity activity) - => EnrichError(activity, error); - - public virtual void EnrichHttpRequestError( - HttpContext context, - Exception exception, - Activity activity) - => activity.RecordException(exception); - - public virtual void EnrichParseHttpRequest(HttpContext context, Activity activity) - { - activity.DisplayName = "Parse HTTP Request"; - } - - public virtual void EnrichFormatHttpResponse(HttpContext context, Activity activity) - { - activity.DisplayName = "Format HTTP Response"; - } - - public virtual void EnrichParserErrors(HttpContext context, IError error, Activity activity) - => EnrichError(activity, error); - - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - Exception exception) - { - activity.RecordException(exception); - } - - public virtual void EnrichRequestError( - RequestContext context, - Activity activity, - IError error) - => EnrichError(activity, error); - - protected virtual void EnrichError(Activity activity, IError error) - { - if (error.Exception is { } exception) - { - activity.RecordException(exception); - } - - var tags = new ActivityTagsCollection - { - [GraphQL.Error.Message] = error.Message - }; - - if (error.Path is not null) - { - tags[GraphQL.Error.Path] = error.Path.Print(); - } - - if (!string.IsNullOrEmpty(error.Code)) - { - tags[GraphQL.Error.Code] = error.Code; - } - - if (error.Locations is { Count: > 0 }) - { - var locations = new object[error.Locations.Count]; - for (var i = 0; i < error.Locations.Count; i++) - { - var location = error.Locations[i]; - locations[i] = new Dictionary - { - ["line"] = location.Line, - ["column"] = location.Column - }; - } - - tags[GraphQL.Error.Locations] = locations; - } - - // TODO: Not sure if this is correct according to the spec - activity.AddEvent(new ActivityEvent("exception", default, tags)); - } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs new file mode 100644 index 00000000000..27941526ffc --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -0,0 +1,227 @@ +using System.Diagnostics; +using System.Text.Json; +using Microsoft.AspNetCore.Http; +using HotChocolate.AspNetCore.Instrumentation; +using HotChocolate.Execution; +using HotChocolate.Language; +using HotChocolate.Language.Utilities; +using OpenTelemetry.Trace; +using static HotChocolate.Diagnostics.SemanticConventions; +using static HotChocolate.WellKnownContextData; + +namespace HotChocolate.Diagnostics; + +internal sealed class ExecuteHttpRequestSpan( + Activity activity, + InstrumentationOptionsBase options) : SpanBase(activity) +{ + public static ExecuteHttpRequestSpan? Start( + ActivitySource source, + HttpContext httpContext, + HttpRequestKind kind, + InstrumentationOptionsBase options) + { + var activity = source.StartActivity(); + + if (activity is null) + { + return null; + } + + switch (kind) + { + case HttpRequestKind.HttpPost: + activity.DisplayName = "GraphQL HTTP POST"; + break; + case HttpRequestKind.HttpMultiPart: + activity.DisplayName = "GraphQL HTTP POST MultiPart"; + break; + case HttpRequestKind.HttpGet: + activity.DisplayName = "GraphQL HTTP GET"; + break; + case HttpRequestKind.HttpGetSchema: + activity.DisplayName = "GraphQL HTTP GET SDL"; + break; + } + + activity.SetTag(GraphQL.Http.Kind, kind); + + if (!(httpContext.Items.TryGetValue(SchemaName, out var value) + && value is string schemaName)) + { + schemaName = ISchemaDefinition.DefaultName; + } + + activity.SetTag(GraphQL.Schema.Name, schemaName); + activity.MarkAsSuccess(); + + return new ExecuteHttpRequestSpan(activity, options); + } + + public void SetSingleRequestDetails(GraphQLRequest request) + { + Activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Single); + + if (request.DocumentId is not null + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + } + + if (request.Document is not null + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) + { + Activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); + } + + if (request.OperationName is not null + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) + { + Activity.SetTag(GraphQL.Http.Request.OperationName, request.OperationName); + } + + if (request.Variables is not null + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + Activity.SetTag(GraphQL.Http.Request.Variables, request.Variables.RootElement.ToString()); + } + + if (request.Extensions is not null + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + try + { + Activity.SetTag(GraphQL.Http.Request.Extensions, request.Extensions.RootElement.ToString()); + } + catch + { + // Ignore any errors + } + } + } + + public void SetBatchRequestDetails(IReadOnlyList batch) + { + Activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.Batch); + + for (var i = 0; i < batch.Count; i++) + { + var request = batch[i]; + + if (request.DocumentId is not null + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + Activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryId(i), request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + Activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryHash(i), request.DocumentHash.Value); + } + + if (request.Document is not null + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) + { + Activity.SetTag(GraphQL.Http.Request.BatchRequest.QueryBody(i), request.Document.Print()); + } + + if (request.OperationName is not null + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) + { + Activity.SetTag(GraphQL.Http.Request.BatchRequest.OperationName(i), request.OperationName); + } + + if (request.Variables is not null + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + Activity.SetTag( + GraphQL.Http.Request.BatchRequest.Variables(i), + request.Variables.RootElement.ToString()); + } + + if (request.Extensions is not null + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + try + { + Activity.SetTag( + GraphQL.Http.Request.BatchRequest.Extensions(i), + request.Extensions.RootElement.ToString()); + } + catch + { + // Ignore any errors + } + } + } + } + + public void SetOperationBatchRequestDetails( + GraphQLRequest request, + IReadOnlyList operations) + { + Activity.SetTag(GraphQL.Http.Request.Type, GraphQL.Http.Request.Types.OperationBatch); + + if (request.DocumentId is not null + && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) + { + Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + } + + if (request.DocumentHash is not null + && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) + { + Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + } + + if (request.Document is not null + && (options.RequestDetails & RequestDetails.Document) == RequestDetails.Document) + { + Activity.SetTag(GraphQL.Http.Request.QueryBody, request.Document.Print()); + } + + if (request.OperationName is not null + && (options.RequestDetails & RequestDetails.OperationName) == RequestDetails.OperationName) + { + Activity.SetTag(GraphQL.Http.Request.Operations, string.Join(" -> ", operations)); + } + + if (request.Variables is not null + && (options.RequestDetails & RequestDetails.Variables) == RequestDetails.Variables) + { + Activity.SetTag(GraphQL.Http.Request.Variables, request.Variables.RootElement.ToString()); + } + + if (request.Extensions is not null + && (options.RequestDetails & RequestDetails.Extensions) == RequestDetails.Extensions) + { + try + { + Activity.SetTag(GraphQL.Http.Request.Extensions, request.Extensions.RootElement.ToString()); + } + catch + { + // Ignore any errors + } + } + } + + public void RecordError(IError error) + { + Activity.RecordError(error); + Activity.MarkAsError(); + } + + public void RecordError(Exception exception) + { + Activity.RecordException(exception); + Activity.MarkAsError(); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs new file mode 100644 index 00000000000..6e5ac323e30 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs @@ -0,0 +1,21 @@ +using System.Diagnostics; +using OpenTelemetry.Trace; + +namespace HotChocolate.Diagnostics; + +internal sealed class FormatHttpResponseSpan(Activity activity) : SpanBase(activity) +{ + public static FormatHttpResponseSpan? Start(ActivitySource source) + { + var activity = source.StartActivity("Format HTTP Response"); + + if (activity is null) + { + return null; + } + + activity.MarkAsSuccess(); + + return new FormatHttpResponseSpan(activity); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs new file mode 100644 index 00000000000..00338bba9d2 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs @@ -0,0 +1,31 @@ +using System.Diagnostics; +using OpenTelemetry.Trace; + +namespace HotChocolate.Diagnostics; + +internal sealed class ParseHttpRequestSpan(Activity activity) : SpanBase(activity) +{ + public static ParseHttpRequestSpan? Start(ActivitySource source) + { + var activity = source.StartActivity("Parse HTTP Request"); + + if (activity is null) + { + return null; + } + + activity.MarkAsSuccess(); + + return new ParseHttpRequestSpan(activity); + } + + public void RecordErrors(IReadOnlyList errors) + { + foreach (var error in errors) + { + Activity.RecordError(error); + } + + Activity.MarkAsError(); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Extensions/DiagnosticsRequestExecutorBuilderExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Extensions/DiagnosticsRequestExecutorBuilderExtensions.cs index 47493fa3a0b..d3b40ac99cd 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Extensions/DiagnosticsRequestExecutorBuilderExtensions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Extensions/DiagnosticsRequestExecutorBuilderExtensions.cs @@ -80,8 +80,5 @@ public static IRequestExecutorBuilder AddInstrumentation( return builder; } - private sealed class InternalActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) - : ActivityEnricher(stringBuilderPool, options); + private sealed class InternalActivityEnricher(InstrumentationOptions options) : ActivityEnricher(options); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index 03c0506367b..e14337e3131 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -9,6 +9,8 @@ internal sealed class ActivityDataLoaderDiagnosticListener( InstrumentationOptions options) : DataLoaderDiagnosticEventListener { + private readonly ActivityEnricher _enricher = enricher; + public override IDisposable ExecuteBatch( IDataLoader dataLoader, IReadOnlyList keys) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index 98c186b5a5e..dc10a7f67c2 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -12,6 +12,8 @@ internal sealed class ActivityExecutionDiagnosticListener( ActivityEnricher enricher, InstrumentationOptions options) : ExecutionDiagnosticEventListener { + private readonly ActivityEnricher _enricher = enricher; + public override bool EnableResolveFieldValue => true; public override IDisposable ExecuteRequest(RequestContext context) @@ -22,11 +24,9 @@ public override IDisposable ExecuteRequest(RequestContext context) { if (!options.SkipExecuteHttpRequest && context.Features.TryGet(out var httpContext) - // TODO: Fix this - && httpContext.Items.TryGetValue("TODO context key", out var untypedActivity) - && untypedActivity is Activity activity) + && httpContext.Features.Get() is { } httpRequestSpan) { - httpContextActivity = activity; + httpContextActivity = httpRequestSpan.Activity; } else { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs index 5a4705d3681..308d788a67a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityServerDiagnosticListener.cs @@ -1,10 +1,8 @@ -using System.Diagnostics; using Microsoft.AspNetCore.Http; using HotChocolate.AspNetCore.Instrumentation; using HotChocolate.Execution; using HotChocolate.Language; -using OpenTelemetry.Trace; -using static HotChocolate.Diagnostics.ContextKeys; +using static HotChocolate.Diagnostics.HotChocolateActivitySource; namespace HotChocolate.Diagnostics.Listeners; @@ -13,6 +11,8 @@ internal sealed class ActivityServerDiagnosticListener( InstrumentationOptions options) : ServerDiagnosticEventListener { + private readonly ActivityEnricher _enricher = enricher; + public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestKind kind) { if (options.SkipExecuteHttpRequest) @@ -20,35 +20,33 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK return EmptyScope; } - var activity = HotChocolateActivitySource.Source.StartActivity(); + var span = ExecuteHttpRequestSpan.Start(Source, context, kind, options); - if (activity is null) + if (span is null) { return EmptyScope; } - enricher.EnrichExecuteHttpRequest(context, kind, activity); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[HttpRequestActivity] = activity; + context.Features.Set(span); - return activity; + return span; } public override void StartSingleRequest(HttpContext context, GraphQLRequest request) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichSingleRequest(context, request, (Activity)activity!); + span.SetSingleRequestDetails(request); } } public override void StartBatchRequest(HttpContext context, IReadOnlyList batch) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichBatchRequest(context, batch, (Activity)activity!); + span.SetBatchRequestDetails(batch); } } @@ -58,33 +56,25 @@ public override void StartOperationBatchRequest( IReadOnlyList operations) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichOperationBatchRequest( - context, - request, - operations, - (Activity)activity!); + span.SetOperationBatchRequestDetails(request, operations); } } public override void HttpRequestError(HttpContext context, IError error) { - if (context.Items.TryGetValue(HttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - enricher.EnrichHttpRequestError(context, error, activity); - activity.SetStatus(Status.Error); + span.RecordError(error); } } public override void HttpRequestError(HttpContext context, Exception exception) { - if (context.Items.TryGetValue(HttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - enricher.EnrichHttpRequestError(context, exception, activity); - activity.SetStatus(Status.Error); + span.RecordError(exception); } } @@ -95,34 +85,23 @@ public override IDisposable ParseHttpRequest(HttpContext context) return EmptyScope; } - var activity = HotChocolateActivitySource.Source.StartActivity(); + var span = ParseHttpRequestSpan.Start(Source); - if (activity is null) + if (span is null) { return EmptyScope; } - enricher.EnrichParseHttpRequest(context, activity); - activity.SetStatus(Status.Ok); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[ParseHttpRequestActivity] = activity; + context.Features.Set(span); - return activity; + return span; } public override void ParserErrors(HttpContext context, IReadOnlyList errors) { - if (context.Items.TryGetValue(ParseHttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - - foreach (var error in errors) - { - enricher.EnrichParserErrors(context, error, activity); - } - - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); + span.RecordErrors(errors); } } @@ -133,17 +112,8 @@ public override IDisposable FormatHttpResponse(HttpContext context, OperationRes return EmptyScope; } - var activity = HotChocolateActivitySource.Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - enricher.EnrichFormatHttpResponse(context, activity); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[FormatHttpResponseActivity] = activity; + var span = FormatHttpResponseSpan.Start(Source); - return activity; + return span ?? EmptyScope; } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs index b6825ab8cdf..d475f4fd2a6 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Extensions/DiagnosticsFusionGatewayBuilderExtensions.cs @@ -49,8 +49,5 @@ public static IFusionGatewayBuilder AddInstrumentation( return builder; } - private sealed class InternalActivityEnricher( - ObjectPool stringBuilderPool, - InstrumentationOptions options) - : FusionActivityEnricher(stringBuilderPool, options); + private sealed class InternalActivityEnricher(InstrumentationOptions options) : FusionActivityEnricher(options); } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 1a6bc0eb45d..1ff0a33cc68 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -13,6 +13,8 @@ internal sealed class FusionActivityExecutionDiagnosticEventListener( FusionActivityEnricher enricher, InstrumentationOptions options) : FusionExecutionDiagnosticEventListener { + private readonly FusionActivityEnricher _enricher = enricher; + public override IDisposable ExecuteRequest(RequestContext context) { Activity? httpContextActivity = null; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs index b56704b9e84..3f4b7c30f9c 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityServerDiagnosticListener.cs @@ -1,9 +1,9 @@ -using System.Diagnostics; using Microsoft.AspNetCore.Http; using HotChocolate.AspNetCore.Instrumentation; +using HotChocolate.Diagnostics; using HotChocolate.Execution; using HotChocolate.Language; -using OpenTelemetry.Trace; +using static HotChocolate.Fusion.Diagnostics.HotChocolateFusionActivitySource; namespace HotChocolate.Fusion.Diagnostics.Listeners; @@ -12,6 +12,8 @@ internal sealed class FusionActivityServerDiagnosticListener( InstrumentationOptions options) : ServerDiagnosticEventListener { + private readonly FusionActivityEnricher _enricher = enricher; + public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestKind kind) { if (options.SkipExecuteHttpRequest) @@ -19,35 +21,33 @@ public override IDisposable ExecuteHttpRequest(HttpContext context, HttpRequestK return EmptyScope; } - var activity = HotChocolateFusionActivitySource.Source.StartActivity(); + var span = ExecuteHttpRequestSpan.Start(Source, context, kind, options); - if (activity is null) + if (span is null) { return EmptyScope; } - enricher.EnrichExecuteHttpRequest(context, kind, activity); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[HttpRequestActivity] = activity; + context.Features.Set(span); - return activity; + return span; } public override void StartSingleRequest(HttpContext context, GraphQLRequest request) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichSingleRequest(context, request, (Activity)activity!); + span.SetSingleRequestDetails(request); } } public override void StartBatchRequest(HttpContext context, IReadOnlyList batch) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichBatchRequest(context, batch, (Activity)activity!); + span.SetBatchRequestDetails(batch); } } @@ -57,33 +57,25 @@ public override void StartOperationBatchRequest( IReadOnlyList operations) { if (options.IncludeRequestDetails - && context.Items.TryGetValue(HttpRequestActivity, out var activity)) + && context.Features.Get() is { } span) { - enricher.EnrichOperationBatchRequest( - context, - request, - operations, - (Activity)activity!); + span.SetOperationBatchRequestDetails(request, operations); } } public override void HttpRequestError(HttpContext context, IError error) { - if (context.Items.TryGetValue(HttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - enricher.EnrichHttpRequestError(context, error, activity); - activity.SetStatus(Status.Error); + span.RecordError(error); } } public override void HttpRequestError(HttpContext context, Exception exception) { - if (context.Items.TryGetValue(HttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - enricher.EnrichHttpRequestError(context, exception, activity); - activity.SetStatus(Status.Error); + span.RecordError(exception); } } @@ -94,34 +86,23 @@ public override IDisposable ParseHttpRequest(HttpContext context) return EmptyScope; } - var activity = HotChocolateFusionActivitySource.Source.StartActivity(); + var span = ParseHttpRequestSpan.Start(Source); - if (activity is null) + if (span is null) { return EmptyScope; } - enricher.EnrichParseHttpRequest(context, activity); - activity.SetStatus(Status.Ok); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[ParseHttpRequestActivity] = activity; + context.Features.Set(span); - return activity; + return span; } public override void ParserErrors(HttpContext context, IReadOnlyList errors) { - if (context.Items.TryGetValue(ParseHttpRequestActivity, out var value)) + if (context.Features.Get() is { } span) { - var activity = (Activity)value!; - - foreach (var error in errors) - { - enricher.EnrichParserErrors(context, error, activity); - } - - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); + span.RecordErrors(errors); } } @@ -132,17 +113,8 @@ public override IDisposable FormatHttpResponse(HttpContext context, OperationRes return EmptyScope; } - var activity = HotChocolateFusionActivitySource.Source.StartActivity(); - - if (activity is null) - { - return EmptyScope; - } - - enricher.EnrichFormatHttpResponse(context, activity); - activity.SetStatus(ActivityStatusCode.Ok); - context.Items[FormatHttpResponseActivity] = activity; + var span = FormatHttpResponseSpan.Start(Source); - return activity; + return span ?? EmptyScope; } } From 8754015513e20cf794bb7eb9aad311ede8ac0c93 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Wed, 4 Mar 2026 22:14:03 +0100 Subject: [PATCH 12/37] Add back enrichment --- .../Diagnostics.Core/ActivityEnricherBase.cs | 104 ++++++++++++++++-- .../Spans/AnalyzeOperationComplexitySpan.cs | 16 ++- .../Spans/ExecuteOperationSpan.cs | 14 ++- .../Spans/ExecuteRequestSpan.cs | 6 +- .../Spans/Http/ExecuteHttpRequestSpan.cs | 22 +++- .../Spans/Http/FormatHttpResponseSpan.cs | 18 ++- .../Spans/Http/ParseHttpRequestSpan.cs | 20 +++- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 14 ++- .../Diagnostics.Core/Spans/ValidationSpan.cs | 14 ++- .../Spans/VariableCoercionSpan.cs | 14 ++- .../src/Diagnostics/ActivityEnricher.cs | 45 +++++++- .../ActivityDataLoaderDiagnosticListener.cs | 10 +- .../ActivityExecutionDiagnosticListener.cs | 32 ++++-- .../ActivityServerDiagnosticListener.cs | 6 +- .../Diagnostics/Spans/CompileOperationSpan.cs | 14 ++- .../Diagnostics/Spans/DataLoaderBatchSpan.cs | 16 ++- .../Spans/DataLoaderDispatchSpan.cs | 15 ++- .../src/Diagnostics/Spans/ResolveFieldSpan.cs | 14 ++- .../FusionActivityEnricher.cs | 52 ++++++++- ...ctivityExecutionDiagnosticEventListener.cs | 42 +++++-- .../FusionActivityServerDiagnosticListener.cs | 6 +- .../Spans/ExecutePlanNodeSpan.cs | 18 ++- .../Spans/PlanOperationSpan.cs | 17 ++- ...per.cs => FusionDocumentNodeExtensions.cs} | 3 +- .../HotChocolate.Fusion.Utilities.csproj | 1 - 25 files changed, 442 insertions(+), 91 deletions(-) rename src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/{OperationResolverHelper.cs => FusionDocumentNodeExtensions.cs} (97%) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 67c8d979572..80bfaa28d62 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -1,21 +1,107 @@ using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Text.Json; using Microsoft.AspNetCore.Http; using HotChocolate.AspNetCore.Instrumentation; using HotChocolate.Execution; using HotChocolate.Language; -using HotChocolate.Language.Utilities; -using OpenTelemetry.Trace; -using static HotChocolate.Diagnostics.SemanticConventions; -using static HotChocolate.WellKnownContextData; namespace HotChocolate.Diagnostics; /// -/// Base class for activity enrichers that provides shared enrichment logic -/// for HTTP request handling, error handling, and common span enrichment. +/// Base class for activity enrichers that allows adding additional information +/// to the activity spans created by the diagnostics system. /// -public abstract class ActivityEnricherBase(InstrumentationOptionsBase options) +public abstract class ActivityEnricherBase { + public virtual void EnrichExecuteHttpRequest( + Activity activity, + HttpContext httpContext, + HttpRequestKind kind) { } + + public virtual void EnrichStartSingleRequest( + Activity activity, + HttpContext httpContext, + GraphQLRequest request) { } + + public virtual void EnrichStartBatchRequest( + Activity activity, + HttpContext httpContext, + IReadOnlyList batch) { } + + public virtual void EnrichStartOperationBatchRequest( + Activity activity, + HttpContext httpContext, + GraphQLRequest request, + IReadOnlyList operations) { } + + public virtual void EnrichHttpRequestError( + Activity activity, + HttpContext httpContext, + IError error) { } + + public virtual void EnrichHttpRequestError( + Activity activity, + HttpContext httpContext, + Exception exception) { } + + public virtual void EnrichParseHttpRequest( + Activity activity, + HttpContext httpContext) { } + + public virtual void EnrichParserErrors( + Activity activity, + HttpContext httpContext, + IReadOnlyList errors) { } + + public virtual void EnrichFormatHttpResponse( + Activity activity, + HttpContext httpContext) { } + + public virtual void EnrichExecuteRequest( + Activity activity, + RequestContext context) { } + + public virtual void EnrichRequestError( + Activity activity, + RequestContext context, + Exception exception) { } + + public virtual void EnrichRequestError( + Activity activity, + RequestContext context, + IError error) { } + + public virtual void EnrichParseDocument( + Activity activity, + RequestContext context) { } + + public virtual void EnrichValidateDocument( + Activity activity, + RequestContext context) { } + + public virtual void EnrichValidationErrors( + Activity activity, + RequestContext context, + IReadOnlyList errors) { } + + public virtual void EnrichAnalyzeOperationCost( + Activity activity, + RequestContext context) { } + + public virtual void EnrichOperationCost( + Activity activity, + RequestContext context, + double fieldCost, + double typeCost) { } + + public virtual void EnrichCoerceVariables( + Activity activity, + RequestContext context) { } + + public virtual void EnrichExecuteOperation( + Activity activity, + RequestContext context) { } + + public virtual void EnrichError(Activity activity, IError error) { } + + public virtual void EnrichException(Activity activity, Exception exception) { } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 96bab84e9ab..f0ecd04c0ec 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -4,11 +4,17 @@ namespace HotChocolate.Diagnostics; -internal sealed class AnalyzeOperationComplexitySpan(Activity activity) : SpanBase(activity) +internal sealed class AnalyzeOperationComplexitySpan( + Activity activity, + RequestContext context, + ActivityEnricherBase enricher) : SpanBase(activity) { private bool _costSet; - public static AnalyzeOperationComplexitySpan? Start(ActivitySource source, RequestContext context) + public static AnalyzeOperationComplexitySpan? Start( + ActivitySource source, + RequestContext context, + ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Complexity Analyzation"); @@ -46,7 +52,7 @@ internal sealed class AnalyzeOperationComplexitySpan(Activity activity) : SpanBa activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new AnalyzeOperationComplexitySpan(activity); + return new AnalyzeOperationComplexitySpan(activity, context, enricher); } public void SetCost(double fieldCost, double typeCost) @@ -55,6 +61,8 @@ public void SetCost(double fieldCost, double typeCost) Activity.SetTag(GraphQL.Operation.TypeCost, typeCost); _costSet = true; + + enricher.EnrichOperationCost(Activity, context, fieldCost, typeCost); } protected override void OnComplete() @@ -63,5 +71,7 @@ protected override void OnComplete() { Activity.MarkAsSuccess(); } + + enricher.EnrichAnalyzeOperationCost(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index c7db9607428..a3902abade2 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -5,9 +5,15 @@ namespace HotChocolate.Diagnostics; -internal sealed class ExecuteOperationSpan(Activity activity, RequestContext context) : SpanBase(activity) +internal sealed class ExecuteOperationSpan( + Activity activity, + RequestContext context, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static ParsingSpan? Start(ActivitySource source, RequestContext context) + public static ExecuteOperationSpan? Start( + ActivitySource source, + RequestContext context, + ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Operation Execution"); @@ -46,7 +52,7 @@ internal sealed class ExecuteOperationSpan(Activity activity, RequestContext con activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new ParsingSpan(activity, context); + return new ExecuteOperationSpan(activity, context, enricher); } protected override void OnComplete() @@ -59,5 +65,7 @@ protected override void OnComplete() { Activity.MarkAsSuccess(); } + + enricher.EnrichExecuteOperation(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs index 835c344619e..f73b7cb86f5 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -10,6 +10,7 @@ namespace HotChocolate.Diagnostics; internal sealed class ExecuteRequestSpan( Activity activity, RequestContext context, + ActivityEnricherBase? enricher, bool shouldDisposeActivity) : IDisposable { private bool _disposed; @@ -19,6 +20,7 @@ internal sealed class ExecuteRequestSpan( public static ExecuteRequestSpan? Start( ActivitySource source, RequestContext context, + ActivityEnricherBase enricher, InstrumentationOptionsBase options) { var activity = source.StartActivity("GraphQL Operation", ActivityKind.Server); @@ -37,7 +39,7 @@ internal sealed class ExecuteRequestSpan( activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); } - return new ExecuteRequestSpan(activity, context, true); + return new ExecuteRequestSpan(activity, context, enricher, true); } public void Dispose() @@ -65,5 +67,7 @@ private void OnComplete() { Activity.MarkAsSuccess(); } + + enricher?.EnrichExecuteRequest(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index 27941526ffc..6df4f388cb7 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Text.Json; using Microsoft.AspNetCore.Http; using HotChocolate.AspNetCore.Instrumentation; using HotChocolate.Execution; @@ -13,12 +12,16 @@ namespace HotChocolate.Diagnostics; internal sealed class ExecuteHttpRequestSpan( Activity activity, + HttpContext httpContext, + HttpRequestKind kind, + ActivityEnricherBase enricher, InstrumentationOptionsBase options) : SpanBase(activity) { public static ExecuteHttpRequestSpan? Start( ActivitySource source, HttpContext httpContext, HttpRequestKind kind, + ActivityEnricherBase enricher, InstrumentationOptionsBase options) { var activity = source.StartActivity(); @@ -55,7 +58,7 @@ internal sealed class ExecuteHttpRequestSpan( activity.SetTag(GraphQL.Schema.Name, schemaName); activity.MarkAsSuccess(); - return new ExecuteHttpRequestSpan(activity, options); + return new ExecuteHttpRequestSpan(activity, httpContext, kind, enricher, options); } public void SetSingleRequestDetails(GraphQLRequest request) @@ -104,6 +107,8 @@ public void SetSingleRequestDetails(GraphQLRequest request) // Ignore any errors } } + + enricher.EnrichStartSingleRequest(Activity, httpContext, request); } public void SetBatchRequestDetails(IReadOnlyList batch) @@ -161,6 +166,8 @@ public void SetBatchRequestDetails(IReadOnlyList batch) } } } + + enricher.EnrichStartBatchRequest(Activity, httpContext, batch); } public void SetOperationBatchRequestDetails( @@ -211,17 +218,28 @@ public void SetOperationBatchRequestDetails( // Ignore any errors } } + + enricher.EnrichStartOperationBatchRequest(Activity, httpContext, request, operations); + } + + protected override void OnComplete() + { + enricher.EnrichExecuteHttpRequest(Activity, httpContext, kind); } public void RecordError(IError error) { Activity.RecordError(error); Activity.MarkAsError(); + enricher.EnrichHttpRequestError(Activity, httpContext, error); + enricher.EnrichError(Activity, error); } public void RecordError(Exception exception) { Activity.RecordException(exception); Activity.MarkAsError(); + enricher.EnrichHttpRequestError(Activity, httpContext, exception); + enricher.EnrichException(Activity, exception); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs index 6e5ac323e30..5c9ada5ba2a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs @@ -1,11 +1,18 @@ using System.Diagnostics; +using Microsoft.AspNetCore.Http; using OpenTelemetry.Trace; namespace HotChocolate.Diagnostics; -internal sealed class FormatHttpResponseSpan(Activity activity) : SpanBase(activity) +internal sealed class FormatHttpResponseSpan( + Activity activity, + HttpContext httpContext, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static FormatHttpResponseSpan? Start(ActivitySource source) + public static FormatHttpResponseSpan? Start( + ActivitySource source, + HttpContext httpContext, + ActivityEnricherBase enricher) { var activity = source.StartActivity("Format HTTP Response"); @@ -16,6 +23,11 @@ internal sealed class FormatHttpResponseSpan(Activity activity) : SpanBase(activ activity.MarkAsSuccess(); - return new FormatHttpResponseSpan(activity); + return new FormatHttpResponseSpan(activity, httpContext, enricher); + } + + protected override void OnComplete() + { + enricher.EnrichFormatHttpResponse(Activity, httpContext); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs index 00338bba9d2..c30761f1aa5 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs @@ -1,11 +1,18 @@ using System.Diagnostics; +using Microsoft.AspNetCore.Http; using OpenTelemetry.Trace; namespace HotChocolate.Diagnostics; -internal sealed class ParseHttpRequestSpan(Activity activity) : SpanBase(activity) +internal sealed class ParseHttpRequestSpan( + Activity activity, + HttpContext httpContext, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static ParseHttpRequestSpan? Start(ActivitySource source) + public static ParseHttpRequestSpan? Start( + ActivitySource source, + HttpContext httpContext, + ActivityEnricherBase enricher) { var activity = source.StartActivity("Parse HTTP Request"); @@ -16,7 +23,7 @@ internal sealed class ParseHttpRequestSpan(Activity activity) : SpanBase(activit activity.MarkAsSuccess(); - return new ParseHttpRequestSpan(activity); + return new ParseHttpRequestSpan(activity, httpContext, enricher); } public void RecordErrors(IReadOnlyList errors) @@ -24,8 +31,15 @@ public void RecordErrors(IReadOnlyList errors) foreach (var error in errors) { Activity.RecordError(error); + enricher.EnrichError(Activity, error); } Activity.MarkAsError(); + enricher.EnrichParserErrors(Activity, httpContext, errors); + } + + protected override void OnComplete() + { + enricher.EnrichParseHttpRequest(Activity, httpContext); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index a1bec79ef1f..55aa08f7bef 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -5,9 +5,15 @@ namespace HotChocolate.Diagnostics; -internal sealed class ParsingSpan(Activity activity, RequestContext context) : SpanBase(activity) +internal sealed class ParsingSpan( + Activity activity, + RequestContext context, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static ParsingSpan? Start(ActivitySource source, RequestContext context) + public static ParsingSpan? Start( + ActivitySource source, + RequestContext context, + ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Document Parsing"); @@ -39,7 +45,7 @@ internal sealed class ParsingSpan(Activity activity, RequestContext context) : S activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new ParsingSpan(activity, context); + return new ParsingSpan(activity, context, enricher); } protected override void OnComplete() @@ -53,5 +59,7 @@ protected override void OnComplete() Activity.MarkAsSuccess(); } + + enricher.EnrichParseDocument(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index 0d279483515..0223faf1c6f 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -5,9 +5,15 @@ namespace HotChocolate.Diagnostics; -internal sealed class ValidationSpan(Activity activity, RequestContext context) : SpanBase(activity) +internal sealed class ValidationSpan( + Activity activity, + RequestContext context, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static ParsingSpan? Start(ActivitySource source, RequestContext context) + public static ValidationSpan? Start( + ActivitySource source, + RequestContext context, + ActivityEnricherBase enricher) { var activity = source.StartActivity( "GraphQL Document Validation"); @@ -45,7 +51,7 @@ internal sealed class ValidationSpan(Activity activity, RequestContext context) activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new ParsingSpan(activity, context); + return new ValidationSpan(activity, context, enricher); } protected override void OnComplete() @@ -54,5 +60,7 @@ protected override void OnComplete() { Activity.MarkAsSuccess(); } + + enricher.EnrichValidateDocument(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index 62ba0039020..3e252851159 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -5,9 +5,15 @@ namespace HotChocolate.Diagnostics; -internal sealed class VariableCoercionSpan(Activity activity, RequestContext context) : SpanBase(activity) +internal sealed class VariableCoercionSpan( + Activity activity, + RequestContext context, + ActivityEnricherBase enricher) : SpanBase(activity) { - public static ParsingSpan? Start(ActivitySource source, RequestContext context) + public static VariableCoercionSpan? Start( + ActivitySource source, + RequestContext context, + ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Variable Coercion"); @@ -46,7 +52,7 @@ internal sealed class VariableCoercionSpan(Activity activity, RequestContext con activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new ParsingSpan(activity, context); + return new VariableCoercionSpan(activity, context, enricher); } protected override void OnComplete() @@ -55,5 +61,7 @@ protected override void OnComplete() { Activity.MarkAsSuccess(); } + + enricher.EnrichCoerceVariables(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 9126c518808..526649d96a6 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -1,10 +1,47 @@ +using System.Diagnostics; +using GreenDonut; +using HotChocolate.Execution; +using HotChocolate.Resolvers; + namespace HotChocolate.Diagnostics; /// -/// The activity enricher is used to add information to the activity spans. -/// You can inherit from this class and override the enricher methods to provide more or -/// less information. +/// The activity enricher allows adding additional information to the activity spans +/// created by the Hot Chocolate diagnostics system. +/// You can inherit from this class and override the enricher methods to add +/// additional information to the spans. /// -public class ActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase(options) +public class ActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase { + protected InstrumentationOptions Options { get; } = options; + + public virtual void EnrichCompileOperation( + Activity activity, + RequestContext context) { } + + public virtual void EnrichResolveFieldValue( + Activity activity, + IMiddlewareContext context) { } + + public virtual void EnrichResolverError( + Activity activity, + IMiddlewareContext context, + IError error) { } + + public virtual void EnrichExecuteBatch( + Activity activity, + IDataLoader dataLoader, + IReadOnlyList keys) where TKey : notnull { } + + public virtual void EnrichRunBatchDispatchCoordinator( + Activity activity) { } + + public virtual void EnrichBatchDispatchError( + Activity activity, + Exception exception) { } + + public virtual void EnrichOnSubscriptionEvent( + Activity activity, + RequestContext context, + ulong subscriptionId) { } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index e14337e3131..ad092899a84 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -20,7 +20,7 @@ public override IDisposable ExecuteBatch( return EmptyScope; } - var span = DataLoaderBatchSpan.Start(Source, dataLoader, keys); + var span = DataLoaderBatchSpan.Start(Source, dataLoader, keys, _enricher); if (span is null) { @@ -38,7 +38,7 @@ public override IDisposable ExecuteBatch( public override IDisposable RunBatchDispatchCoordinator() { - var span = DataLoaderDispatchSpan.Start(Source); + var span = DataLoaderDispatchSpan.Start(Source, _enricher); return span ?? EmptyScope; } @@ -50,6 +50,12 @@ public override void BatchDispatchError(Exception error) #else Activity.Current?.SetStatus(ActivityStatusCode.Error, error.Message); #endif + + if (Activity.Current is { } activity) + { + _enricher.EnrichBatchDispatchError(activity, error); + _enricher.EnrichException(activity, error); + } } public override void BatchEvaluated(int openBatches) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index dc10a7f67c2..eb2beedf8bf 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -35,8 +35,8 @@ public override IDisposable ExecuteRequest(RequestContext context) } var span = httpContextActivity is not null - ? new ExecuteRequestSpan(httpContextActivity, context, false) - : ExecuteRequestSpan.Start(Source, context, options); + ? new ExecuteRequestSpan(httpContextActivity, context, null, false) + : ExecuteRequestSpan.Start(Source, context, _enricher, options); if (span is null) { @@ -56,6 +56,9 @@ public override void RequestError(RequestContext context, Exception error) activity.RecordException(error); activity.MarkAsError(); + + _enricher.EnrichRequestError(activity, context, error); + _enricher.EnrichException(activity, error); } } @@ -67,6 +70,9 @@ public override void RequestError(RequestContext context, IError error) activity.RecordError(error); activity.MarkAsError(); + + _enricher.EnrichRequestError(activity, context, error); + _enricher.EnrichError(activity, error); } } @@ -77,7 +83,7 @@ public override IDisposable ParseDocument(RequestContext context) return EmptyScope; } - var span = ParsingSpan.Start(Source, context); + var span = ParsingSpan.Start(Source, context, _enricher); return span ?? EmptyScope; } @@ -91,7 +97,7 @@ public override IDisposable ValidateDocument(RequestContext context) return EmptyScope; } - var span = ValidationSpan.Start(Source, context); + var span = ValidationSpan.Start(Source, context, _enricher); if (span is null) { @@ -115,9 +121,12 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList(Activity activity) : SpanBase(activity) +internal sealed class DataLoaderBatchSpan( + Activity activity, + IDataLoader dataLoader, + IReadOnlyList keys, + ActivityEnricher enricher) : SpanBase(activity) where TKey : notnull { public static DataLoaderBatchSpan? Start( ActivitySource source, IDataLoader dataLoader, - IReadOnlyList keys) + IReadOnlyList keys, + ActivityEnricher enricher) { var dataLoaderName = dataLoader.GetType().Name; @@ -25,6 +30,11 @@ internal sealed class DataLoaderBatchSpan(Activity activity) : SpanBase(ac activity.SetTag(GraphQL.DataLoader.Name, dataLoaderName); activity.SetTag(GraphQL.DataLoader.Batch.Size, keys.Count); - return new DataLoaderBatchSpan(activity); + return new DataLoaderBatchSpan(activity, dataLoader, keys, enricher); + } + + protected override void OnComplete() + { + enricher.EnrichExecuteBatch(Activity, dataLoader, keys); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs index 060f0c8d726..99f7f3402f8 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs @@ -5,9 +5,13 @@ namespace HotChocolate.Diagnostics; -internal sealed class DataLoaderDispatchSpan(Activity activity) : SpanBase(activity) +internal sealed class DataLoaderDispatchSpan( + Activity activity, + ActivityEnricher enricher) : SpanBase(activity) { - public static DataLoaderDispatchSpan? Start(ActivitySource source) + public static DataLoaderDispatchSpan? Start( + ActivitySource source, + ActivityEnricher enricher) { var activity = source.StartActivity("GraphQL DataLoader Dispatch"); @@ -18,6 +22,11 @@ internal sealed class DataLoaderDispatchSpan(Activity activity) : SpanBase(activ activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.DataLoaderDispatch); - return new DataLoaderDispatchSpan(activity); + return new DataLoaderDispatchSpan(activity, enricher); + } + + protected override void OnComplete() + { + enricher.EnrichRunBatchDispatchCoordinator(Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs index 83ea7913bfb..9f909c78572 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs @@ -6,9 +6,15 @@ namespace HotChocolate.Diagnostics; -internal sealed class ResolveFieldSpan(Activity activity) : SpanBase(activity) +internal sealed class ResolveFieldSpan( + Activity activity, + IMiddlewareContext context, + ActivityEnricher enricher) : SpanBase(activity) { - public static ResolveFieldSpan? Start(ActivitySource source, IMiddlewareContext context) + public static ResolveFieldSpan? Start( + ActivitySource source, + IMiddlewareContext context, + ActivityEnricher enricher) { var selection = context.Selection; var coordinate = selection.Field.Coordinate; @@ -31,11 +37,13 @@ internal sealed class ResolveFieldSpan(Activity activity) : SpanBase(activity) // TODO: Re-add this // context.SetLocalState(ResolverActivity, activity); - return new ResolveFieldSpan(activity); + return new ResolveFieldSpan(activity, context, enricher); } protected override void OnComplete() { Activity.MarkAsSuccess(); + + enricher.EnrichResolveFieldValue(Activity, context); } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs index fd73ca8ec5d..e018ab80348 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -1,12 +1,56 @@ +using System.Diagnostics; using HotChocolate.Diagnostics; +using HotChocolate.Execution; +using HotChocolate.Fusion.Execution; +using HotChocolate.Fusion.Execution.Nodes; namespace HotChocolate.Fusion.Diagnostics; /// -/// The activity enricher is used to add information to the activity spans. -/// You can inherit from this class and override the enricher methods to provide more or -/// less information. +/// The activity enricher allows adding additional information to the activity spans +/// created by the Fusion diagnostics system. +/// You can inherit from this class and override the enricher methods to add +/// additional information to the spans. /// -public class FusionActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase(options) +public class FusionActivityEnricher(InstrumentationOptions options) : ActivityEnricherBase { + protected InstrumentationOptions Options { get; } = options; + + public virtual void EnrichPlanOperation( + Activity activity, + RequestContext context, + string operationPlanId) { } + + public virtual void EnrichExecutePlanNode( + Activity activity, + OperationPlanContext context, + ExecutionNode node, + string? schemaName) { } + + public virtual void EnrichExecutionNodeError( + Activity activity, + OperationPlanContext context, + ExecutionNode node, + Exception exception) { } + + public virtual void EnrichSourceSchemaTransportError( + Activity activity, + OperationPlanContext context, + ExecutionNode node, + string schemaName, + Exception exception) { } + + public virtual void EnrichSourceSchemaStoreError( + Activity activity, + OperationPlanContext context, + ExecutionNode node, + string schemaName, + Exception exception) { } + + public virtual void EnrichOnSubscriptionEvent( + Activity activity, + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId) { } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 1ff0a33cc68..ea37cf7a59f 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -23,11 +23,9 @@ public override IDisposable ExecuteRequest(RequestContext context) { if (!options.SkipExecuteHttpRequest && context.Features.TryGet(out var httpContext) - // TODO: Fix this - && httpContext.Items.TryGetValue("TODO context key", out var untypedActivity) - && untypedActivity is Activity activity) + && httpContext.Features.Get() is { } httpRequestSpan) { - httpContextActivity = activity; + httpContextActivity = httpRequestSpan.Activity; } else { @@ -36,8 +34,8 @@ public override IDisposable ExecuteRequest(RequestContext context) } var span = httpContextActivity is not null - ? new ExecuteRequestSpan(httpContextActivity, context, false) - : ExecuteRequestSpan.Start(Source, context, options); + ? new ExecuteRequestSpan(httpContextActivity, context, null, false) + : ExecuteRequestSpan.Start(Source, context, _enricher, options); if (span is null) { @@ -57,6 +55,9 @@ public override void RequestError(RequestContext context, Exception error) activity.RecordException(error); activity.MarkAsError(); + + _enricher.EnrichRequestError(activity, context, error); + _enricher.EnrichException(activity, error); } } @@ -68,6 +69,9 @@ public override void RequestError(RequestContext context, IError error) activity.RecordError(error); activity.MarkAsError(); + + _enricher.EnrichRequestError(activity, context, error); + _enricher.EnrichError(activity, error); } } @@ -78,7 +82,7 @@ public override IDisposable ParseDocument(RequestContext context) return EmptyScope; } - var span = ParsingSpan.Start(Source, context); + var span = ParsingSpan.Start(Source, context, _enricher); return span ?? EmptyScope; } @@ -92,7 +96,7 @@ public override IDisposable ValidateDocument(RequestContext context) return EmptyScope; } - var span = ValidationSpan.Start(Source, context); + var span = ValidationSpan.Start(Source, context, _enricher); if (span is null) { @@ -116,9 +120,12 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList KindValues { get; } = new Dictionary @@ -23,7 +29,8 @@ internal sealed class ExecutePlanNodeSpan(Activity activity) : SpanBase(activity ActivitySource source, OperationPlanContext context, ExecutionNode node, - string? schemaName) + string? schemaName, + FusionActivityEnricher enricher) { var activity = source.StartActivity("GraphQL Step Execution"); @@ -47,7 +54,12 @@ internal sealed class ExecutePlanNodeSpan(Activity activity) : SpanBase(activity SetSourceSchemaTags(activity, batchExecutionNode.Operation, schemaName); } - return new ExecutePlanNodeSpan(activity); + return new ExecutePlanNodeSpan(activity, context, node, schemaName, enricher); + } + + protected override void OnComplete() + { + enricher.EnrichExecutePlanNode(Activity, context, node, schemaName); } private static void SetSourceSchemaTags(Activity activity, OperationSourceText operation, string? schemaName) diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs index 9157d4d0f54..a518a6818f1 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -1,12 +1,21 @@ using System.Diagnostics; using HotChocolate.Execution; +using HotChocolate.Fusion.Diagnostics; using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics; -internal sealed class PlanOperationSpan(Activity activity, RequestContext context) : SpanBase(activity) +internal sealed class PlanOperationSpan( + Activity activity, + RequestContext context, + FusionActivityEnricher enricher, + string operationPlanId) : SpanBase(activity) { - public static ParsingSpan? Start(ActivitySource source, RequestContext context) + public static PlanOperationSpan? Start( + ActivitySource source, + RequestContext context, + FusionActivityEnricher enricher, + string operationPlanId) { var activity = source.StartActivity("GraphQL Operation Planning"); @@ -44,7 +53,7 @@ internal sealed class PlanOperationSpan(Activity activity, RequestContext contex activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - return new ParsingSpan(activity, context); + return new PlanOperationSpan(activity, context, enricher, operationPlanId); } protected override void OnComplete() @@ -53,5 +62,7 @@ protected override void OnComplete() { Activity.MarkAsSuccess(); } + + enricher.EnrichPlanOperation(Activity, context, operationPlanId); } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs similarity index 97% rename from src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs rename to src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs index efe60f15948..0fb3bb8c8ef 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/OperationResolverHelper.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs @@ -2,8 +2,7 @@ namespace HotChocolate.Fusion.Planning; -// TODO: Should be internal and match filename -public static class FusionDocumentNodeExtensions +internal static class FusionDocumentNodeExtensions { private const string NoOperationFoundMessage = "There are no operations in the GraphQL document."; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj index 52e0cb9bc72..0fcb3b3147e 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj @@ -6,7 +6,6 @@ - From 48b0955f2f602e2385d770e9a020a190fde9ad16 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 07:20:48 +0100 Subject: [PATCH 13/37] More cleanup --- .../Spans/AnalyzeOperationComplexitySpan.cs | 14 +- .../Spans/ExecuteOperationSpan.cs | 14 +- .../Spans/ExecuteRequestSpan.cs | 23 +- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 16 +- .../src/Diagnostics.Core/Spans/SpanBase.cs | 7 +- .../Diagnostics.Core/Spans/ValidationSpan.cs | 14 +- .../Spans/VariableCoercionSpan.cs | 14 +- .../ActivityExecutionDiagnosticListener.cs | 6 +- .../Diagnostics/Spans/CompileOperationSpan.cs | 16 +- .../src/Diagnostics/Spans/ResolveFieldSpan.cs | 3 - ...tivityDataLoaderDiagnosticListenerTests.cs | 5 +- ...h_Dispatch_Coordinator_Emits_Activity.snap | 2 +- ...ch_Coordinator_Tracks_Dispatch_Events.snap | 2 +- ...onTests.Allow_document_to_be_captured.snap | 49 ++- ...r_error_that_deletes_the_whole_result.snap | 51 ++- ...or_that_deletes_the_whole_result_deep.snap | 38 ++- ...peration_name_is_used_as_request_name.snap | 49 ++- ...lidation_activity_has_an_error_status.snap | 38 ++- ...rack_events_of_a_simple_query_default.snap | 10 +- ...ack_events_of_a_simple_query_detailed.snap | 41 ++- ...umentationTests.Http_Get_SDL_download.snap | 17 +- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 178 +--------- ...s.Http_Post_SingleRequest_GetHeroName.snap | 178 +--------- ...ost_SingleRequest_GetHeroName_Default.snap | 135 +------- ....Http_Post_add_query_to_http_activity.snap | 202 +---------- ...p_Post_add_variables_to_http_activity.snap | 206 +---------- ...s.Http_Post_capture_deferred_response.snap | 207 +---------- ...t_ensure_list_path_is_correctly_built.snap | 322 +----------------- ...mentationTests.Http_Post_parser_error.snap | 61 +--- ...not_automatically_added_to_activities.snap | 202 +---------- ...onTests.Http_Post_with_extensions_map.snap | 206 +---------- ...g_error_when_rename_root_is_activated.snap | 61 +--- ...n_error_when_rename_root_is_activated.snap | 99 +----- .../src/Fusion.Aspire/SchemaComposition.cs | 15 +- .../Spans/PlanOperationSpan.cs | 14 +- .../FusionDocumentNodeExtensions.cs | 17 +- .../HotChocolate.Fusion.Utilities.csproj | 1 + ...onTests.Allow_Document_To_Be_Captured.snap | 67 ++-- ...r_Error_That_Deletes_The_Whole_Result.snap | 65 ++-- ...or_That_Deletes_The_Whole_Result_Deep.snap | 38 ++- ...peration_Name_Is_Used_As_Request_Name.snap | 67 ++-- ...lidation_Activity_Has_An_Error_Status.snap | 38 ++- ...onTests.Source_Schema_Transport_Error.snap | 51 +-- ...ents_Of_A_Query_With_Multiple_Sources.snap | 71 ++-- ...rack_Events_Of_A_Simple_Query_Default.snap | 24 +- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 55 +-- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 55 +-- ...umentationTests.Http_Get_SDL_Download.snap | 17 +- ...entationTests.Http_Get_Single_Request.snap | 187 +--------- ....Http_Post_Add_Query_To_Http_Activity.snap | 211 +----------- ...p_Post_Add_Variables_To_Http_Activity.snap | 215 +----------- ...mentationTests.Http_Post_Parser_Error.snap | 61 +--- ...ntationTests.Http_Post_Single_Request.snap | 178 +--------- ...ests.Http_Post_Single_Request_Default.snap | 151 +------- ...Not_Automatically_Added_To_Activities.snap | 211 +----------- ...onTests.Http_Post_With_Extensions_Map.snap | 215 +----------- ...g_Error_When_Rename_Root_Is_Activated.snap | 61 +--- ...n_Error_When_Rename_Root_Is_Activated.snap | 99 +----- 58 files changed, 562 insertions(+), 4108 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index f0ecd04c0ec..90aed4f085d 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -28,14 +28,13 @@ internal sealed class AnalyzeOperationComplexitySpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -46,7 +45,6 @@ internal sealed class AnalyzeOperationComplexitySpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index a3902abade2..e398d94cd60 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -28,14 +28,13 @@ internal sealed class ExecuteOperationSpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -46,7 +45,6 @@ internal sealed class ExecuteOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs index f73b7cb86f5..a5bcaeba176 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -11,12 +11,8 @@ internal sealed class ExecuteRequestSpan( Activity activity, RequestContext context, ActivityEnricherBase? enricher, - bool shouldDisposeActivity) : IDisposable + bool shouldDisposeActivity) : SpanBase(activity, shouldDisposeActivity) { - private bool _disposed; - - public Activity Activity { get; } = activity; - public static ExecuteRequestSpan? Start( ActivitySource source, RequestContext context, @@ -42,22 +38,7 @@ internal sealed class ExecuteRequestSpan( return new ExecuteRequestSpan(activity, context, enricher, true); } - public void Dispose() - { - if (!_disposed) - { - _disposed = true; - - OnComplete(); - - if (shouldDisposeActivity) - { - Activity.Dispose(); - } - } - } - - private void OnComplete() + protected override void OnComplete() { if (context.Result is null or OperationResult { Errors: [_, ..] }) { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index 55aa08f7bef..7a4f954a3bf 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -24,13 +24,6 @@ internal sealed class ParsingSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - var documentInfo = context.OperationDocumentInfo; var hash = documentInfo.Hash; @@ -39,7 +32,6 @@ internal sealed class ParsingSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); @@ -54,7 +46,13 @@ protected override void OnComplete() { if (document.GetOperation(context.Request.OperationName) is { } operation) { - Activity.SetTag(GraphQL.Operation.Type, operation.Operation); + Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } } Activity.MarkAsSuccess(); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs index d6f891dcfa4..a5fd63b5965 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SpanBase.cs @@ -2,7 +2,7 @@ namespace HotChocolate.Diagnostics; -internal abstract class SpanBase(Activity activity) : IDisposable +internal abstract class SpanBase(Activity activity, bool shouldDisposeActivity = true) : IDisposable { private bool _disposed; @@ -18,7 +18,10 @@ public void Dispose() OnComplete(); - Activity.Dispose(); + if (shouldDisposeActivity) + { + Activity.Dispose(); + } } } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index 0223faf1c6f..c5e80aa2907 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -27,14 +27,13 @@ internal sealed class ValidationSpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -45,7 +44,6 @@ internal sealed class ValidationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index 3e252851159..73a9c64d6e2 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -28,14 +28,13 @@ internal sealed class VariableCoercionSpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -46,7 +45,6 @@ internal sealed class VariableCoercionSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index eb2beedf8bf..b98eaae993f 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -12,6 +12,7 @@ internal sealed class ActivityExecutionDiagnosticListener( ActivityEnricher enricher, InstrumentationOptions options) : ExecutionDiagnosticEventListener { + private const string ResolveFieldSpanKey = "HotChocolate.Diagnostics.ResolveFieldSpan"; private readonly ActivityEnricher _enricher = enricher; public override bool EnableResolveFieldValue => true; @@ -208,14 +209,15 @@ public override IDisposable ResolveFieldValue(IMiddlewareContext context) return EmptyScope; } - context.Features.Set(span); + context.LocalContextData = context.LocalContextData.SetItem(ResolveFieldSpanKey, span); return span; } public override void ResolverError(IMiddlewareContext context, IError error) { - if (context.Features.TryGet(out var span)) + if (context.LocalContextData.TryGetValue(ResolveFieldSpanKey, out var value) + && value is ResolveFieldSpan span) { span.Activity.RecordError(error); span.Activity.MarkAsError(); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs index 075df938861..1b610a035d1 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs @@ -26,14 +26,13 @@ internal sealed class CompileOperationSpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } - - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -44,7 +43,6 @@ internal sealed class CompileOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs index 9f909c78572..db8d62fca84 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs @@ -34,9 +34,6 @@ internal sealed class ResolveFieldSpan( activity.SetTag(GraphQL.Selection.Field.Coordinate, activity.DisplayName); activity.SetTag(GraphQL.Selection.Field.ParentType, coordinate.Name); - // TODO: Re-add this - // context.SetLocalState(ResolverActivity, activity); - return new ResolveFieldSpan(activity, context, enricher); } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs index 6b0b0e62b89..c8c6558cd1f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityDataLoaderDiagnosticListenerTests.cs @@ -1,5 +1,3 @@ -using System.Text; -using Microsoft.Extensions.ObjectPool; using static HotChocolate.Diagnostics.ActivityTestHelper; namespace HotChocolate.Diagnostics; @@ -45,8 +43,7 @@ private static Listeners.ActivityDataLoaderDiagnosticListener CreateListener(Act { Scopes = scopes }; - var pool = new DefaultObjectPoolProvider().Create(new StringBuilderPooledObjectPolicy()); - var enricher = new ActivityEnricher(pool, options); + var enricher = new ActivityEnricher(options); return new Listeners.ActivityDataLoaderDiagnosticListener(enricher, options); } } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap index 417bc6c07ca..a7a2daf1c50 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap @@ -1,7 +1,7 @@ { "activities": [ { - "OperationName": "BatchCoordinator", + "OperationName": "GraphQL DataLoader Dispatch", "DisplayName": "GraphQL DataLoader Dispatch", "Status": "Unset", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap index aac7842e7f6..b0c339d25a6 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap @@ -1,7 +1,7 @@ { "activities": [ { - "OperationName": "BatchCoordinator", + "OperationName": "GraphQL DataLoader Dispatch", "DisplayName": "GraphQL DataLoader Dispatch", "Status": "Unset", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 1f433ab3552..593636939a3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -1,23 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "execute" }, { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n sayHello\n}" + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -26,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -37,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -45,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -57,7 +78,7 @@ "event": [] }, { - "OperationName": "CompileOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -85,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -113,7 +134,7 @@ "event": [], "activities": [ { - "OperationName": "ResolveFieldValue", + "OperationName": "SimpleQuery.sayHello", "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index b13a9ba2a99..cdc1079d796 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -1,27 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n causeFatalError\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", "Value": "ERROR" } ], - "event": [], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -49,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -61,7 +78,7 @@ "event": [] }, { - "OperationName": "CompileOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -89,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ @@ -117,9 +134,9 @@ "event": [], "activities": [ { - "OperationName": "ResolveFieldValue", + "OperationName": "SimpleQuery.causeFatalError", "DisplayName": "SimpleQuery.causeFatalError", - "Status": "Error", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -147,7 +164,7 @@ }, { "Key": "otel.status_code", - "Value": "ERROR" + "Value": "OK" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index b62d7b855e7..f410cb236b9 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -1,17 +1,13 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", @@ -21,7 +17,7 @@ "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +26,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,21 +41,29 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index e84b80f0967..593636939a3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -33,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -53,7 +78,7 @@ "event": [] }, { - "OperationName": "CompileOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -81,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -109,7 +134,7 @@ "event": [], "activities": [ { - "OperationName": "ResolveFieldValue", + "OperationName": "SimpleQuery.sayHello", "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index bf77ede87d1..46555942a55 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -1,17 +1,13 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n sayHello_\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", @@ -21,7 +17,7 @@ "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +26,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,21 +41,29 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 6cea4c9d956..3c577a99283 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -1,7 +1,7 @@ { "activities": [ { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -9,6 +9,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -21,7 +25,7 @@ "event": [] }, { - "OperationName": "CompileOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -45,7 +49,7 @@ "event": [] }, { - "OperationName": "ResolveFieldValue", + "OperationName": "SimpleQuery.sayHello", "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index df78879f806..1c0b1d26be1 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,8 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.operation.type", + "Value": "query" }, { "Key": "otel.status_code", @@ -33,7 +46,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +54,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -53,7 +70,7 @@ "event": [] }, { - "OperationName": "CompileOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -77,7 +94,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -101,7 +118,7 @@ "event": [], "activities": [ { - "OperationName": "ResolveFieldValue", + "OperationName": "SimpleQuery.sayHello", "DisplayName": "SimpleQuery.sayHello", "Status": "Ok", "tags": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap index 1669a6a2090..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap @@ -1,16 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP GET SDL", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index ffd191fca0b..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -1,177 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP GET", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index baf4330a517..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -1,177 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index 671c8838b14..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -1,134 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL Operation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 99dc4cafd2e..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -1,201 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index 9da449e2fd2..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -1,205 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.variables", - "Value": "{\"episode\":\"NEW_HOPE\"}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 3922695aff4..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -1,206 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Droid.id", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "id" - }, - { - "Key": "graphql.selection.path", - "Value": "hero.id" - }, - { - "Key": "graphql.selection.field.name", - "Value": "id" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Droid.id" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Droid" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 4897ecb4922..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -1,321 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:668e9631148921208d08dbb69513fa8e" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Droid.friends", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.path", - "Value": "hero.friends" - }, - { - "Key": "graphql.selection.field.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Droid.friends" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Droid" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Human.friends", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.path", - "Value": "hero.friends.nodes[0].friends" - }, - { - "Key": "graphql.selection.field.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Human.friends" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Human.friends", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.path", - "Value": "hero.friends.nodes[1].friends" - }, - { - "Key": "graphql.selection.field.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Human.friends" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Human.friends", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.path", - "Value": "hero.friends.nodes[2].friends" - }, - { - "Key": "graphql.selection.field.name", - "Value": "friends" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Human.friends" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index 2a9fd28a838..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -1,60 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Found a NameStart character `n` (110) following a number, which is disallowed." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 10, - "column": 37 - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 99dc4cafd2e..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -1,201 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 108db891d7b..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -1,205 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.extensions", - "Value": "{\"test\":\"abc\"}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "AnalyzeOperationCost", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "CompileOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ResolveFieldValue", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index 5b2e774ad0d..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -1,60 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 3, - "column": 21 - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 0f04b5ae931..0967ef424bc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -1,98 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 3, - "column": 21 - } - ] - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Aspire/SchemaComposition.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Aspire/SchemaComposition.cs index e490475a394..8fc4e228186 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Aspire/SchemaComposition.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Aspire/SchemaComposition.cs @@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using IOPath = System.IO.Path; namespace HotChocolate.Fusion.Aspire; @@ -94,7 +95,7 @@ private async Task ComposeSchemaAsync( try { var gatewayDirectory = GetProjectPath(compositionResource)!; - var archivePath = Path.Combine(Path.GetDirectoryName(gatewayDirectory)!, settings.OutputFileName); + var archivePath = IOPath.Combine(IOPath.GetDirectoryName(gatewayDirectory)!, settings.OutputFileName); return await ComposeSchemaAsync(archivePath, sourceSchemas, settings, cancellationToken); } finally @@ -277,7 +278,7 @@ private List GetReferencedResources( // For file schemas, settings file is named after the schema file // e.g., "foo.graphql" -> "foo-settings.json" var schemaFileName = annotation.SchemaPath ?? "schema.graphql"; - var settingsFileName = $"{Path.GetFileNameWithoutExtension(schemaFileName)}-settings.json"; + var settingsFileName = $"{IOPath.GetFileNameWithoutExtension(schemaFileName)}-settings.json"; var schemaSettings = await GetSourceSchemaSettingsAsync(resource, settingsFileName, cancellationToken); if (schemaSettings == null) @@ -309,8 +310,8 @@ private List GetReferencedResources( return null; } - var projectDirectory = Path.GetDirectoryName(projectPath); - var settingsFile = Path.Combine(projectDirectory!, settingsFileName); + var projectDirectory = IOPath.GetDirectoryName(projectPath); + var settingsFile = IOPath.Combine(projectDirectory!, settingsFileName); if (!File.Exists(settingsFile)) { @@ -373,8 +374,8 @@ private List GetReferencedResources( return null; } - var projectDirectory = Path.GetDirectoryName(projectPath); - var schemaFile = Path.Combine(projectDirectory!, fileName ?? "schema.graphql"); + var projectDirectory = IOPath.GetDirectoryName(projectPath); + var schemaFile = IOPath.Combine(projectDirectory!, fileName ?? "schema.graphql"); if (!File.Exists(schemaFile)) { @@ -487,7 +488,7 @@ private async Task ComposeSchemaAsync( GraphQLSchemaCompositionAnnotation settings, CancellationToken cancellationToken) { - var tempArchivePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + var tempArchivePath = IOPath.Combine(IOPath.GetTempPath(), IOPath.GetRandomFileName()); try { diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs index a518a6818f1..d388afaf1d3 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -29,14 +29,13 @@ internal sealed class PlanOperationSpan( if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { - activity.SetTag(GraphQL.Operation.Type, operation.Operation); - } + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - var operationName = context.Request.OperationName; - // TODO: This should be conditional - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } } var documentInfo = context.OperationDocumentInfo; @@ -47,7 +46,6 @@ internal sealed class PlanOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - // TODO: We need a good mechanism to determine if persisted operations are enabled if (documentInfo.IsPersisted && documentInfo.Id.HasValue) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs index 0fb3bb8c8ef..772487fbe6f 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/Extensions/FusionDocumentNodeExtensions.cs @@ -2,17 +2,8 @@ namespace HotChocolate.Fusion.Planning; -internal static class FusionDocumentNodeExtensions +public static class FusionDocumentNodeExtensions { - private const string NoOperationFoundMessage = - "There are no operations in the GraphQL document."; - - private const string MultipleOperationMessage = - "The operation name can only be omitted if there is just one operation in a GraphQL document."; - - private const string InvalidOperationNameMessage = - "The specified operation `{0}` cannot be found."; - public static OperationDefinitionNode GetOperation( this DocumentNode document, string? operationName) @@ -83,7 +74,7 @@ public static Dictionary GetFragments( private static GraphQLException OperationResolverHelper_NoOperationFound( DocumentNode documentNode) => new(ErrorBuilder.New() - .SetMessage(NoOperationFoundMessage) + .SetMessage("There are no operations in the GraphQL document.") .AddLocation(documentNode) .Build()); @@ -91,7 +82,7 @@ private static GraphQLException OperationResolverHelper_MultipleOperation( OperationDefinitionNode firstOperation, OperationDefinitionNode secondOperation) => new(ErrorBuilder.New() - .SetMessage(MultipleOperationMessage) + .SetMessage("The operation name can only be omitted if there is just one operation in a GraphQL document.") .AddLocation(firstOperation) .AddLocation(secondOperation) .Build()); @@ -100,7 +91,7 @@ private static GraphQLException OperationResolverHelper_InvalidOperationName( DocumentNode documentNode, string operationName) => new(ErrorBuilder.New() - .SetMessage(InvalidOperationNameMessage, operationName) + .SetMessage("The specified operation `{0}` cannot be found.", operationName) .AddLocation(documentNode) .SetExtension("operationName", operationName) .Build()); diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj index 0fcb3b3147e..52e0cb9bc72 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Utilities/HotChocolate.Fusion.Utilities.csproj @@ -6,6 +6,7 @@ + diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index 578794f38b0..f511c98d28d 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -1,23 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "execute" }, { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n sayHello\n}" + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -26,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -37,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -45,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -57,7 +78,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -85,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -113,9 +134,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -133,18 +154,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.source.name", "Value": "a" @@ -160,10 +169,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 21d2d60f6f7..42472285ad5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -1,27 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n causeFatalError\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", "Value": "ERROR" } ], - "event": [], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -49,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -61,7 +78,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -89,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ @@ -117,9 +134,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -137,18 +154,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "5f75eb886568e255310bed3eb3e1f7f1c91f1a22f71ac7c36f00d8df27400d8e" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, { "Key": "graphql.source.name", "Value": "a" @@ -164,10 +169,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:1b35e9142c2e8235f31d2b3ae0de3d2ba54692a7aa6481803c3841fd135f4c4c" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index b62d7b855e7..f410cb236b9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -1,17 +1,13 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", @@ -21,7 +17,7 @@ "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +26,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,21 +41,29 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index e76e057ae62..f511c98d28d 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -33,7 +50,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +58,14 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -53,7 +78,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -81,7 +106,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -109,9 +134,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -129,18 +154,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, { "Key": "graphql.source.name", "Value": "a" @@ -156,10 +169,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index aef6b71e41a..944907ba798 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -1,17 +1,13 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n sayHello_\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", @@ -21,7 +17,7 @@ "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +26,12 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" }, { "Key": "otel.status_code", @@ -41,21 +41,29 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Error", "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 29943780bc9..2e35319429b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -1,27 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.document.body", - "Value": "{\n sayHello\n}" + "Key": "graphql.processing.type", + "Value": "execute" }, { "Key": "otel.status_code", "Value": "ERROR" } ], - "event": [], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -30,8 +35,8 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.operation.type", + "Value": "query" }, { "Key": "otel.status_code", @@ -41,7 +46,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -49,6 +54,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -61,7 +70,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -85,7 +94,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Error", "tags": [ @@ -109,9 +118,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Error", "tags": [ { "Key": "graphql.processing.type", @@ -129,14 +138,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.source.name", "Value": "a" @@ -155,7 +156,7 @@ }, { "Key": "otel.status_code", - "Value": "OK" + "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 712b90f3925..375c98e39b5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,8 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" + "Key": "graphql.operation.type", + "Value": "query" }, { "Key": "otel.status_code", @@ -33,7 +46,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +54,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -53,7 +70,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -77,7 +94,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -101,9 +118,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -121,14 +138,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, { "Key": "graphql.source.name", "Value": "a" @@ -144,18 +153,14 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:b6db85f78e867baa06bf8b4f45ed381a2b6bc9f7abd15948f0bfff0967fbc308" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] }, { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -173,14 +178,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, { "Key": "graphql.source.name", "Value": "b" @@ -196,10 +193,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index d8f906dcc30..7483d20ccd9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -1,7 +1,7 @@ { "activities": [ { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -9,6 +9,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -21,7 +25,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -45,9 +49,9 @@ "event": [] }, { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -65,14 +69,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.source.name", "Value": "a" @@ -88,10 +84,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 1432ac4bafb..6bb97d96f9e 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,8 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.operation.type", + "Value": "query" }, { "Key": "otel.status_code", @@ -33,7 +46,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +54,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -53,7 +70,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -77,7 +94,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -101,9 +118,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -121,14 +138,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.source.name", "Value": "a" @@ -144,10 +153,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 1432ac4bafb..6bb97d96f9e 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -1,19 +1,32 @@ { "activities": [ { - "OperationName": "ExecuteRequest", + "OperationName": "GraphQL Operation", "DisplayName": "GraphQL Operation", - "Status": "Unset", + "Status": "Ok", "tags": [ { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] } ], - "event": [], "activities": [ { - "OperationName": "ParseDocument", + "OperationName": "GraphQL Document Parsing", "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ @@ -22,8 +35,8 @@ "Value": "parse" }, { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + "Key": "graphql.operation.type", + "Value": "query" }, { "Key": "otel.status_code", @@ -33,7 +46,7 @@ "event": [] }, { - "OperationName": "ValidateDocument", + "OperationName": "GraphQL Document Validation", "DisplayName": "GraphQL Document Validation", "Status": "Ok", "tags": [ @@ -41,6 +54,10 @@ "Key": "graphql.processing.type", "Value": "validate" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -53,7 +70,7 @@ "event": [] }, { - "OperationName": "PlanOperation", + "OperationName": "GraphQL Operation Planning", "DisplayName": "GraphQL Operation Planning", "Status": "Ok", "tags": [ @@ -77,7 +94,7 @@ "event": [] }, { - "OperationName": "ExecuteOperation", + "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", "Status": "Ok", "tags": [ @@ -101,9 +118,9 @@ "event": [], "activities": [ { - "OperationName": "ExecuteOperationNode", + "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Ok", + "Status": "Unset", "tags": [ { "Key": "graphql.processing.type", @@ -121,14 +138,6 @@ "Key": "graphql.operation.step.plan.id", "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, { "Key": "graphql.source.name", "Value": "a" @@ -144,10 +153,6 @@ { "Key": "graphql.source.operation.hash", "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap index 1669a6a2090..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap @@ -1,16 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP GET SDL", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index ce229f83daf..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -1,186 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP GET", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 942049224c0..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -1,210 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_c46cf8c9_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 852bdcb51a8..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -1,214 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.variables", - "Value": "{\"name\":\"World\"}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_c46cf8c9_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index c5c238e14c2..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -1,60 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Found a NameStart character `d` (100) following a number, which is disallowed." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 4, - "column": 13 - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 3e36ee1cfa2..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -1,177 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "ExecuteHttpRequest", - "Status": "Unset", - "tags": [], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index 3c9fb7d86e2..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -1,150 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL Operation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 942049224c0..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -1,210 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_c46cf8c9_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index a2d2538ab6c..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -1,214 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.extensions", - "Value": "{\"test\":\"abc\"}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Unset", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "PlanOperation", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "CoerceVariables", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteOperation", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ExecuteOperationNode", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_c46cf8c9_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" - }, - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index 2e69b5918d9..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -1,60 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 1, - "column": 3 - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 20129998150..0967ef424bc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -1,98 +1 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ParseHttpRequest", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], - "event": [] - }, - { - "OperationName": "ExecuteRequest", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], - "event": [], - "activities": [ - { - "OperationName": "ValidateDocument", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - }, - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 1, - "column": 3 - } - ] - } - ] - } - ] - } - ] - }, - { - "OperationName": "FormatHttpResponse", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} +{} From e9f7e746afdeaf5e5ce881d71b17ccb19df3c7df Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 08:29:38 +0100 Subject: [PATCH 14/37] More cleanup --- .../Spans/ExecuteOperationSpan.cs | 17 +++--- .../Spans/ExecuteRequestSpan.cs | 52 +++++++++++++++---- .../Spans/VariableCoercionSpan.cs | 17 +++--- .../ActivityExecutionDiagnosticListener.cs | 30 ++++++++--- ...onTests.Allow_document_to_be_captured.snap | 16 ++++++ ...r_error_that_deletes_the_whole_result.snap | 16 ++++++ ...or_that_deletes_the_whole_result_deep.snap | 16 ++++++ ...peration_name_is_used_as_request_name.snap | 12 +++++ ...lidation_activity_has_an_error_status.snap | 16 ++++++ ...ack_events_of_a_simple_query_detailed.snap | 8 +++ ...ctivityExecutionDiagnosticEventListener.cs | 30 ++++++++--- .../Spans/ExecutePlanNodeSpan.cs | 24 +++++++++ ...onTests.Allow_Document_To_Be_Captured.snap | 28 ++++++++++ ...r_Error_That_Deletes_The_Whole_Result.snap | 28 ++++++++++ ...or_That_Deletes_The_Whole_Result_Deep.snap | 16 ++++++ ...peration_Name_Is_Used_As_Request_Name.snap | 24 +++++++++ ...lidation_Activity_Has_An_Error_Status.snap | 16 ++++++ ...onTests.Source_Schema_Transport_Error.snap | 20 +++++++ ...ents_Of_A_Query_With_Multiple_Sources.snap | 24 +++++++++ ...rack_Events_Of_A_Simple_Query_Default.snap | 8 +++ ...ack_Events_Of_A_Simple_Query_Detailed.snap | 16 ++++++ ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 16 ++++++ 22 files changed, 409 insertions(+), 41 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index e398d94cd60..2d46889424b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using HotChocolate.Execution; +using HotChocolate.Language; using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; @@ -13,6 +14,8 @@ internal sealed class ExecuteOperationSpan( public static ExecuteOperationSpan? Start( ActivitySource source, RequestContext context, + OperationType operationType, + string? operationName, ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Operation Execution"); @@ -24,17 +27,11 @@ internal sealed class ExecuteOperationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - // TODO: This should get it from the operation - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); } var documentInfo = context.OperationDocumentInfo; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs index a5bcaeba176..8cfbf27c0da 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -6,18 +6,18 @@ namespace HotChocolate.Diagnostics; -// TODO: Needs additional tags probably internal sealed class ExecuteRequestSpan( Activity activity, RequestContext context, + InstrumentationOptionsBase options, ActivityEnricherBase? enricher, bool shouldDisposeActivity) : SpanBase(activity, shouldDisposeActivity) { public static ExecuteRequestSpan? Start( ActivitySource source, RequestContext context, - ActivityEnricherBase enricher, - InstrumentationOptionsBase options) + InstrumentationOptionsBase options, + ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Operation", ActivityKind.Server); @@ -28,18 +28,52 @@ internal sealed class ExecuteRequestSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + return new ExecuteRequestSpan( + activity, + context, + options, + enricher, + true); + } + + protected override void OnComplete() + { + // TODO: This could be faster through the operation + if (context.TryGetDocument(out var document, out _)) + { + if (document.GetOperation(context.Request.OperationName) is { } operation) + { + Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + + var operationName = operation.Name?.Value; + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } + } + + Activity.MarkAsSuccess(); + } + var documentInfo = context.OperationDocumentInfo; - if (options.IncludeDocument && documentInfo.Document is not null) + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) { - activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); + Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - return new ExecuteRequestSpan(activity, context, enricher, true); - } + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + if (options.IncludeDocument && documentInfo.Document is not null) + { + Activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); + } - protected override void OnComplete() - { if (context.Result is null or OperationResult { Errors: [_, ..] }) { Activity.MarkAsError(); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index 73a9c64d6e2..d3a1d5644ec 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using HotChocolate.Execution; +using HotChocolate.Language; using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; @@ -13,6 +14,8 @@ internal sealed class VariableCoercionSpan( public static VariableCoercionSpan? Start( ActivitySource source, RequestContext context, + OperationType operationType, + string? operationName, ActivityEnricherBase enricher) { var activity = source.StartActivity("GraphQL Variable Coercion"); @@ -24,17 +27,11 @@ internal sealed class VariableCoercionSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - // TODO: This should get it from the operation - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); } var documentInfo = context.OperationDocumentInfo; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index b98eaae993f..bccf8243b57 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -36,8 +36,8 @@ public override IDisposable ExecuteRequest(RequestContext context) } var span = httpContextActivity is not null - ? new ExecuteRequestSpan(httpContextActivity, context, null, false) - : ExecuteRequestSpan.Start(Source, context, _enricher, options); + ? new ExecuteRequestSpan(httpContextActivity, context, options, _enricher, false) + : ExecuteRequestSpan.Start(Source, context, options, _enricher); if (span is null) { @@ -89,8 +89,6 @@ public override IDisposable ParseDocument(RequestContext context) return span ?? EmptyScope; } - // TODO: A dedicated event for parsing errors would be nice - public override IDisposable ValidateDocument(RequestContext context) { if (options.SkipValidateDocument) @@ -178,7 +176,17 @@ public override IDisposable CoerceVariables(RequestContext context) return EmptyScope; } - var span = VariableCoercionSpan.Start(Source, context, _enricher); + if (!context.TryGetOperation(out var operation)) + { + return EmptyScope; + } + + var span = VariableCoercionSpan.Start( + Source, + context, + operation.Kind, + operation.Name, + _enricher); return span ?? EmptyScope; } @@ -190,7 +198,17 @@ public override IDisposable ExecuteOperation(RequestContext context) return EmptyScope; } - var span = ExecuteOperationSpan.Start(Source, context, _enricher); + if (!context.TryGetOperation(out var operation)) + { + return EmptyScope; + } + + var span = ExecuteOperationSpan.Start( + Source, + context, + operation.Kind, + operation.Name, + _enricher); return span ?? EmptyScope; } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 593636939a3..8d710afbdff 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n sayHello\n}" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index cdc1079d796..91d827ed6ff 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n causeFatalError\n}" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index f410cb236b9..4918e8203f1 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" } ], "event": [], diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index 593636939a3..f111e03e7e6 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -9,9 +9,21 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index 46555942a55..ecd71a2476c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n sayHello_\n}" } ], "event": [], diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index 1c0b1d26be1..77031771016 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -9,9 +9,17 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [ diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index ea37cf7a59f..9de325c21cd 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -34,8 +34,8 @@ public override IDisposable ExecuteRequest(RequestContext context) } var span = httpContextActivity is not null - ? new ExecuteRequestSpan(httpContextActivity, context, null, false) - : ExecuteRequestSpan.Start(Source, context, _enricher, options); + ? new ExecuteRequestSpan(httpContextActivity, context, options, _enricher, false) + : ExecuteRequestSpan.Start(Source, context, options, _enricher); if (span is null) { @@ -87,8 +87,6 @@ public override IDisposable ParseDocument(RequestContext context) return span ?? EmptyScope; } - // TODO: A dedicated event for parsing errors would be nice - public override IDisposable ValidateDocument(RequestContext context) { if (options.SkipValidateDocument) @@ -147,7 +145,17 @@ public override IDisposable CoerceVariables(RequestContext context) return EmptyScope; } - var span = VariableCoercionSpan.Start(Source, context, _enricher); + if (context.GetOperationPlan() is not { } plan) + { + return EmptyScope; + } + + var span = VariableCoercionSpan.Start( + Source, + context, + plan.Operation.Definition.Operation, + plan.OperationName, + _enricher); return span ?? EmptyScope; } @@ -159,7 +167,17 @@ public override IDisposable ExecuteOperation(RequestContext context) return EmptyScope; } - var span = ExecuteOperationSpan.Start(Source, context, _enricher); + if (context.GetOperationPlan() is not { } plan) + { + return EmptyScope; + } + + var span = ExecuteOperationSpan.Start( + Source, + context, + plan.Operation.Definition.Operation, + plan.OperationName, + _enricher); return span ?? EmptyScope; } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs index bfdf9e4fc4b..a09cd16b9da 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs @@ -41,6 +41,30 @@ internal sealed class ExecutePlanNodeSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); + var operation = context.OperationPlan.Operation; + var operationType = operation.Definition.Operation; + var operationName = operation.Name; + + activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); + + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag(GraphQL.Operation.Name, operationName); + } + + var documentInfo = context.RequestContext.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + { + activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); activity.SetTag(GraphQL.Operation.Step.Plan.Id, context.OperationPlan.Id); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index f511c98d28d..c6e1d945cc4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n sayHello\n}" } ], "event": [ @@ -142,6 +158,18 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 42472285ad5..920070c81bb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n causeFatalError\n}" } ], "event": [ @@ -142,6 +158,18 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index f410cb236b9..4918e8203f1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index f511c98d28d..db23913e21a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -9,9 +9,21 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [ @@ -142,6 +154,18 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index 944907ba798..ef7bdc6e015 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -9,9 +9,25 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "SayHelloOperation" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" + }, + { + "Key": "graphql.document.body", + "Value": "query SayHelloOperation {\n sayHello_\n}" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 2e35319429b..20084f4b3b7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -9,9 +9,21 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "otel.status_code", "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.body", + "Value": "{\n sayHello\n}" } ], "event": [ @@ -126,6 +138,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 375c98e39b5..64deccb5f7b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -9,9 +9,17 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" } ], "event": [ @@ -126,6 +134,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + }, { "Key": "graphql.operation.step.id", "Value": "1" @@ -166,6 +182,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + }, { "Key": "graphql.operation.step.id", "Value": "2" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 7483d20ccd9..2962da5589c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -57,6 +57,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 6bb97d96f9e..88860219920 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -9,9 +9,17 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [ @@ -126,6 +134,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "graphql.operation.step.id", "Value": "1" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 6bb97d96f9e..88860219920 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -9,9 +9,17 @@ "Key": "graphql.processing.type", "Value": "execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [ @@ -126,6 +134,14 @@ "Key": "graphql.processing.type", "Value": "step_execute" }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "graphql.operation.step.id", "Value": "1" From a941964bb09acccc3608803cadaf72e923061003 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 08:49:02 +0100 Subject: [PATCH 15/37] More cleanup --- .../Spans/AnalyzeOperationComplexitySpan.cs | 2 +- .../Spans/ExecuteOperationSpan.cs | 2 +- .../Spans/ExecuteRequestSpan.cs | 9 ++++--- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 26 +++++++++---------- .../Diagnostics.Core/Spans/ValidationSpan.cs | 2 +- .../Spans/VariableCoercionSpan.cs | 2 +- .../Diagnostics/Spans/CompileOperationSpan.cs | 4 +-- ...onTests.Allow_document_to_be_captured.snap | 10 +++---- ...r_error_that_deletes_the_whole_result.snap | 10 +++---- ...or_that_deletes_the_whole_result_deep.snap | 10 +++---- ...peration_name_is_used_as_request_name.snap | 10 +++---- ...lidation_activity_has_an_error_status.snap | 10 +++---- ...ack_events_of_a_simple_query_detailed.snap | 10 +++---- .../Spans/ExecutePlanNodeSpan.cs | 2 +- .../Spans/PlanOperationSpan.cs | 2 +- ...onTests.Allow_Document_To_Be_Captured.snap | 10 +++---- ...r_Error_That_Deletes_The_Whole_Result.snap | 10 +++---- ...or_That_Deletes_The_Whole_Result_Deep.snap | 10 +++---- ...peration_Name_Is_Used_As_Request_Name.snap | 10 +++---- ...lidation_Activity_Has_An_Error_Status.snap | 10 +++---- ...onTests.Source_Schema_Transport_Error.snap | 10 +++---- ...ents_Of_A_Query_With_Multiple_Sources.snap | 10 +++---- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 10 +++---- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 10 +++---- 24 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 90aed4f085d..05aea0cab2a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -45,7 +45,7 @@ internal sealed class AnalyzeOperationComplexitySpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index 2d46889424b..032976a1923 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -42,7 +42,7 @@ internal sealed class ExecuteOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs index 8cfbf27c0da..b1abc18b110 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -26,8 +26,6 @@ internal sealed class ExecuteRequestSpan( return null; } - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - return new ExecuteRequestSpan( activity, context, @@ -43,7 +41,10 @@ protected override void OnComplete() { if (document.GetOperation(context.Request.OperationName) is { } operation) { - Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); + var operationType = GraphQL.Operation.TypeValues[operation.Operation]; + + Activity.DisplayName = operationType; + Activity.SetTag(GraphQL.Operation.Type, operationType); var operationName = operation.Name?.Value; if (!string.IsNullOrEmpty(operationName)) @@ -64,7 +65,7 @@ protected override void OnComplete() Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index 7a4f954a3bf..bdeaac3aeea 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -24,19 +24,6 @@ internal sealed class ParsingSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } - return new ParsingSpan(activity, context, enricher); } @@ -58,6 +45,19 @@ protected override void OnComplete() Activity.MarkAsSuccess(); } + var documentInfo = context.OperationDocumentInfo; + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) + { + Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + enricher.EnrichParseDocument(Activity, context); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index c5e80aa2907..fb8ef50052c 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -44,7 +44,7 @@ internal sealed class ValidationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index d3a1d5644ec..7732fe29381 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -42,7 +42,7 @@ internal sealed class VariableCoercionSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs index 1b610a035d1..0065dabdb90 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs @@ -27,7 +27,7 @@ internal sealed class CompileOperationSpan( && document.GetOperation(context.Request.OperationName) is { } operation) { activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - + var operationName = operation.Name?.Value; if (!string.IsNullOrEmpty(operationName)) { @@ -43,7 +43,7 @@ internal sealed class CompileOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 8d710afbdff..3379f6c6f46 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -61,6 +57,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index 91d827ed6ff..bbed2d6a653 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -61,6 +57,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index 4918e8203f1..f0d0efff69c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -52,6 +48,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index f111e03e7e6..1c177f05d25 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -57,6 +53,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index ecd71a2476c..59840a1af8f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -52,6 +48,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index 77031771016..c63e8da7bdc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -49,6 +45,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs index a09cd16b9da..f3eefab87b8 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs @@ -60,7 +60,7 @@ internal sealed class ExecutePlanNodeSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs index d388afaf1d3..39a439947e4 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -46,7 +46,7 @@ internal sealed class PlanOperationSpan( activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); } - if (documentInfo.IsPersisted && documentInfo.Id.HasValue) + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) { activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index c6e1d945cc4..9df28d48587 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -61,6 +57,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 920070c81bb..cf5e9cae53f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -61,6 +57,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index 4918e8203f1..f0d0efff69c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -52,6 +48,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:803df9346db185e9dc0b22dd3909aa70" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index db23913e21a..b5150dcd633 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -57,6 +53,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index ef7bdc6e015..400b2202d71 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -52,6 +48,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 20084f4b3b7..d93a3e67c20 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Error", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -53,6 +49,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 64deccb5f7b..c1a6ef79094 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -49,6 +45,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 88860219920..1ef0320f5d7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -49,6 +45,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 88860219920..1ef0320f5d7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", + "DisplayName": "query", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, { "Key": "graphql.operation.type", "Value": "query" @@ -49,6 +45,10 @@ { "Key": "otel.status_code", "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [] From 4cd6f2d76e37b8efb11062854fc437789b1f9cc5 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 08:01:02 +0000 Subject: [PATCH 16/37] Fix ServerInstrumentationTests --- .../Spans/Http/ExecuteHttpRequestSpan.cs | 2 +- ...umentationTests.Http_Get_SDL_download.snap | 21 +- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 216 ++++++++++- ...s.Http_Post_SingleRequest_GetHeroName.snap | 216 ++++++++++- ...ost_SingleRequest_GetHeroName_Default.snap | 152 +++++++- ....Http_Post_add_query_to_http_activity.snap | 240 +++++++++++- ...p_Post_add_variables_to_http_activity.snap | 244 +++++++++++- ...s.Http_Post_capture_deferred_response.snap | 240 +++++++++++- ...t_ensure_list_path_is_correctly_built.snap | 360 +++++++++++++++++- ...mentationTests.Http_Post_parser_error.snap | 70 +++- ...not_automatically_added_to_activities.snap | 240 +++++++++++- ...onTests.Http_Post_with_extensions_map.snap | 244 +++++++++++- ...g_error_when_rename_root_is_activated.snap | 70 +++- ...n_error_when_rename_root_is_activated.snap | 116 +++++- ...umentationTests.Http_Get_SDL_Download.snap | 21 +- ...entationTests.Http_Get_Single_Request.snap | 204 +++++++++- ....Http_Post_Add_Query_To_Http_Activity.snap | 228 ++++++++++- ...p_Post_Add_Variables_To_Http_Activity.snap | 232 ++++++++++- ...mentationTests.Http_Post_Parser_Error.snap | 70 +++- ...ntationTests.Http_Post_Single_Request.snap | 204 +++++++++- ...ests.Http_Post_Single_Request_Default.snap | 164 +++++++- ...Not_Automatically_Added_To_Activities.snap | 228 ++++++++++- ...onTests.Http_Post_With_Extensions_Map.snap | 232 ++++++++++- ...g_Error_When_Rename_Root_Is_Activated.snap | 70 +++- ...n_Error_When_Rename_Root_Is_Activated.snap | 116 +++++- 25 files changed, 4175 insertions(+), 25 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index 6df4f388cb7..72548f4874b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -24,7 +24,7 @@ internal sealed class ExecuteHttpRequestSpan( ActivityEnricherBase enricher, InstrumentationOptionsBase options) { - var activity = source.StartActivity(); + var activity = source.StartActivity("ExecuteHttpRequest"); if (activity is null) { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap index 0967ef424bc..3bd6ff6b97c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap @@ -1 +1,20 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP GET SDL", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 0967ef424bc..15e2ab71323 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -1 +1,215 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP GET", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 0967ef424bc..40bc68d34d3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -1 +1,215 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index 0967ef424bc..a7c27e9ac96 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -1 +1,151 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 0967ef424bc..3c4d9de201f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -1 +1,239 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index 0967ef424bc..5ccf4143d90 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -1 +1,243 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.variables", + "Value": "{\"episode\":\"NEW_HOPE\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 0967ef424bc..af5256bbf3f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -1 +1,239 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Droid.id", + "DisplayName": "Droid.id", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "id" + }, + { + "Key": "graphql.selection.path", + "Value": "hero.id" + }, + { + "Key": "graphql.selection.field.name", + "Value": "id" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Droid.id" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Droid" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 0967ef424bc..e2086b9120d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -1 +1,359 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Droid.friends", + "DisplayName": "Droid.friends", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.path", + "Value": "hero.friends" + }, + { + "Key": "graphql.selection.field.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Droid.friends" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Droid" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Human.friends", + "DisplayName": "Human.friends", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.path", + "Value": "hero.friends.nodes[0].friends" + }, + { + "Key": "graphql.selection.field.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Human.friends" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Human" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Human.friends", + "DisplayName": "Human.friends", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.path", + "Value": "hero.friends.nodes[1].friends" + }, + { + "Key": "graphql.selection.field.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Human.friends" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Human" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "Human.friends", + "DisplayName": "Human.friends", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.path", + "Value": "hero.friends.nodes[2].friends" + }, + { + "Key": "graphql.selection.field.name", + "Value": "friends" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Human.friends" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Human" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index 0967ef424bc..c4e81092490 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -1 +1,69 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Error", + "tags": [ + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "Found a NameStart character `n` (110) following a number, which is disallowed." + }, + { + "Key": "graphql.error.code", + "Value": "HC0011" + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 10, + "column": 37 + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 0967ef424bc..3c4d9de201f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -1 +1,239 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 0967ef424bc..e8330a520ca 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -1 +1,243 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index 0967ef424bc..8fd22c7389b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -1 +1,69 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Error", + "tags": [ + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "Expected a `Name`-token, but found a `Integer`-token." + }, + { + "Key": "graphql.error.code", + "Value": "HC0011" + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 3, + "column": 21 + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 0967ef424bc..eca9d0536dd 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -1 +1,115 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:346f68539881f0624dca2927281d1a2f" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:346f68539881f0624dca2927281d1a2f" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "The field `abc` does not exist on the type `Query`." + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 3, + "column": 21 + } + ] + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap index 0967ef424bc..3bd6ff6b97c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap @@ -1 +1,20 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP GET SDL", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 0967ef424bc..815479ddc9b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -1 +1,203 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP GET", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 0967ef424bc..ec0dc0fe3fa 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -1 +1,227 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 0967ef424bc..a203c628d9f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -1 +1,231 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.variables", + "Value": "{\"name\":\"World\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index 0967ef424bc..068bdda6282 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -1 +1,69 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Error", + "tags": [ + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "Found a NameStart character `d` (100) following a number, which is disallowed." + }, + { + "Key": "graphql.error.code", + "Value": "HC0011" + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 4, + "column": 13 + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 0967ef424bc..f94a175db44 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -1 +1,203 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index 0967ef424bc..f4675df0826 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -1 +1,163 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 0967ef424bc..ec0dc0fe3fa 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -1 +1,227 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 0967ef424bc..0a7b055eaf1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -1 +1,231 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_c46cf8c9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index 0967ef424bc..f3423be9748 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -1 +1,69 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Error", + "tags": [ + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "Expected a `Name`-token, but found a `Integer`-token." + }, + { + "Key": "graphql.error.code", + "Value": "HC0011" + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 0967ef424bc..ff23bb565df 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -1 +1,115 @@ -{} +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "otel.status_code", + "Value": "OK" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:346f68539881f0624dca2927281d1a2f" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:346f68539881f0624dca2927281d1a2f" + }, + { + "Key": "otel.status_code", + "Value": "ERROR" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "The field `abc` does not exist on the type `Query`." + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] + } + ] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [ + { + "Key": "otel.status_code", + "Value": "OK" + } + ], + "event": [] + } + ] + } + ] +} From fd91e51bc2fac5569923809c41513bbcd90ce700 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 10:49:04 +0000 Subject: [PATCH 17/37] Properly report errors and set status --- .../Diagnostics.Core/ActivityEnricherBase.cs | 4 -- .../Extensions/ActivityExtensions.cs | 30 +++++----- .../Spans/AnalyzeOperationComplexitySpan.cs | 2 +- .../Spans/ExecuteOperationSpan.cs | 4 +- .../Spans/ExecuteRequestSpan.cs | 6 +- .../Spans/Http/ExecuteHttpRequestSpan.cs | 14 ++--- .../Spans/Http/FormatHttpResponseSpan.cs | 2 +- .../Spans/Http/ParseHttpRequestSpan.cs | 8 +-- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 2 +- .../Diagnostics.Core/Spans/ValidationSpan.cs | 2 +- .../Spans/VariableCoercionSpan.cs | 2 +- .../ActivityDataLoaderDiagnosticListener.cs | 10 +--- .../ActivityExecutionDiagnosticListener.cs | 22 +++---- .../Diagnostics/Spans/CompileOperationSpan.cs | 2 +- .../Diagnostics/Spans/DataLoaderBatchSpan.cs | 5 ++ .../Spans/DataLoaderDispatchSpan.cs | 5 ++ .../src/Diagnostics/Spans/ResolveFieldSpan.cs | 5 +- ...h_Dispatch_Coordinator_Emits_Activity.snap | 2 +- ...ch_Coordinator_Tracks_Dispatch_Events.snap | 2 +- ...onTests.Allow_document_to_be_captured.snap | 24 -------- ...r_error_that_deletes_the_whole_result.snap | 26 +-------- ...or_that_deletes_the_whole_result_deep.snap | 12 ---- ...peration_name_is_used_as_request_name.snap | 24 -------- ...lidation_activity_has_an_error_status.snap | 12 ---- ...rack_events_of_a_simple_query_default.snap | 12 ---- ...ack_events_of_a_simple_query_detailed.snap | 24 -------- ...umentationTests.Http_Get_SDL_download.snap | 4 -- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 42 +------------- ...s.Http_Post_SingleRequest_GetHeroName.snap | 42 +------------- ...ost_SingleRequest_GetHeroName_Default.snap | 30 +--------- ....Http_Post_add_query_to_http_activity.snap | 46 +-------------- ...p_Post_add_variables_to_http_activity.snap | 46 +-------------- ...s.Http_Post_capture_deferred_response.snap | 39 +------------ ...t_ensure_list_path_is_correctly_built.snap | 58 +------------------ ...mentationTests.Http_Post_parser_error.snap | 18 +----- ...not_automatically_added_to_activities.snap | 46 +-------------- ...onTests.Http_Post_with_extensions_map.snap | 46 +-------------- ...g_error_when_rename_root_is_activated.snap | 18 +----- ...n_error_when_rename_root_is_activated.snap | 26 +-------- ...ctivityExecutionDiagnosticEventListener.cs | 32 +++++----- .../Spans/ExecutePlanNodeSpan.cs | 5 ++ .../Spans/PlanOperationSpan.cs | 2 +- ...onTests.Allow_Document_To_Be_Captured.snap | 22 +------ ...r_Error_That_Deletes_The_Whole_Result.snap | 22 +------ ...or_That_Deletes_The_Whole_Result_Deep.snap | 12 ---- ...peration_Name_Is_Used_As_Request_Name.snap | 22 +------ ...lidation_Activity_Has_An_Error_Status.snap | 12 ---- ...onTests.Source_Schema_Transport_Error.snap | 32 ++-------- ...ents_Of_A_Query_With_Multiple_Sources.snap | 24 +------- ...rack_Events_Of_A_Simple_Query_Default.snap | 10 +--- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 22 +------ ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 22 +------ ...umentationTests.Http_Get_SDL_Download.snap | 4 -- ...entationTests.Http_Get_Single_Request.snap | 36 +----------- ....Http_Post_Add_Query_To_Http_Activity.snap | 40 +------------ ...p_Post_Add_Variables_To_Http_Activity.snap | 40 +------------ ...mentationTests.Http_Post_Parser_Error.snap | 18 +----- ...ntationTests.Http_Post_Single_Request.snap | 36 +----------- ...ests.Http_Post_Single_Request_Default.snap | 28 +-------- ...Not_Automatically_Added_To_Activities.snap | 40 +------------ ...onTests.Http_Post_With_Extensions_Map.snap | 40 +------------ ...g_Error_When_Rename_Root_Is_Activated.snap | 18 +----- ...n_Error_When_Rename_Root_Is_Activated.snap | 26 +-------- 63 files changed, 146 insertions(+), 1143 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 80bfaa28d62..ec65c827d3a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -100,8 +100,4 @@ public virtual void EnrichCoerceVariables( public virtual void EnrichExecuteOperation( Activity activity, RequestContext context) { } - - public virtual void EnrichError(Activity activity, IError error) { } - - public virtual void EnrichException(Activity activity, Exception exception) { } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs index 14ca67ca0ad..39a6d55e3d8 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs @@ -1,7 +1,4 @@ using System.Diagnostics; -using System.Runtime.CompilerServices; -using OpenTelemetry.Trace; -using Status = OpenTelemetry.Trace.Status; namespace HotChocolate.Diagnostics; @@ -9,25 +6,26 @@ internal static class ActivityExtensions { extension(Activity activity) { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void MarkAsSuccess() +#if !NET9_0_OR_GREATER + public void AddException(Exception exception) { - activity.SetStatus(Status.Ok); - activity.SetStatus(ActivityStatusCode.Ok); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void MarkAsError() - { - activity.SetStatus(Status.Error); - activity.SetStatus(ActivityStatusCode.Error); + activity.AddEvent( + new ActivityEvent( + "exception", + tags: new ActivityTagsCollection + { + { "exception.message", exception.Message }, + { "exception.stacktrace", exception.ToString() }, + { "exception.type", exception.GetType().ToString() } + })); } +#endif - public void RecordError(IError error) + public void AddGraphQLError(IError error) { if (error.Exception is { } exception) { - activity.RecordException(exception); + activity.AddException(exception); } var tags = new ActivityTagsCollection diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 05aea0cab2a..7ca27a3c2c6 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -67,7 +67,7 @@ protected override void OnComplete() { if (_costSet) { - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } enricher.EnrichAnalyzeOperationCost(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index 032976a1923..2fd2787407a 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -54,11 +54,11 @@ protected override void OnComplete() { if (context.Result is null or OperationResult { Errors: [_, ..] }) { - Activity.MarkAsError(); + Activity.SetStatus(ActivityStatusCode.Error); } else { - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } enricher.EnrichExecuteOperation(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs index b1abc18b110..5a4e9e9f95b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs @@ -53,7 +53,7 @@ protected override void OnComplete() } } - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } var documentInfo = context.OperationDocumentInfo; @@ -77,11 +77,11 @@ protected override void OnComplete() if (context.Result is null or OperationResult { Errors: [_, ..] }) { - Activity.MarkAsError(); + Activity.SetStatus(ActivityStatusCode.Error); } else { - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } enricher?.EnrichExecuteRequest(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index 72548f4874b..1ad3a1d4ee0 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -56,7 +56,7 @@ internal sealed class ExecuteHttpRequestSpan( } activity.SetTag(GraphQL.Schema.Name, schemaName); - activity.MarkAsSuccess(); + activity.SetStatus(ActivityStatusCode.Ok); return new ExecuteHttpRequestSpan(activity, httpContext, kind, enricher, options); } @@ -229,17 +229,17 @@ protected override void OnComplete() public void RecordError(IError error) { - Activity.RecordError(error); - Activity.MarkAsError(); + Activity.SetStatus(ActivityStatusCode.Error); + Activity.AddGraphQLError(error); + enricher.EnrichHttpRequestError(Activity, httpContext, error); - enricher.EnrichError(Activity, error); } public void RecordError(Exception exception) { - Activity.RecordException(exception); - Activity.MarkAsError(); + Activity.SetStatus(ActivityStatusCode.Error); + Activity.AddException(exception); + enricher.EnrichHttpRequestError(Activity, httpContext, exception); - enricher.EnrichException(Activity, exception); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs index 5c9ada5ba2a..8df70769751 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs @@ -21,7 +21,7 @@ internal sealed class FormatHttpResponseSpan( return null; } - activity.MarkAsSuccess(); + activity.SetStatus(ActivityStatusCode.Ok); return new FormatHttpResponseSpan(activity, httpContext, enricher); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs index c30761f1aa5..da7f9ef9cc9 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs @@ -21,20 +21,20 @@ internal sealed class ParseHttpRequestSpan( return null; } - activity.MarkAsSuccess(); + activity.SetStatus(ActivityStatusCode.Ok); return new ParseHttpRequestSpan(activity, httpContext, enricher); } public void RecordErrors(IReadOnlyList errors) { + Activity.SetStatus(ActivityStatusCode.Error); + foreach (var error in errors) { - Activity.RecordError(error); - enricher.EnrichError(Activity, error); + Activity.AddGraphQLError(error); } - Activity.MarkAsError(); enricher.EnrichParserErrors(Activity, httpContext, errors); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index bdeaac3aeea..766be587136 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -42,7 +42,7 @@ protected override void OnComplete() } } - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } var documentInfo = context.OperationDocumentInfo; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index fb8ef50052c..29068e505d6 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -56,7 +56,7 @@ protected override void OnComplete() { if (context.IsOperationDocumentValid()) { - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } enricher.EnrichValidateDocument(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index 7732fe29381..439a2186375 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -54,7 +54,7 @@ protected override void OnComplete() { if (context.VariableValues.Length > 0) { - Activity.MarkAsSuccess(); + Activity.SetStatus(ActivityStatusCode.Ok); } enricher.EnrichCoerceVariables(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index ad092899a84..e2d15408e22 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -45,16 +45,12 @@ public override IDisposable RunBatchDispatchCoordinator() public override void BatchDispatchError(Exception error) { -#if NET9_0_OR_GREATER - Activity.Current?.AddException(error); -#else - Activity.Current?.SetStatus(ActivityStatusCode.Error, error.Message); -#endif - if (Activity.Current is { } activity) { + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(error); + _enricher.EnrichBatchDispatchError(activity, error); - _enricher.EnrichException(activity, error); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index bccf8243b57..6c7d32d5127 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -55,11 +55,10 @@ public override void RequestError(RequestContext context, Exception error) { var activity = span.Activity; - activity.RecordException(error); - activity.MarkAsError(); + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(error); _enricher.EnrichRequestError(activity, context, error); - _enricher.EnrichException(activity, error); } } @@ -69,11 +68,10 @@ public override void RequestError(RequestContext context, IError error) { var activity = span.Activity; - activity.RecordError(error); - activity.MarkAsError(); + activity.SetStatus(ActivityStatusCode.Error); + activity.AddGraphQLError(error); _enricher.EnrichRequestError(activity, context, error); - _enricher.EnrichError(activity, error); } } @@ -117,14 +115,13 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList( protected override void OnComplete() { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + enricher.EnrichExecuteBatch(Activity, dataLoader, keys); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs index 99f7f3402f8..a193a4f4753 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs @@ -27,6 +27,11 @@ internal sealed class DataLoaderDispatchSpan( protected override void OnComplete() { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + enricher.EnrichRunBatchDispatchCoordinator(Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs index db8d62fca84..b9ef912634d 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ResolveFieldSpan.cs @@ -39,7 +39,10 @@ internal sealed class ResolveFieldSpan( protected override void OnComplete() { - Activity.MarkAsSuccess(); + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } enricher.EnrichResolveFieldValue(Activity, context); } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap index a7a2daf1c50..a7bc715d1b7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Emits_Activity.snap @@ -3,7 +3,7 @@ { "OperationName": "GraphQL DataLoader Dispatch", "DisplayName": "GraphQL DataLoader Dispatch", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap index b0c339d25a6..f835ed1a85a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityDataLoaderDiagnosticListenerTests.Run_Batch_Dispatch_Coordinator_Tracks_Dispatch_Events.snap @@ -3,7 +3,7 @@ { "OperationName": "GraphQL DataLoader Dispatch", "DisplayName": "GraphQL DataLoader Dispatch", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 3379f6c6f46..897c20a4256 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -13,10 +13,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -54,10 +50,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -85,10 +77,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -113,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -141,10 +125,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -177,10 +157,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index bbed2d6a653..e12fe6e961e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -13,10 +13,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -54,10 +50,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -85,10 +77,6 @@ { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -113,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -141,10 +125,6 @@ { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" } ], "event": [], @@ -152,7 +132,7 @@ { "OperationName": "SimpleQuery.causeFatalError", "DisplayName": "SimpleQuery.causeFatalError", - "Status": "Ok", + "Status": "Error", "tags": [ { "Key": "graphql.processing.type", @@ -177,10 +157,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index f0d0efff69c..f477c1bfce9 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -13,10 +13,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -45,10 +41,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -76,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index 1c177f05d25..fc671fbcbe9 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -13,10 +13,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -50,10 +46,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -81,10 +73,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -109,10 +97,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -137,10 +121,6 @@ { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -173,10 +153,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index 59840a1af8f..83c66ba6cf8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -13,10 +13,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -45,10 +41,6 @@ "Key": "graphql.operation.name", "Value": "SayHelloOperation" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -76,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" } ], "event": [ diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 3c577a99283..0ed3bad0155 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -16,10 +16,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -40,10 +36,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -76,10 +68,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index c63e8da7bdc..e5c726fb27d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -9,10 +9,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -42,10 +38,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -69,10 +61,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -93,10 +81,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -117,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -153,10 +133,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "SimpleQuery" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap index 3bd6ff6b97c..1669a6a2090 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 15e2ab71323..7578385325f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -185,10 +156,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -201,12 +168,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 40bc68d34d3..2d925fdfd26 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -185,10 +156,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -201,12 +168,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index a7c27e9ac96..beef5946029 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -41,12 +37,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -65,10 +56,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -89,10 +76,6 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +108,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -137,12 +116,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 3c4d9de201f..7a940e187b5 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -173,10 +144,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -209,10 +176,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -225,12 +188,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index 5ccf4143d90..7a701e6f895 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -28,12 +24,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -45,10 +36,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -81,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -105,10 +88,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -129,10 +108,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -153,10 +128,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -177,10 +148,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -213,10 +180,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -229,12 +192,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index af5256bbf3f..16b456035e8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -185,10 +156,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -221,10 +188,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Droid" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index e2086b9120d..fe5dd5ea4c8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -185,10 +156,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -221,10 +188,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Droid" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -257,10 +220,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -293,10 +252,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -329,10 +284,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Human" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -345,12 +296,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap index c4e81092490..12163143e55 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -20,12 +16,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], + "tags": [], "event": [ { "Name": "exception", @@ -55,12 +46,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 3c4d9de201f..7a940e187b5 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -173,10 +144,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -209,10 +176,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -225,12 +188,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index e8330a520ca..20ca20ac606 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -28,12 +24,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -45,10 +36,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -81,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -105,10 +88,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -129,10 +108,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -153,10 +128,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -177,10 +148,6 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -213,10 +180,6 @@ { "Key": "graphql.selection.field.parent_type", "Value": "Query" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -229,12 +192,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap index 8fd22c7389b..82a6b94e61b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -20,12 +16,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], + "tags": [], "event": [ { "Name": "exception", @@ -55,12 +46,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index eca9d0536dd..9eb25b9aaa4 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -68,10 +55,6 @@ { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" } ], "event": [ @@ -101,12 +84,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 9de325c21cd..d0841ad1123 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -53,11 +53,10 @@ public override void RequestError(RequestContext context, Exception error) { var activity = span.Activity; - activity.RecordException(error); - activity.MarkAsError(); + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(error); _enricher.EnrichRequestError(activity, context, error); - _enricher.EnrichException(activity, error); } } @@ -67,11 +66,10 @@ public override void RequestError(RequestContext context, IError error) { var activity = span.Activity; - activity.RecordError(error); - activity.MarkAsError(); + activity.SetStatus(ActivityStatusCode.Error); + activity.AddGraphQLError(error); _enricher.EnrichRequestError(activity, context, error); - _enricher.EnrichError(activity, error); } } @@ -115,14 +113,13 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList.GetResult()\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158" }, { - "Key": "exception.message", - "Value": "Response status code does not indicate success: 500 (Internal Server Error)." + "Key": "exception.type", + "Value": "System.Net.Http.HttpRequestException" } ] } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index c1a6ef79094..1b3cca1aecb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -9,10 +9,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -42,10 +38,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -69,10 +61,6 @@ { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -93,10 +81,6 @@ { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -117,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -128,7 +108,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -176,7 +156,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 2962da5589c..567b332fef4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -16,10 +16,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -40,10 +36,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -51,7 +43,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index 1ef0320f5d7..fe778b6b069 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -9,10 +9,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -42,10 +38,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -69,10 +61,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -93,10 +81,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -117,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -128,7 +108,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index 1ef0320f5d7..fe778b6b069 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -9,10 +9,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -42,10 +38,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -69,10 +61,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -93,10 +81,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -117,10 +101,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -128,7 +108,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap index 3bd6ff6b97c..1669a6a2090 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 815479ddc9b..470992e4e61 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -136,7 +111,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -189,12 +164,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index ec0dc0fe3fa..412fec55580 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -160,7 +131,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -213,12 +184,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index a203c628d9f..530c5a37e62 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -28,12 +24,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -45,10 +36,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -81,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -105,10 +88,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -129,10 +108,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -153,10 +128,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -164,7 +135,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -217,12 +188,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index 068bdda6282..b0d6d9b7444 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -20,12 +16,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], + "tags": [], "event": [ { "Name": "exception", @@ -55,12 +46,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index f94a175db44..069321a653c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -136,7 +111,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -189,12 +164,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index f4675df0826..de392c5dfa3 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -41,12 +37,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -65,10 +56,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -89,10 +76,6 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -100,7 +83,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -149,12 +132,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index ec0dc0fe3fa..412fec55580 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -77,10 +64,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -101,10 +84,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -125,10 +104,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -149,10 +124,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -160,7 +131,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -213,12 +184,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 0a7b055eaf1..03d84bd8f99 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -28,12 +24,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -45,10 +36,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -81,10 +68,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -105,10 +88,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -129,10 +108,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [] @@ -153,10 +128,6 @@ { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -164,7 +135,7 @@ { "OperationName": "GraphQL Step Execution", "DisplayName": "GraphQL Step Execution", - "Status": "Unset", + "Status": "Ok", "tags": [ { "Key": "graphql.processing.type", @@ -217,12 +188,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index f3423be9748..fde78095229 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -8,10 +8,6 @@ { "Key": "graphql.schema.name", "Value": "_Default" - }, - { - "Key": "otel.status_code", - "Value": "OK" } ], "event": [], @@ -20,12 +16,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Error", - "tags": [ - { - "Key": "otel.status_code", - "Value": "ERROR" - } - ], + "tags": [], "event": [ { "Name": "exception", @@ -55,12 +46,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index ff23bb565df..20c6e0575fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -9,10 +9,6 @@ "Key": "graphql.schema.name", "Value": "_Default" }, - { - "Key": "otel.status_code", - "Value": "OK" - }, { "Key": "graphql.http.request.type", "Value": "single" @@ -24,12 +20,7 @@ "OperationName": "Parse HTTP Request", "DisplayName": "Parse HTTP Request", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] }, { @@ -41,10 +32,6 @@ "Key": "graphql.operation.type", "Value": "query" }, - { - "Key": "otel.status_code", - "Value": "ERROR" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -68,10 +55,6 @@ { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" - }, - { - "Key": "otel.status_code", - "Value": "ERROR" } ], "event": [ @@ -101,12 +84,7 @@ "OperationName": "Format HTTP Response", "DisplayName": "Format HTTP Response", "Status": "Ok", - "tags": [ - { - "Key": "otel.status_code", - "Value": "OK" - } - ], + "tags": [], "event": [] } ] From 351469fa7ea41c878c6ee460c71c1bdba40540b1 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 11:54:25 +0100 Subject: [PATCH 18/37] Add more tests --- .../Spans/AnalyzeOperationComplexitySpan.cs | 2 - .../HotChocolate.Diagnostics.Tests.csproj | 1 + .../QueryInstrumentationTests.cs | 320 +++++++++++++ .../ServerInstrumentationTests.cs | 143 ++++++ ...esExecuteRequestAndParseDocumentSpans.snap | 145 ++++++ ...ityAnalysis_Enabled_RecordsCostInSpan.snap | 161 +++++++ ...es_OnlyValidateAndCompile_LimitsSpans.snap | 44 ++ ...oader_BatchExecution_RecordsBatchSpan.snap | 194 ++++++++ ...esExecuteRequestAndParseDocumentSpans.snap | 76 ++++ ..._SecondExecution_RecordsCacheHitEvent.snap | 262 +++++++++++ ...perationName_UsesAnonymousDisplayName.snap | 145 ++++++ ...meInRequest_UsedAsActivityDisplayName.snap | 165 +++++++ ...lidGraphQLDocument_ReportsErrorStatus.snap | 52 +++ ...ration_LoadsFromStorage_DefaultScopes.snap | 84 ++++ ...ror_AtRootLevel_MarksOperationAsError.snap | 163 +++++++ ...or_DeepInTree_MarksNestedFieldAsError.snap | 85 ++++ ...Error_UnknownField_ReportsErrorStatus.snap | 81 ++++ ...ion_WithAllScopes_RecordsCoercionSpan.snap | 165 +++++++ ...ts.Http_Get_SingleRequest_GetHeroName.snap | 4 - ...NameInRequest_SetsActivityDisplayName.snap | 217 +++++++++ ...s.Http_Post_SingleRequest_GetHeroName.snap | 4 - ....Http_Post_add_query_to_http_activity.snap | 4 - ...p_Post_add_variables_to_http_activity.snap | 4 - ...s.Http_Post_capture_deferred_response.snap | 4 - ...t_ensure_list_path_is_correctly_built.snap | 4 - ...not_automatically_added_to_activities.snap | 4 - ...onTests.Http_Post_with_extensions_map.snap | 4 - ...RequestDetails_All_IncludesAllDetails.snap | 229 ++++++++++ ...IncludesIdHashOperationNameExtensions.snap | 197 ++++++++ ...ails_DocumentOnly_IncludesDocumentTag.snap | 177 ++++++++ ...equestDetails_None_ExcludesAllDetails.snap | 213 +++++++++ ...ercionTests.InputObject_Invalid_Field.yaml | 2 +- .../QueryInstrumentationTests.cs | 421 ++++++++++++++++++ .../ServerInstrumentationTests.cs | 173 +++++++ ...ationTests.AllScopes_IncludesAllSpans.snap | 161 +++++++ ...copes_OnlyValidateAndPlan_LimitsSpans.snap | 44 ++ ...esExecuteRequestAndParseDocumentSpans.snap | 92 ++++ ..._SecondExecution_RecordsCacheHitEvent.snap | 294 ++++++++++++ ...HttpRequestError_MarksNodeSpanAsError.snap | 190 ++++++++ ...esolverError_RecordsDeeplyNestedError.snap | 213 +++++++++ ...perationName_UsesAnonymousDisplayName.snap | 161 +++++++ ...meInRequest_UsedAsActivityDisplayName.snap | 185 ++++++++ ...lidGraphQLDocument_ReportsErrorStatus.snap | 52 +++ ...ration_LoadsFromStorage_DefaultScopes.snap | 104 +++++ ...Error_UnknownField_ReportsErrorStatus.snap | 81 ++++ ...NameInRequest_SetsActivityDisplayName.snap | 217 +++++++++ ...RequestDetails_All_IncludesAllDetails.snap | 229 ++++++++++ ...IncludesIdHashOperationNameExtensions.snap | 197 ++++++++ ...ails_DocumentOnly_IncludesDocumentTag.snap | 177 ++++++++ ...equestDetails_None_ExcludesAllDetails.snap | 213 +++++++++ 50 files changed, 6524 insertions(+), 35 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap create mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 7ca27a3c2c6..679de469b65 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -23,8 +23,6 @@ internal sealed class AnalyzeOperationComplexitySpan( return null; } - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - if (context.TryGetDocument(out var document, out _) && document.GetOperation(context.Request.OperationName) is { } operation) { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/HotChocolate.Diagnostics.Tests.csproj b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/HotChocolate.Diagnostics.Tests.csproj index f3d92a3b4f1..2f7b559fa8a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/HotChocolate.Diagnostics.Tests.csproj +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/HotChocolate.Diagnostics.Tests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index 2e8e3c8fdf0..ea7e15aa44b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -1,6 +1,8 @@ using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; using HotChocolate.Execution; +using HotChocolate.Language; +using HotChocolate.PersistedOperations; using static HotChocolate.Diagnostics.ActivityTestHelper; namespace HotChocolate.Diagnostics; @@ -241,10 +243,299 @@ query SayHelloOperation { } } + [Fact] + public async Task PersistedOperation_LoadsFromStorage_DefaultScopes() + { + using (CaptureActivities(out var activities)) + { + // arrange + var storage = new InMemoryOperationDocumentStorage(); + storage.Add("sayHelloOp", "{ sayHello }"); + + var services = new ServiceCollection() + .AddGraphQL() + .AddInstrumentation() + .AddQueryType() + .UsePersistedOperationPipeline() + .ConfigureSchemaServices( + s => s.AddSingleton(storage)) + .Services + .BuildServiceProvider(); + + var executor = await services.GetRequestExecutorAsync(); + + // act + await executor.ExecuteAsync(OperationRequest.FromId("sayHelloOp")); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ParsingError_InvalidGraphQLDocument_ReportsErrorStatus() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("{ sayHello"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ValidationError_UnknownField_ReportsErrorStatus() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("{ unknownField123 }"); + + // assert + activities.MatchSnapshot(); + } + } + + // TODO: Not sure if we want this + [Fact] + public async Task DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation() + .AddQueryType() + .ExecuteRequestAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task AllScopes_IncludesExecuteRequestAndParseDocumentSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task CustomScopes_OnlyValidateAndCompile_LimitsSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => + o.Scopes = ActivityScopes.ValidateDocument | ActivityScopes.CompileOperation) + .AddQueryType() + .ExecuteRequestAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task OperationNameInRequest_UsedAsActivityDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("query MyOp { sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task NoOperationName_UsesAnonymousDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ResolverError_AtRootLevel_MarksOperationAsError() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => + { + o.Scopes = ActivityScopes.All; + o.IncludeDocument = true; + }) + .AddQueryType() + .ExecuteRequestAsync("{ causeFatalError }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ResolverError_DeepInTree_MarksNestedFieldAsError() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => + { + o.Scopes = ActivityScopes.All; + o.IncludeDocument = true; + }) + .AddQueryType() + .ExecuteRequestAsync( + """ + { + deep { + deeper { + deeps { + deeper { + causeFatalError + } + } + } + } + } + """); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ComplexityAnalysis_Enabled_RecordsCostInSpan() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => + o.Scopes = ActivityScopes.All) + .AddCostAnalyzer() + .AddQueryType() + .ExecuteRequestAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task DataLoader_BatchExecution_RecordsBatchSpan() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync("{ dataLoader(key: \"abc\") }"); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task VariableCoercion_WithAllScopes_RecordsCoercionSpan() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .ExecuteRequestAsync( + OperationRequestBuilder.New() + .SetDocument("query($name: String!) { greeting(name: $name) }") + .SetVariableValues( + new Dictionary { { "name", "World" } }) + .Build()); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() + { + using (CaptureActivities(out var activities)) + { + // arrange + var services = new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .Services + .BuildServiceProvider(); + + var executor = await services.GetRequestExecutorAsync(); + + // act - execute twice so second uses cached document + await executor.ExecuteAsync("{ sayHello }"); + await executor.ExecuteAsync("{ sayHello }"); + + // assert + activities.MatchSnapshot(); + } + } + public class SimpleQuery { public string SayHello() => "hello"; + public string Greeting(string name) => $"Hello, {name}!"; + public string CauseFatalError() => throw new GraphQLException("fail"); public Deep Deep() => new(); @@ -264,4 +555,33 @@ public class Deeper { public Deep[] Deeps() => [new Deep()]; } + + private sealed class InMemoryOperationDocumentStorage : IOperationDocumentStorage + { + private readonly Dictionary _cache = []; + + public void Add(string id, string document) + => _cache[id] = Utf8GraphQLParser.Parse(document); + + public ValueTask TryReadAsync( + OperationDocumentId documentId, + CancellationToken cancellationToken = default) + { + if (_cache.TryGetValue(documentId.Value, out var document)) + { + return new ValueTask(new OperationDocument(document)); + } + + return new ValueTask(default(IOperationDocument)); + } + + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, + CancellationToken cancellationToken = default) + { + _cache[documentId.Value] = Utf8GraphQLParser.Parse(document.AsSpan()); + return default; + } + } } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index 853776ee49e..48dfa6acd0f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -368,6 +368,149 @@ await server.PostRawAsync(new ClientQueryRequest } } + [Fact] + public async Task RequestDetails_None_ExcludesAllDetails() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateInstrumentedServer( + o => + { + o.Scopes = ActivityScopes.All; + o.RequestDetails = RequestDetails.None; + }); + + // act + await server.PostAsync(new ClientQueryRequest + { + Query = @" + query GetHero($episode: Episode!) { + hero(episode: $episode) { + name + } + }", + Variables = new Dictionary { { "episode", "NEW_HOPE" } }, + Extensions = new Dictionary { { "test", "abc" } } + }); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_All_IncludesAllDetails() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateInstrumentedServer( + o => + { + o.Scopes = ActivityScopes.All; + o.RequestDetails = RequestDetails.All; + }); + + // act + await server.PostAsync(new ClientQueryRequest + { + Query = @" + query GetHero($episode: Episode!) { + hero(episode: $episode) { + name + } + }", + Variables = new Dictionary { { "episode", "NEW_HOPE" } }, + Extensions = new Dictionary { { "test", "abc" } } + }); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_DocumentOnly_IncludesDocumentTag() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateInstrumentedServer( + o => + { + o.Scopes = ActivityScopes.All; + o.RequestDetails = RequestDetails.Document; + }); + + // act + await server.PostAsync(new ClientQueryRequest + { + Query = @" + { + hero { + name + } + }" + }); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_Default_IncludesIdHashOperationNameExtensions() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateInstrumentedServer( + o => o.Scopes = ActivityScopes.All); + + // act + await server.PostAsync(new ClientQueryRequest + { + Query = @" + query GetHero { + hero { + name + } + }", + Extensions = new Dictionary { { "test", "abc" } } + }); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task Http_Post_OperationNameInRequest_SetsActivityDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateInstrumentedServer( + o => o.Scopes = ActivityScopes.All); + + // act + await server.PostAsync(new ClientQueryRequest + { + Query = @" + query GetHeroByEpisode($episode: Episode!) { + hero(episode: $episode) { + name + } + }", + Variables = new Dictionary { { "episode", "NEW_HOPE" } } + }); + + // assert + activities.MatchSnapshot(); + } + } + private TestServer CreateInstrumentedServer( Action? options = null) => CreateStarWarsServer( diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap new file mode 100644 index 00000000000..e5c726fb27d --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap @@ -0,0 +1,145 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap new file mode 100644 index 00000000000..b2238a6757a --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap @@ -0,0 +1,161 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap new file mode 100644 index 00000000000..09a87fce98a --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap @@ -0,0 +1,44 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap new file mode 100644 index 00000000000..798b195e500 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap @@ -0,0 +1,194 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.dataLoader", + "DisplayName": "SimpleQuery.dataLoader", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.path", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.field.name", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.dataLoader" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL DataLoader Dispatch", + "DisplayName": "GraphQL DataLoader Dispatch", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_dispatch" + } + ], + "event": [ + { + "Name": "BatchEvaluated", + "Tags": [ + { + "Key": "openBatches", + "Value": 1 + } + ] + }, + { + "Name": "BatchDispatched", + "Tags": [ + { + "Key": "dispatchedBatches", + "Value": 1 + } + ] + } + ], + "activities": [ + { + "OperationName": "GraphQL DataLoader Batch CustomDataLoader", + "DisplayName": "GraphQL DataLoader Batch CustomDataLoader", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_batch" + }, + { + "Key": "graphql.dataloader.name", + "Value": "CustomDataLoader" + } + ], + "event": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap new file mode 100644 index 00000000000..0ed3bad0155 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap @@ -0,0 +1,76 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap new file mode 100644 index 00000000000..2283582a467 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -0,0 +1,262 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap new file mode 100644 index 00000000000..e5c726fb27d --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap @@ -0,0 +1,145 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap new file mode 100644 index 00000000000..8bf20ebc36a --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap @@ -0,0 +1,165 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap new file mode 100644 index 00000000000..10892b14993 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap @@ -0,0 +1,52 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "GraphQL Operation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "exception.message", + "Value": "Expected a `RightBrace`-token, but found a `EndOfFile`-token." + }, + { + "Key": "exception.stacktrace", + "Value": "HotChocolate.Language.SyntaxException: Expected a `RightBrace`-token, but found a `EndOfFile`-token.\n at HotChocolate.Language.Utf8GraphQLParser.ParseSelectionSet() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs:line 221\n at HotChocolate.Language.Utf8GraphQLParser.ParseShortOperationDefinition() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs:line 73\n at HotChocolate.Language.Utf8GraphQLParser.ParseDefinition() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 215\n at HotChocolate.Language.Utf8GraphQLParser.Parse() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 98\n at HotChocolate.Language.Utf8GraphQLParser.Parse(String sourceText, ParserOptions options) in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 326\n at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(RequestContext context) in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Core/src/Execution.Pipeline/DocumentParserMiddleware.cs:line 63" + }, + { + "Key": "exception.type", + "Value": "HotChocolate.Language.SyntaxException" + } + ] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap new file mode 100644 index 00000000000..626e8cbb7c0 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap @@ -0,0 +1,84 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.id", + "Value": "sayHelloOp" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.id", + "Value": "sayHelloOp" + } + ], + "event": [] + }, + { + "OperationName": "SimpleQuery.sayHello", + "DisplayName": "SimpleQuery.sayHello", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.path", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.name", + "Value": "sayHello" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.sayHello" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap new file mode 100644 index 00000000000..89a4d6c71ce --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap @@ -0,0 +1,163 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + }, + { + "Key": "graphql.document.body", + "Value": "{\n causeFatalError\n}" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.causeFatalError", + "DisplayName": "SimpleQuery.causeFatalError", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "causeFatalError" + }, + { + "Key": "graphql.selection.path", + "Value": "causeFatalError" + }, + { + "Key": "graphql.selection.field.name", + "Value": "causeFatalError" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.causeFatalError" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "fail" + }, + { + "Key": "graphql.error.path", + "Value": "causeFatalError" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap new file mode 100644 index 00000000000..5d59501f36d --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap @@ -0,0 +1,85 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" + }, + { + "Key": "graphql.document.body", + "Value": "{\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "The field `causeFatalError` does not exist on the type `Deeper`." + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 6, + "column": 21 + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap new file mode 100644 index 00000000000..bf59bc3b606 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap @@ -0,0 +1,81 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "The field `unknownField123` does not exist on the type `SimpleQuery`." + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap new file mode 100644 index 00000000000..0976709926c --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap @@ -0,0 +1,165 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.greeting", + "DisplayName": "SimpleQuery.greeting", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "greeting" + }, + { + "Key": "graphql.selection.path", + "Value": "greeting" + }, + { + "Key": "graphql.selection.field.name", + "Value": "greeting" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.greeting" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 7578385325f..7a9aa1a122f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap new file mode 100644 index 00000000000..37367cb44db --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap @@ -0,0 +1,217 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHeroByEpisode" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 2d925fdfd26..18fdf875831 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 7a940e187b5..025ed2c75b7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index 7a701e6f895..d91754cd165 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -77,10 +77,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 16b456035e8..7f51e38bf85 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index fe5dd5ea4c8..6093da53a77 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 7a940e187b5..025ed2c75b7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -73,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 20ca20ac606..123e8c78f9f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -77,10 +77,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap new file mode 100644 index 00000000000..9af893319ad --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -0,0 +1,229 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.query.body", + "Value": "query GetHero(\n $episode: Episode!\n) {\n hero(episode: $episode) {\n name\n }\n}" + }, + { + "Key": "graphql.http.request.variables", + "Value": "{\"episode\":\"NEW_HOPE\"}" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap new file mode 100644 index 00000000000..ded5745f826 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -0,0 +1,197 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap new file mode 100644 index 00000000000..153e3c009eb --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -0,0 +1,177 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.query.body", + "Value": "{\n hero {\n name\n }\n}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap new file mode 100644 index 00000000000..07b4069db8a --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -0,0 +1,213 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Complexity Analyzation", + "DisplayName": "GraphQL Complexity Analyzation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetHero" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Query.hero", + "DisplayName": "Query.hero", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.path", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.name", + "Value": "hero" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "Query.hero" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "Query" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.InputObject_Invalid_Field.yaml b/src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.InputObject_Invalid_Field.yaml index 7b2490d8f64..ad5a138da57 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.InputObject_Invalid_Field.yaml +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.InputObject_Invalid_Field.yaml @@ -19,7 +19,7 @@ response: { "message": "The field \u0060invalidField\u0060 is not defined on the input object type \u0060Cat\u0060.", "extensions": { - "variable": "/cat" + "variable": "cat" } } ] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index bc887e92352..a6565a825a1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -1,5 +1,8 @@ using System.Diagnostics; +using HotChocolate.Diagnostics; using HotChocolate.Execution; +using HotChocolate.Language; +using HotChocolate.PersistedOperations; using Microsoft.Extensions.DependencyInjection; using static HotChocolate.Fusion.Diagnostics.ActivityTestHelper; @@ -445,6 +448,377 @@ public async Task Track_Events_Of_A_Query_With_Multiple_Sources() } } + [Fact] + public async Task PersistedOperation_LoadsFromStorage_DefaultScopes() + { + using (CaptureActivities(out var activities)) + { + // arrange + var storage = new InMemoryOperationDocumentStorage(); + storage.Add("sayHelloOp", "{ sayHello }"); + + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b + .AddInstrumentation() + .ConfigureSchemaServices( + (_, s) => s.AddSingleton(storage)) + .UsePersistedOperationPipeline()); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + // act + await executor.ExecuteAsync(OperationRequest.FromId("sayHelloOp")); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ParsingError_InvalidGraphQLDocument_ReportsErrorStatus() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task ValidationError_UnknownField_ReportsErrorStatus() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ unknownField123 }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation()); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task AllScopes_IncludesAllSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task CustomScopes_OnlyValidateAndPlan_LimitsSpans() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.ValidateDocument + | FusionActivityScopes.PlanOperation)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task OperationNameInRequest_UsedAsActivityDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("query MyOp { sayHello }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task NoOperationName_UsesAnonymousDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task MultipleSources_HttpRequestError_MarksNodeSpanAsError() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var server2 = CreateSourceSchema( + "b", + b => b.AddQueryType(), + isOffline: true); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1), + ("b", server2) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + { + o.Scopes = FusionActivityScopes.All; + o.IncludeDocument = true; + })); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello sayGoodbye }") + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var server2 = CreateSourceSchema( + "b", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1), + ("b", server2) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + { + o.Scopes = FusionActivityScopes.All; + o.IncludeDocument = true; + })); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument( + """ + { + sayHello + deepB { + deeperB { + causeFatalError + } + } + } + """) + .Build(); + + // act + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + // act - execute twice so second uses cached document + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .Build(); + + await executor.ExecuteAsync(request); + await executor.ExecuteAsync(request); + + // assert + activities.MatchSnapshot(); + } + } + public class Query { public string SayHello() => "hello"; @@ -466,6 +840,24 @@ public class QueryB public string SayGoodbye() => "goodbye"; } + [GraphQLName("Query")] + public class QueryBWithDeepError + { + public string SayGoodbye() => "goodbye"; + + public DeepB DeepB() => new(); + } + + public class DeepB + { + public DeeperB DeeperB() => new(); + } + + public class DeeperB + { + public string CauseFatalError() => throw new GraphQLException("deep fail"); + } + public class Deep { public Deeper Deeper() => new(); @@ -477,4 +869,33 @@ public class Deeper { public Deep[] Deeps() => [new Deep()]; } + + private sealed class InMemoryOperationDocumentStorage : IOperationDocumentStorage + { + private readonly Dictionary _cache = []; + + public void Add(string id, string document) + => _cache[id] = Utf8GraphQLParser.Parse(document); + + public ValueTask TryReadAsync( + OperationDocumentId documentId, + CancellationToken cancellationToken = default) + { + if (_cache.TryGetValue(documentId.Value, out var document)) + { + return new ValueTask(new OperationDocument(document)); + } + + return new ValueTask(default(IOperationDocument)); + } + + public ValueTask SaveAsync( + OperationDocumentId documentId, + IOperationDocument document, + CancellationToken cancellationToken = default) + { + _cache[documentId.Value] = Utf8GraphQLParser.Parse(document.AsSpan()); + return default; + } + } } diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index ed5965ea178..3c7bafb8774 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -383,6 +383,179 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() } } + [Fact] + public async Task RequestDetails_None_ExcludesAllDetails() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [("a", server)], + configureGatewayBuilder: b => b.AddInstrumentation( + o => + { + o.Scopes = FusionActivityScopes.All; + o.RequestDetails = RequestDetails.None; + })); + + using var client = GraphQLHttpClient.Create(gateway.CreateClient()); + + var request = new OperationRequest( + query: """ + query GetGreeting($name: String!) { + greeting(name: $name) + } + """, + variables: new Dictionary { { "name", "World" } }, + extensions: new Dictionary { { "test", "abc" } }); + + // act + using var result = await client.PostAsync(request, s_url); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_All_IncludesAllDetails() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [("a", server)], + configureGatewayBuilder: b => b.AddInstrumentation( + o => + { + o.Scopes = FusionActivityScopes.All; + o.RequestDetails = RequestDetails.All; + })); + + using var client = GraphQLHttpClient.Create(gateway.CreateClient()); + + var request = new OperationRequest( + query: """ + query GetGreeting($name: String!) { + greeting(name: $name) + } + """, + variables: new Dictionary { { "name", "World" } }, + extensions: new Dictionary { { "test", "abc" } }); + + // act + using var result = await client.PostAsync(request, s_url); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_DocumentOnly_IncludesDocumentTag() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [("a", server)], + configureGatewayBuilder: b => b.AddInstrumentation( + o => + { + o.Scopes = FusionActivityScopes.All; + o.RequestDetails = RequestDetails.Document; + })); + + using var client = GraphQLHttpClient.Create(gateway.CreateClient()); + + var request = new OperationRequest("{ sayHello }"); + + // act + using var result = await client.PostAsync(request, s_url); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task RequestDetails_Default_IncludesIdHashOperationNameExtensions() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [("a", server)], + configureGatewayBuilder: b => b.AddInstrumentation( + o => o.Scopes = FusionActivityScopes.All)); + + using var client = GraphQLHttpClient.Create(gateway.CreateClient()); + + var request = new OperationRequest( + query: """ + query GetGreeting { + sayHello + } + """, + extensions: new Dictionary { { "test", "abc" } }); + + // act + using var result = await client.PostAsync(request, s_url); + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task Http_Post_OperationNameInRequest_SetsActivityDisplayName() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server = CreateSourceSchema( + "a", + b => b.AddQueryType()); + + using var gateway = await CreateCompositeSchemaAsync( + [("a", server)], + configureGatewayBuilder: b => b.AddInstrumentation( + o => o.Scopes = FusionActivityScopes.All)); + + using var client = GraphQLHttpClient.Create(gateway.CreateClient()); + + var request = new OperationRequest( + query: """ + query GetGreetingByName($name: String!) { + greeting(name: $name) + } + """, + variables: new Dictionary { { "name", "World" } }); + + // act + using var result = await client.PostAsync(request, s_url); + + // assert + activities.MatchSnapshot(); + } + } + public class Query { public string SayHello() => "hello"; diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap new file mode 100644 index 00000000000..fe778b6b069 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap @@ -0,0 +1,161 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap new file mode 100644 index 00000000000..09a87fce98a --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap @@ -0,0 +1,44 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap new file mode 100644 index 00000000000..567b332fef4 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap @@ -0,0 +1,92 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap new file mode 100644 index 00000000000..ffa28e2fcca --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -0,0 +1,294 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap new file mode 100644 index 00000000000..93f74171684 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap @@ -0,0 +1,190 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + }, + { + "Key": "graphql.document.body", + "Value": "{\n sayHello\n sayGoodbye\n}" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Unset", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:073bf7696c078e52587c88890ef21bbe" + }, + { + "Key": "graphql.operation.step.id", + "Value": "2" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" + }, + { + "Key": "graphql.source.name", + "Value": "b" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_073bf769_2" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "exception.message", + "Value": "Response status code does not indicate success: 500 (Internal Server Error)." + }, + { + "Key": "exception.stacktrace", + "Value": "System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).\n at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\n at HotChocolate.Fusion.Transport.Http.GraphQLHttpResponse.ReadAsResultAsync(CancellationToken cancellationToken) in GraphQLHttpResponse.cs:line 150\n at HotChocolate.Fusion.Execution.Clients.SourceSchemaHttpClient.Response.ReadAsResultStreamAsync(CancellationToken cancellationToken)+MoveNext() in SourceSchemaHttpClient.cs:line 577\n at HotChocolate.Fusion.Execution.Clients.SourceSchemaHttpClient.Response.ReadAsResultStreamAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158" + }, + { + "Key": "exception.type", + "Value": "System.Net.Http.HttpRequestException" + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap new file mode 100644 index 00000000000..0c77f95348c --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap @@ -0,0 +1,213 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + }, + { + "Key": "graphql.document.body", + "Value": "{\n sayHello\n deepB {\n deeperB {\n causeFatalError\n }\n }\n}" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "6034e1863f163f1cf2ced76832d1f0f496fa230f34e6ea0bb0b1a9de5b0f7db5" + }, + { + "Key": "graphql.source.name", + "Value": "b" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_241c617b_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:7dfcb1cc48aa6c4d4750dc471f2f71b0c1acf70356383ea909d2c5994dc65d6f" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + }, + { + "Key": "graphql.operation.step.id", + "Value": "2" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "6034e1863f163f1cf2ced76832d1f0f496fa230f34e6ea0bb0b1a9de5b0f7db5" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_241c617b_2" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:23e6ec3292fdaf4949c838051e42d74bee6c27bed8b0720637c4b77d961f3ef3" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap new file mode 100644 index 00000000000..fe778b6b069 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap @@ -0,0 +1,161 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap new file mode 100644 index 00000000000..a1cbbd7aca3 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap @@ -0,0 +1,185 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "MyOp" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "a98170628f191ebff09f0fb9fb2dfbe571198d565b457fa166c0b4efe3bc9e20" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "MyOp_cb42fac0_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:a490aca65a3bd8d348ab10c71053c9bcdda1f81c52c1106d66e112d2e56d36e9" + } + ], + "event": [] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap new file mode 100644 index 00000000000..bd5ffd80003 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap @@ -0,0 +1,52 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "GraphQL Operation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "exception.message", + "Value": "Expected a `RightBrace`-token, but found a `EndOfFile`-token." + }, + { + "Key": "exception.stacktrace", + "Value": "HotChocolate.Language.SyntaxException: Expected a `RightBrace`-token, but found a `EndOfFile`-token.\n at HotChocolate.Language.Utf8GraphQLParser.ParseSelectionSet() in Utf8GraphQLParser.Operations.cs:line 221\n at HotChocolate.Language.Utf8GraphQLParser.ParseShortOperationDefinition() in Utf8GraphQLParser.Operations.cs:line 73\n at HotChocolate.Language.Utf8GraphQLParser.ParseDefinition() in Utf8GraphQLParser.cs:line 215\n at HotChocolate.Language.Utf8GraphQLParser.Parse() in Utf8GraphQLParser.cs:line 98\n at HotChocolate.Language.Utf8GraphQLParser.Parse(String sourceText, ParserOptions options) in Utf8GraphQLParser.cs:line 326\n at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(RequestContext context) in DocumentParserMiddleware.cs:line 63" + }, + { + "Key": "exception.type", + "Value": "HotChocolate.Language.SyntaxException" + } + ] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Unset", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap new file mode 100644 index 00000000000..e4361336a78 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap @@ -0,0 +1,104 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.id", + "Value": "sayHelloOp" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.id", + "Value": "sayHelloOp" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.document.id", + "Value": "sayHelloOp" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap new file mode 100644 index 00000000000..17300b20ade --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap @@ -0,0 +1,81 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Error", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "parse" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1526f207d516803b71eb8a0db419b57b" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "The field `unknownField123` does not exist on the type `Query`." + }, + { + "Key": "graphql.error.locations", + "Value": [ + { + "line": 1, + "column": 3 + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap new file mode 100644 index 00000000000..c0eee965c8e --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap @@ -0,0 +1,217 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreetingByName" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:4f33a60d4ccb822195345aaf7258b649" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "ca1b7ddc139a796427bb8f038fd7b1d78e4b678141df887304f916363259661d" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "GetGreetingByName_4f33a60d_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:4edb6cbcb2c1a6f3b39ac971526043d760b69a6d2dc5324a9cdbce30a3e786b1" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap new file mode 100644 index 00000000000..fa0bff72adc --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -0,0 +1,229 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.query.body", + "Value": "query GetGreeting(\n $name: String!\n) {\n greeting(name: $name)\n}" + }, + { + "Key": "graphql.http.request.variables", + "Value": "{\"name\":\"World\"}" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "12136be79ce453a7feac5df83310a20585dbdb9c9675bc55b25c2c2ea1f871e1" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "GetGreeting_111e40f9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:00692b6fbeb8014bcc1eb8932d5924dc0c5e5ea3e158e34979ec322c2e1b3c40" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap new file mode 100644 index 00000000000..86b628a4bd5 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -0,0 +1,197 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.extensions", + "Value": "{\"test\":\"abc\"}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "f274a33c8d687ab897e52e6be6346ef3ccdd10a864a4088c571073d755df2d92" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "GetGreeting_cf203f64_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:579285518f37f039b04a0268fd6058a3903e369efccd77c48e7c045c35f25428" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap new file mode 100644 index 00000000000..e944c98d48b --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -0,0 +1,177 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.query.body", + "Value": "{\n sayHello\n}" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "Op_f7e9989f_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap new file mode 100644 index 00000000000..c7582416d6d --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -0,0 +1,213 @@ +{ + "activities": [ + { + "OperationName": "ExecuteHttpRequest", + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + } + ], + "event": [], + "activities": [ + { + "OperationName": "Parse HTTP Request", + "DisplayName": "Parse HTTP Request", + "Status": "Ok", + "tags": [], + "event": [] + }, + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Variable Coercion", + "DisplayName": "GraphQL Variable Coercion", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "variable_coercion" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.operation.name", + "Value": "GetGreeting" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "12136be79ce453a7feac5df83310a20585dbdb9c9675bc55b25c2c2ea1f871e1" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "GetGreeting_111e40f9_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "query" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:00692b6fbeb8014bcc1eb8932d5924dc0c5e5ea3e158e34979ec322c2e1b3c40" + } + ], + "event": [] + } + ] + } + ] + }, + { + "OperationName": "Format HTTP Response", + "DisplayName": "Format HTTP Response", + "Status": "Ok", + "tags": [], + "event": [] + } + ] + } + ] +} From 3b5df4fbac54c95207765a6d77b617b7ef9f7fe7 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 13:00:18 +0100 Subject: [PATCH 19/37] Add GraphQL error details on "exception" span event --- .../Extensions/ActivityExtensions.cs | 13 ++++---- .../ActivityDataLoaderDiagnosticListener.cs | 8 ++--- .../ActivityExecutionDiagnosticListener.cs | 29 ++++++++--------- .../ActivityServerDiagnosticListener.cs | 8 ++--- ...ctivityExecutionDiagnosticEventListener.cs | 32 +++++++++---------- .../FusionActivityServerDiagnosticListener.cs | 8 ++--- 6 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs index 39a6d55e3d8..118742248b1 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs @@ -23,16 +23,18 @@ public void AddException(Exception exception) public void AddGraphQLError(IError error) { - if (error.Exception is { } exception) - { - activity.AddException(exception); - } - var tags = new ActivityTagsCollection { [SemanticConventions.GraphQL.Error.Message] = error.Message }; + if (error.Exception is { } exception) + { + tags["exception.message"] = exception.Message; + tags["exception.stacktrace"] = exception.ToString(); + tags["exception.type"] = exception.GetType().ToString(); + } + if (error.Path is not null) { tags[SemanticConventions.GraphQL.Error.Path] = error.Path.Print(); @@ -59,7 +61,6 @@ public void AddGraphQLError(IError error) tags[SemanticConventions.GraphQL.Error.Locations] = locations; } - // TODO: Not sure if this is correct according to the spec activity.AddEvent(new ActivityEvent("exception", default, tags)); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index e2d15408e22..ea8300a348d 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -9,8 +9,6 @@ internal sealed class ActivityDataLoaderDiagnosticListener( InstrumentationOptions options) : DataLoaderDiagnosticEventListener { - private readonly ActivityEnricher _enricher = enricher; - public override IDisposable ExecuteBatch( IDataLoader dataLoader, IReadOnlyList keys) @@ -20,7 +18,7 @@ public override IDisposable ExecuteBatch( return EmptyScope; } - var span = DataLoaderBatchSpan.Start(Source, dataLoader, keys, _enricher); + var span = DataLoaderBatchSpan.Start(Source, dataLoader, keys, enricher); if (span is null) { @@ -38,7 +36,7 @@ public override IDisposable ExecuteBatch( public override IDisposable RunBatchDispatchCoordinator() { - var span = DataLoaderDispatchSpan.Start(Source, _enricher); + var span = DataLoaderDispatchSpan.Start(Source, enricher); return span ?? EmptyScope; } @@ -50,7 +48,7 @@ public override void BatchDispatchError(Exception error) activity.SetStatus(ActivityStatusCode.Error); activity.AddException(error); - _enricher.EnrichBatchDispatchError(activity, error); + enricher.EnrichBatchDispatchError(activity, error); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index 6c7d32d5127..9da5972c45d 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -13,7 +13,6 @@ internal sealed class ActivityExecutionDiagnosticListener( InstrumentationOptions options) : ExecutionDiagnosticEventListener { private const string ResolveFieldSpanKey = "HotChocolate.Diagnostics.ResolveFieldSpan"; - private readonly ActivityEnricher _enricher = enricher; public override bool EnableResolveFieldValue => true; @@ -36,8 +35,8 @@ public override IDisposable ExecuteRequest(RequestContext context) } var span = httpContextActivity is not null - ? new ExecuteRequestSpan(httpContextActivity, context, options, _enricher, false) - : ExecuteRequestSpan.Start(Source, context, options, _enricher); + ? new ExecuteRequestSpan(httpContextActivity, context, options, enricher, false) + : ExecuteRequestSpan.Start(Source, context, options, enricher); if (span is null) { @@ -58,7 +57,7 @@ public override void RequestError(RequestContext context, Exception error) activity.SetStatus(ActivityStatusCode.Error); activity.AddException(error); - _enricher.EnrichRequestError(activity, context, error); + enricher.EnrichRequestError(activity, context, error); } } @@ -71,7 +70,7 @@ public override void RequestError(RequestContext context, IError error) activity.SetStatus(ActivityStatusCode.Error); activity.AddGraphQLError(error); - _enricher.EnrichRequestError(activity, context, error); + enricher.EnrichRequestError(activity, context, error); } } @@ -82,7 +81,7 @@ public override IDisposable ParseDocument(RequestContext context) return EmptyScope; } - var span = ParsingSpan.Start(Source, context, _enricher); + var span = ParsingSpan.Start(Source, context, enricher); return span ?? EmptyScope; } @@ -94,7 +93,7 @@ public override IDisposable ValidateDocument(RequestContext context) return EmptyScope; } - var span = ValidationSpan.Start(Source, context, _enricher); + var span = ValidationSpan.Start(Source, context, enricher); if (span is null) { @@ -122,7 +121,7 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList Date: Thu, 5 Mar 2026 15:13:27 +0100 Subject: [PATCH 20/37] More cleanup --- .../Spans/AnalyzeOperationComplexitySpan.cs | 12 --- .../Spans/ExecuteRequestSpan.cs | 89 ------------------- .../Spans/ExecuteRequestSpanBase.cs | 59 ++++++++++++ .../Spans/Http/ExecuteHttpRequestSpan.cs | 6 +- .../Spans/Http/FormatHttpResponseSpan.cs | 7 +- .../Spans/Http/ParseHttpRequestSpan.cs | 7 +- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 15 +--- .../Diagnostics.Core/Spans/ValidationSpan.cs | 12 --- .../Diagnostics/Spans/CompileOperationSpan.cs | 22 ++--- .../Spans/DataLoaderDispatchSpan.cs | 2 - .../Diagnostics/Spans/ExecuteRequestSpan.cs | 52 +++++++++++ ...esExecuteRequestAndParseDocumentSpans.snap | 20 +---- ...onTests.Allow_document_to_be_captured.snap | 28 +----- ...r_error_that_deletes_the_whole_result.snap | 28 +----- ...or_that_deletes_the_whole_result_deep.snap | 30 +------ ...ityAnalysis_Enabled_RecordsCostInSpan.snap | 24 +---- ...es_OnlyValidateAndCompile_LimitsSpans.snap | 12 +-- ...oader_BatchExecution_RecordsBatchSpan.snap | 20 +---- ...esExecuteRequestAndParseDocumentSpans.snap | 12 +-- ..._SecondExecution_RecordsCacheHitEvent.snap | 32 +------ ...peration_name_is_used_as_request_name.snap | 28 +----- ...lidation_activity_has_an_error_status.snap | 30 +------ ...perationName_UsesAnonymousDisplayName.snap | 20 +---- ...meInRequest_UsedAsActivityDisplayName.snap | 28 +----- ...lidGraphQLDocument_ReportsErrorStatus.snap | 4 - ...ration_LoadsFromStorage_DefaultScopes.snap | 12 +-- ...ror_AtRootLevel_MarksOperationAsError.snap | 20 +---- ...or_DeepInTree_MarksNestedFieldAsError.snap | 18 +--- ...rack_events_of_a_simple_query_default.snap | 12 +-- ...ack_events_of_a_simple_query_detailed.snap | 20 +---- ...Error_UnknownField_ReportsErrorStatus.snap | 18 +--- ...ion_WithAllScopes_RecordsCoercionSpan.snap | 20 +---- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 16 +--- ...NameInRequest_SetsActivityDisplayName.snap | 24 +---- ...s.Http_Post_SingleRequest_GetHeroName.snap | 16 +--- ...ost_SingleRequest_GetHeroName_Default.snap | 12 +-- ....Http_Post_add_query_to_http_activity.snap | 16 +--- ...p_Post_add_variables_to_http_activity.snap | 16 +--- ...s.Http_Post_capture_deferred_response.snap | 16 +--- ...t_ensure_list_path_is_correctly_built.snap | 16 +--- ...not_automatically_added_to_activities.snap | 16 +--- ...onTests.Http_Post_with_extensions_map.snap | 16 +--- ...RequestDetails_All_IncludesAllDetails.snap | 24 +---- ...IncludesIdHashOperationNameExtensions.snap | 24 +---- ...ails_DocumentOnly_IncludesDocumentTag.snap | 16 +--- ...equestDetails_None_ExcludesAllDetails.snap | 24 +---- ...n_error_when_rename_root_is_activated.snap | 10 +-- ...ctivityExecutionDiagnosticEventListener.cs | 1 - .../Spans/ExecutePlanNodeSpan.cs | 1 - .../Spans/ExecuteRequestSpan.cs | 52 +++++++++++ .../Spans/PlanOperationSpan.cs | 13 ++- ...ationTests.AllScopes_IncludesAllSpans.snap | 12 --- ...onTests.Allow_Document_To_Be_Captured.snap | 20 ----- ...r_Error_That_Deletes_The_Whole_Result.snap | 20 ----- ...or_That_Deletes_The_Whole_Result_Deep.snap | 30 +------ ...copes_OnlyValidateAndPlan_LimitsSpans.snap | 4 - ...esExecuteRequestAndParseDocumentSpans.snap | 4 - ..._SecondExecution_RecordsCacheHitEvent.snap | 24 ----- ...peration_Name_Is_Used_As_Request_Name.snap | 20 ----- ...lidation_Activity_Has_An_Error_Status.snap | 30 +------ ...HttpRequestError_MarksNodeSpanAsError.snap | 12 --- ...esolverError_RecordsDeeplyNestedError.snap | 12 --- ...perationName_UsesAnonymousDisplayName.snap | 12 --- ...meInRequest_UsedAsActivityDisplayName.snap | 20 ----- ...lidGraphQLDocument_ReportsErrorStatus.snap | 4 - ...ration_LoadsFromStorage_DefaultScopes.snap | 4 - ...onTests.Source_Schema_Transport_Error.snap | 12 --- ...ents_Of_A_Query_With_Multiple_Sources.snap | 12 --- ...rack_Events_Of_A_Simple_Query_Default.snap | 4 - ...ack_Events_Of_A_Simple_Query_Detailed.snap | 12 --- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 12 --- ...Error_UnknownField_ReportsErrorStatus.snap | 18 +--- ...entationTests.Http_Get_Single_Request.snap | 4 - ....Http_Post_Add_Query_To_Http_Activity.snap | 4 - ...p_Post_Add_Variables_To_Http_Activity.snap | 4 - ...NameInRequest_SetsActivityDisplayName.snap | 8 -- ...ntationTests.Http_Post_Single_Request.snap | 19 +--- ...ests.Http_Post_Single_Request_Default.snap | 4 - ...Not_Automatically_Added_To_Activities.snap | 4 - ...onTests.Http_Post_With_Extensions_Map.snap | 4 - ...RequestDetails_All_IncludesAllDetails.snap | 8 -- ...IncludesIdHashOperationNameExtensions.snap | 8 -- ...ails_DocumentOnly_IncludesDocumentTag.snap | 4 - ...equestDetails_None_ExcludesAllDetails.snap | 8 -- ...n_Error_When_Rename_Root_Is_Activated.snap | 10 +-- 85 files changed, 332 insertions(+), 1103 deletions(-) delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs create mode 100644 src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 679de469b65..2153f1519ba 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -23,18 +23,6 @@ internal sealed class AnalyzeOperationComplexitySpan( return null; } - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - var documentInfo = context.OperationDocumentInfo; var hash = documentInfo.Hash; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs deleted file mode 100644 index 5a4e9e9f95b..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpan.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Diagnostics; -using HotChocolate.Execution; -using HotChocolate.Language.Utilities; -using OpenTelemetry.Trace; -using static HotChocolate.Diagnostics.SemanticConventions; - -namespace HotChocolate.Diagnostics; - -internal sealed class ExecuteRequestSpan( - Activity activity, - RequestContext context, - InstrumentationOptionsBase options, - ActivityEnricherBase? enricher, - bool shouldDisposeActivity) : SpanBase(activity, shouldDisposeActivity) -{ - public static ExecuteRequestSpan? Start( - ActivitySource source, - RequestContext context, - InstrumentationOptionsBase options, - ActivityEnricherBase enricher) - { - var activity = source.StartActivity("GraphQL Operation", ActivityKind.Server); - - if (activity is null) - { - return null; - } - - return new ExecuteRequestSpan( - activity, - context, - options, - enricher, - true); - } - - protected override void OnComplete() - { - // TODO: This could be faster through the operation - if (context.TryGetDocument(out var document, out _)) - { - if (document.GetOperation(context.Request.OperationName) is { } operation) - { - var operationType = GraphQL.Operation.TypeValues[operation.Operation]; - - Activity.DisplayName = operationType; - Activity.SetTag(GraphQL.Operation.Type, operationType); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - - Activity.SetStatus(ActivityStatusCode.Ok); - } - - var documentInfo = context.OperationDocumentInfo; - - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } - - if (options.IncludeDocument && documentInfo.Document is not null) - { - Activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); - } - - if (context.Result is null or OperationResult { Errors: [_, ..] }) - { - Activity.SetStatus(ActivityStatusCode.Error); - } - else - { - Activity.SetStatus(ActivityStatusCode.Ok); - } - - enricher?.EnrichExecuteRequest(Activity, context); - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs new file mode 100644 index 00000000000..9b49dd6ac14 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs @@ -0,0 +1,59 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using HotChocolate.Language.Utilities; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal abstract class ExecuteRequestSpanBase( + Activity activity, + RequestContext context, + InstrumentationOptionsBase options, + ActivityEnricherBase? enricher, + bool shouldDisposeActivity) : SpanBase(activity, shouldDisposeActivity) +{ + public RequestContext Context { get; } = context; + + protected static Activity? StartActivity(ActivitySource source) + { + return source.StartActivity("GraphQL Operation", ActivityKind.Server); + } + + protected override void OnComplete() + { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + + var documentInfo = Context.OperationDocumentInfo; + + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); + } + + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) + { + Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); + } + + if (options.IncludeDocument && documentInfo.Document is not null) + { + Activity.SetTag(GraphQL.Document.Body, documentInfo.Document.Print()); + } + + if (Context.Result is null or OperationResult { Errors: [_, ..] }) + { + Activity.SetStatus(ActivityStatusCode.Error); + } + else + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + + enricher?.EnrichExecuteRequest(Activity, Context); + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index 1ad3a1d4ee0..3553f1ae499 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -56,7 +56,6 @@ internal sealed class ExecuteHttpRequestSpan( } activity.SetTag(GraphQL.Schema.Name, schemaName); - activity.SetStatus(ActivityStatusCode.Ok); return new ExecuteHttpRequestSpan(activity, httpContext, kind, enricher, options); } @@ -224,6 +223,11 @@ public void SetOperationBatchRequestDetails( protected override void OnComplete() { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + enricher.EnrichExecuteHttpRequest(Activity, httpContext, kind); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs index 8df70769751..7f2d12a3a58 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs @@ -21,13 +21,16 @@ internal sealed class FormatHttpResponseSpan( return null; } - activity.SetStatus(ActivityStatusCode.Ok); - return new FormatHttpResponseSpan(activity, httpContext, enricher); } protected override void OnComplete() { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + enricher.EnrichFormatHttpResponse(Activity, httpContext); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs index da7f9ef9cc9..e6cd83c68ed 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs @@ -21,8 +21,6 @@ internal sealed class ParseHttpRequestSpan( return null; } - activity.SetStatus(ActivityStatusCode.Ok); - return new ParseHttpRequestSpan(activity, httpContext, enricher); } @@ -40,6 +38,11 @@ public void RecordErrors(IReadOnlyList errors) protected override void OnComplete() { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + enricher.EnrichParseHttpRequest(Activity, httpContext); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index 766be587136..1df02f180d2 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -22,26 +22,13 @@ internal sealed class ParsingSpan( return null; } - activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); - return new ParsingSpan(activity, context, enricher); } protected override void OnComplete() { - if (context.TryGetDocument(out var document, out _)) + if (context.TryGetDocument(out _, out _)) { - if (document.GetOperation(context.Request.OperationName) is { } operation) - { - Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - Activity.SetStatus(ActivityStatusCode.Ok); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index 29068e505d6..afa7768aa81 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -24,18 +24,6 @@ internal sealed class ValidationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - var documentInfo = context.OperationDocumentInfo; var hash = documentInfo.Hash; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs index e0c07ab37c4..54a55525253 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs @@ -23,18 +23,6 @@ internal sealed class CompileOperationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - var documentInfo = context.OperationDocumentInfo; var hash = documentInfo.Hash; @@ -53,9 +41,17 @@ internal sealed class CompileOperationSpan( protected override void OnComplete() { - if (context.TryGetOperation(out _)) + if (context.TryGetOperation(out var operation)) { Activity.SetStatus(ActivityStatusCode.Ok); + + Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Kind]); + + var operationName = operation.Name; + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } } enricher.EnrichCompileOperation(Activity, context); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs index a193a4f4753..d7f8b1d8f9f 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/DataLoaderDispatchSpan.cs @@ -1,6 +1,4 @@ using System.Diagnostics; -using HotChocolate.Execution; -using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics; diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs new file mode 100644 index 00000000000..fc98a8d711c --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs @@ -0,0 +1,52 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ExecuteRequestSpan( + Activity activity, + RequestContext context, + InstrumentationOptionsBase options, + ActivityEnricherBase? enricher, + bool shouldDisposeActivity) : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) +{ + public static ExecuteRequestSpan? Start( + ActivitySource source, + RequestContext context, + InstrumentationOptionsBase options, + ActivityEnricherBase enricher) + { + var activity = StartActivity(source); + + if (activity is null) + { + return null; + } + + return new ExecuteRequestSpan( + activity, + context, + options, + enricher, + true); + } + + protected override void OnComplete() + { + if (Context.TryGetOperation(out var operation)) + { + var operationType = GraphQL.Operation.TypeValues[operation.Kind]; + Activity.SetTag(GraphQL.Operation.Type, operationType); + Activity.DisplayName = operationType; + + var operationName = operation.Name; + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } + } + + base.OnComplete(); + } +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap index e5c726fb27d..49f7e009662 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap index 897c20a4256..1a00249e432 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap @@ -38,18 +38,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -66,14 +54,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -90,6 +70,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -97,10 +81,6 @@ { "Key": "graphql.operation.name", "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap index e12fe6e961e..6b24042cac8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap @@ -38,18 +38,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -66,14 +54,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -90,6 +70,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -97,10 +81,6 @@ { "Key": "graphql.operation.name", "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap index f477c1bfce9..1a25c0b220d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap @@ -2,17 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -29,18 +21,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -57,14 +37,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap index b2238a6757a..b102cd0a9fe 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -70,10 +58,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -90,13 +74,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap index 09a87fce98a..6e5564554ca 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -29,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap index 798b195e500..12f52991c63 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap index 0ed3bad0155..2386d6e2307 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -29,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap index 2283582a467..70a59b001c4 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] @@ -167,14 +155,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -191,10 +171,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap index fc671fbcbe9..3a98c0e8fa6 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap @@ -34,18 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -62,14 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -86,6 +66,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -93,10 +77,6 @@ { "Key": "graphql.operation.name", "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap index 83c66ba6cf8..16d3fd1d1f8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap @@ -2,17 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -29,18 +21,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -57,14 +37,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap index e5c726fb27d..49f7e009662 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap index 8bf20ebc36a..c80085b8eb2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap @@ -34,18 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, { "Key": "graphql.document.hash", "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" @@ -62,14 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, { "Key": "graphql.document.hash", "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" @@ -86,6 +66,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -93,10 +77,6 @@ { "Key": "graphql.operation.name", "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap index 10892b14993..3796df85e59 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap @@ -35,10 +35,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Unset", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.document.hash", "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap index 626e8cbb7c0..b85b922a120 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -33,10 +29,6 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -44,6 +36,10 @@ { "Key": "graphql.document.id", "Value": "sayHelloOp" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap index 89a4d6c71ce..6031fca24ee 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap @@ -34,14 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" @@ -58,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" @@ -78,13 +66,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:ae3f9af1d2570e25f30a1ad002172b82" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap index 5d59501f36d..dd5f4d13d99 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" @@ -25,14 +21,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" @@ -49,10 +37,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:2bf0466e723c1bad3a65089b6fb0dbfc" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap index 0ed3bad0155..2386d6e2307 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -29,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap index e5c726fb27d..49f7e009662 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap index bf59bc3b606..c0dc8f03d3c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" @@ -21,14 +17,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" @@ -45,10 +33,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap index 0976709926c..e9d8d435d16 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" @@ -74,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 7a9aa1a122f..8b7ebe7e9b2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap index 37367cb44db..5062a1fc85c 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap @@ -61,14 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - }, { "Key": "graphql.document.hash", "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" @@ -81,14 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - }, { "Key": "graphql.document.hash", "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" @@ -105,6 +89,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -112,10 +100,6 @@ { "Key": "graphql.operation.name", "Value": "GetHeroByEpisode" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 18fdf875831..874ef70b943 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index beef5946029..e897b8cfb22 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -49,10 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -69,13 +65,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap index 025ed2c75b7..e9750924864 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap index d91754cd165..37f00469d69 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -77,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -97,13 +89,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap index 7f51e38bf85..bd2c4c1ccef 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap index 6093da53a77..147b908927b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap index 025ed2c75b7..e9750924864 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -73,10 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -93,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap index 123e8c78f9f..4beeebc258b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -77,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" @@ -97,13 +89,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index 9af893319ad..b83ba8ff2fd 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -73,14 +73,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" @@ -93,14 +85,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" @@ -117,6 +101,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -124,10 +112,6 @@ { "Key": "graphql.operation.name", "Value": "GetHero" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:9335388c19fd2e230b6294a596d13a93" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index ded5745f826..18131e1c576 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -65,14 +65,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" @@ -85,14 +77,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" @@ -109,6 +93,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -116,10 +104,6 @@ { "Key": "graphql.operation.name", "Value": "GetHero" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index 153e3c009eb..11bf49462dc 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -77,10 +73,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" @@ -97,13 +89,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index 07b4069db8a..9fa0b533d02 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -57,14 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" @@ -77,14 +69,6 @@ "DisplayName": "GraphQL Complexity Analyzation", "Status": "Ok", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHero" - }, { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" @@ -101,6 +85,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:9335388c19fd2e230b6294a596d13a93" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -108,10 +96,6 @@ { "Key": "graphql.operation.name", "Value": "GetHero" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:9335388c19fd2e230b6294a596d13a93" } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap index 9eb25b9aaa4..ce98da6bec0 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap @@ -25,13 +25,9 @@ }, { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -48,10 +44,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 577b8f4c008..41b9799406a 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -4,7 +4,6 @@ using HotChocolate.Fusion.Execution; using HotChocolate.Fusion.Execution.Nodes; using Microsoft.AspNetCore.Http; -using OpenTelemetry.Trace; using static HotChocolate.Fusion.Diagnostics.HotChocolateFusionActivitySource; namespace HotChocolate.Fusion.Diagnostics.Listeners; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs index 168a9f78ae7..8cad66885ba 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs @@ -4,7 +4,6 @@ using HotChocolate.Fusion.Diagnostics; using HotChocolate.Fusion.Execution; using HotChocolate.Fusion.Execution.Nodes; -using OpenTelemetry.Trace; using static HotChocolate.Diagnostics.SemanticConventions; namespace HotChocolate.Diagnostics; diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs new file mode 100644 index 00000000000..efcd94ecfc2 --- /dev/null +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs @@ -0,0 +1,52 @@ +using System.Diagnostics; +using HotChocolate.Execution; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class ExecuteRequestSpan( + Activity activity, + RequestContext context, + InstrumentationOptionsBase options, + ActivityEnricherBase? enricher, + bool shouldDisposeActivity) : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) +{ + public static ExecuteRequestSpan? Start( + ActivitySource source, + RequestContext context, + InstrumentationOptionsBase options, + ActivityEnricherBase enricher) + { + var activity = StartActivity(source); + + if (activity is null) + { + return null; + } + + return new ExecuteRequestSpan( + activity, + context, + options, + enricher, + true); + } + + protected override void OnComplete() + { + if (Context.GetOperationPlan() is { Operation: var operation}) + { + var operationType = GraphQL.Operation.TypeValues[operation.Definition.Operation]; + Activity.SetTag(GraphQL.Operation.Type, operationType); + Activity.DisplayName = operationType; + + var operationName = operation.Name; + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } + } + + base.OnComplete(); + } +} diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs index dfb169bab87..bc871d2e79b 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -56,9 +56,20 @@ internal sealed class PlanOperationSpan( protected override void OnComplete() { - if (context.GetOperationPlan() is not null) + if (context.GetOperationPlan() is { } plan) { Activity.SetStatus(ActivityStatusCode.Ok); + + var operation = plan.Operation; + var operationType = operation.Definition.Operation; + var operationName = operation.Name; + + Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); + + if (!string.IsNullOrEmpty(operationName)) + { + Activity.SetTag(GraphQL.Operation.Name, operationName); + } } enricher.EnrichPlanOperation(Activity, context, operationPlanId); diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap index fe778b6b069..33b122e09fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index e1ac6c57bfd..83253985fa5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -38,18 +38,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -66,14 +54,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 20cb0313572..7a6515281e5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -38,18 +38,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" @@ -66,14 +54,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap index f477c1bfce9..1a25c0b220d 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap @@ -2,17 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -29,18 +21,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" @@ -57,14 +37,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:803df9346db185e9dc0b22dd3909aa70" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap index 09a87fce98a..edcb1cef283 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap index 567b332fef4..02d1557c5dd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap index ffa28e2fcca..c2c12aaf823 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -183,14 +171,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -207,10 +187,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap index 96da79ee4f7..a84aa0b3fcb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap @@ -34,18 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" @@ -62,14 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap index e0f41312251..5312732e3a8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap @@ -2,17 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -29,18 +21,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" @@ -57,14 +37,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, { "Key": "graphql.document.hash", "Value": "md5:bb1d246465341a97bdc727d6cd8ead5c" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap index 93f74171684..600eba8e3e4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap @@ -34,14 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -58,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap index 0c77f95348c..c4cc9d6d059 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap @@ -34,14 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:241c617bf9ec34fef187d8b149fd8498" @@ -58,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:241c617bf9ec34fef187d8b149fd8498" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap index fe778b6b069..33b122e09fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap index a1cbbd7aca3..250e9873a59 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap @@ -34,18 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, { "Key": "graphql.document.hash", "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" @@ -62,14 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, { "Key": "graphql.document.hash", "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap index bd5ffd80003..aec02c711c2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap @@ -35,10 +35,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Unset", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, { "Key": "graphql.document.hash", "Value": "md5:bb507ba78696fc3c6ff3a17fb06784d5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap index e4361336a78..a587cb7e489 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 9cbd662723d..80080053c85 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -34,14 +34,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -58,10 +50,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 1b3cca1aecb..99fe5fb135e 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 567b332fef4..02d1557c5dd 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -9,10 +9,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap index fe778b6b069..33b122e09fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap index fe778b6b069..33b122e09fc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap @@ -30,14 +30,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -54,10 +46,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap index 17300b20ade..469d64a23ed 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap @@ -2,13 +2,9 @@ "activities": [ { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" @@ -21,14 +17,6 @@ "DisplayName": "GraphQL Document Parsing", "Status": "Ok", "tags": [ - { - "Key": "graphql.processing.type", - "Value": "parse" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" @@ -45,10 +33,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:1526f207d516803b71eb8a0db419b57b" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 470992e4e61..8bf42f82815 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap index 412fec55580..3d7a83ab9da 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 530c5a37e62..e8e9d5461ea 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap index c0eee965c8e..5ba7e372b41 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap @@ -61,14 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, { "Key": "graphql.document.hash", "Value": "md5:4f33a60d4ccb822195345aaf7258b649" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 069321a653c..7cdab36908c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,18 +2,9 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], + "DisplayName": "ExecuteHttpRequest", + "Status": "Unset", + "tags": [], "event": [], "activities": [ { @@ -57,10 +48,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index de392c5dfa3..ce5aedb5061 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -49,10 +49,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 412fec55580..3d7a83ab9da 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -57,10 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 03d84bd8f99..415a5878598 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index fa0bff72adc..7633cb0dece 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -73,14 +73,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreeting" - }, { "Key": "graphql.document.hash", "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index 86b628a4bd5..a243603489f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -65,14 +65,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreeting" - }, { "Key": "graphql.document.hash", "Value": "md5:cf203f646caf64f424638bd2f09e490a" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index e944c98d48b..e9183e48061 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -61,10 +61,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index c7582416d6d..b8150e5e921 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -57,14 +57,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreeting" - }, { "Key": "graphql.document.hash", "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 20c6e0575fc..3e03450d58a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -25,13 +25,9 @@ }, { "OperationName": "GraphQL Operation", - "DisplayName": "query", + "DisplayName": "GraphQL Operation", "Status": "Error", "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" @@ -48,10 +44,6 @@ "Key": "graphql.processing.type", "Value": "validate" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:346f68539881f0624dca2927281d1a2f" From 212c62799781cae352d12e4fd078b989b10a4d7a Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 14:54:16 +0000 Subject: [PATCH 21/37] Update migration guide again --- .../Diagnostics.Core/ActivityEnricherBase.cs | 76 +++++++++---------- .../Spans/AnalyzeOperationComplexitySpan.cs | 4 +- .../Spans/ExecuteOperationSpan.cs | 2 +- .../Spans/ExecuteRequestSpanBase.cs | 2 +- .../Spans/Http/ExecuteHttpRequestSpan.cs | 12 +-- .../Spans/Http/FormatHttpResponseSpan.cs | 2 +- .../Spans/Http/ParseHttpRequestSpan.cs | 4 +- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 2 +- .../Diagnostics.Core/Spans/ValidationSpan.cs | 2 +- .../Spans/VariableCoercionSpan.cs | 2 +- .../src/Diagnostics/ActivityEnricher.cs | 24 +++--- .../ActivityDataLoaderDiagnosticListener.cs | 2 +- .../ActivityExecutionDiagnosticListener.cs | 10 +-- .../Diagnostics/Spans/CompileOperationSpan.cs | 2 +- .../Diagnostics/Spans/DataLoaderBatchSpan.cs | 2 +- .../src/Diagnostics/Spans/ResolveFieldSpan.cs | 2 +- .../FusionActivityEnricher.cs | 24 +++--- ...ctivityExecutionDiagnosticEventListener.cs | 14 ++-- .../Spans/ExecutePlanNodeSpan.cs | 2 +- .../Spans/PlanOperationSpan.cs | 2 +- .../v16/migrating/migrate-from-15-to-16.md | 59 +++++++++++--- 21 files changed, 145 insertions(+), 106 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index ec65c827d3a..100af8b0db5 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -13,91 +13,91 @@ namespace HotChocolate.Diagnostics; public abstract class ActivityEnricherBase { public virtual void EnrichExecuteHttpRequest( - Activity activity, HttpContext httpContext, - HttpRequestKind kind) { } + HttpRequestKind kind, + Activity activity) { } public virtual void EnrichStartSingleRequest( - Activity activity, HttpContext httpContext, - GraphQLRequest request) { } + GraphQLRequest request, + Activity activity) { } public virtual void EnrichStartBatchRequest( - Activity activity, HttpContext httpContext, - IReadOnlyList batch) { } + IReadOnlyList batch, + Activity activity) { } public virtual void EnrichStartOperationBatchRequest( - Activity activity, HttpContext httpContext, GraphQLRequest request, - IReadOnlyList operations) { } + IReadOnlyList operations, + Activity activity) { } public virtual void EnrichHttpRequestError( - Activity activity, HttpContext httpContext, - IError error) { } + IError error, + Activity activity) { } public virtual void EnrichHttpRequestError( - Activity activity, HttpContext httpContext, - Exception exception) { } + Exception exception, + Activity activity) { } public virtual void EnrichParseHttpRequest( - Activity activity, - HttpContext httpContext) { } + HttpContext httpContext, + Activity activity) { } public virtual void EnrichParserErrors( - Activity activity, HttpContext httpContext, - IReadOnlyList errors) { } + IReadOnlyList errors, + Activity activity) { } public virtual void EnrichFormatHttpResponse( - Activity activity, - HttpContext httpContext) { } + HttpContext httpContext, + Activity activity) { } public virtual void EnrichExecuteRequest( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichRequestError( - Activity activity, RequestContext context, - Exception exception) { } + Exception exception, + Activity activity) { } public virtual void EnrichRequestError( - Activity activity, RequestContext context, - IError error) { } + IError error, + Activity activity) { } public virtual void EnrichParseDocument( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichValidateDocument( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichValidationErrors( - Activity activity, RequestContext context, - IReadOnlyList errors) { } + IReadOnlyList errors, + Activity activity) { } public virtual void EnrichAnalyzeOperationCost( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichOperationCost( - Activity activity, RequestContext context, double fieldCost, - double typeCost) { } + double typeCost, + Activity activity) { } public virtual void EnrichCoerceVariables( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichExecuteOperation( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 2153f1519ba..3352eae5432 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -46,7 +46,7 @@ public void SetCost(double fieldCost, double typeCost) _costSet = true; - enricher.EnrichOperationCost(Activity, context, fieldCost, typeCost); + enricher.EnrichOperationCost(context, fieldCost, typeCost, Activity); } protected override void OnComplete() @@ -56,6 +56,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichAnalyzeOperationCost(Activity, context); + enricher.EnrichAnalyzeOperationCost(context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index 2fd2787407a..15fedecd622 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -61,6 +61,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichExecuteOperation(Activity, context); + enricher.EnrichExecuteOperation(context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs index 9b49dd6ac14..ddf666fc420 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs @@ -54,6 +54,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher?.EnrichExecuteRequest(Activity, Context); + enricher?.EnrichExecuteRequest(Context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index 3553f1ae499..f44242a4e56 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -107,7 +107,7 @@ public void SetSingleRequestDetails(GraphQLRequest request) } } - enricher.EnrichStartSingleRequest(Activity, httpContext, request); + enricher.EnrichStartSingleRequest(httpContext, request, Activity); } public void SetBatchRequestDetails(IReadOnlyList batch) @@ -166,7 +166,7 @@ public void SetBatchRequestDetails(IReadOnlyList batch) } } - enricher.EnrichStartBatchRequest(Activity, httpContext, batch); + enricher.EnrichStartBatchRequest(httpContext, batch, Activity); } public void SetOperationBatchRequestDetails( @@ -218,7 +218,7 @@ public void SetOperationBatchRequestDetails( } } - enricher.EnrichStartOperationBatchRequest(Activity, httpContext, request, operations); + enricher.EnrichStartOperationBatchRequest(httpContext, request, operations, Activity); } protected override void OnComplete() @@ -228,7 +228,7 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichExecuteHttpRequest(Activity, httpContext, kind); + enricher.EnrichExecuteHttpRequest(httpContext, kind, Activity); } public void RecordError(IError error) @@ -236,7 +236,7 @@ public void RecordError(IError error) Activity.SetStatus(ActivityStatusCode.Error); Activity.AddGraphQLError(error); - enricher.EnrichHttpRequestError(Activity, httpContext, error); + enricher.EnrichHttpRequestError(httpContext, error, Activity); } public void RecordError(Exception exception) @@ -244,6 +244,6 @@ public void RecordError(Exception exception) Activity.SetStatus(ActivityStatusCode.Error); Activity.AddException(exception); - enricher.EnrichHttpRequestError(Activity, httpContext, exception); + enricher.EnrichHttpRequestError(httpContext, exception, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs index 7f2d12a3a58..e8cf5d8e580 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/FormatHttpResponseSpan.cs @@ -31,6 +31,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichFormatHttpResponse(Activity, httpContext); + enricher.EnrichFormatHttpResponse(httpContext, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs index e6cd83c68ed..8f809d2b0df 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ParseHttpRequestSpan.cs @@ -33,7 +33,7 @@ public void RecordErrors(IReadOnlyList errors) Activity.AddGraphQLError(error); } - enricher.EnrichParserErrors(Activity, httpContext, errors); + enricher.EnrichParserErrors(httpContext, errors, Activity); } protected override void OnComplete() @@ -43,6 +43,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichParseHttpRequest(Activity, httpContext); + enricher.EnrichParseHttpRequest(httpContext, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index 1df02f180d2..68d7ae28fd7 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -45,6 +45,6 @@ protected override void OnComplete() Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); } - enricher.EnrichParseDocument(Activity, context); + enricher.EnrichParseDocument(context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index afa7768aa81..f27b15bdffd 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -47,6 +47,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichValidateDocument(Activity, context); + enricher.EnrichValidateDocument(context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index 439a2186375..a26ed09a4ed 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -57,6 +57,6 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - enricher.EnrichCoerceVariables(Activity, context); + enricher.EnrichCoerceVariables(context, Activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs index 526649d96a6..896c1b3fcfc 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/ActivityEnricher.cs @@ -16,32 +16,32 @@ public class ActivityEnricher(InstrumentationOptions options) : ActivityEnricher protected InstrumentationOptions Options { get; } = options; public virtual void EnrichCompileOperation( - Activity activity, - RequestContext context) { } + RequestContext context, + Activity activity) { } public virtual void EnrichResolveFieldValue( - Activity activity, - IMiddlewareContext context) { } + IMiddlewareContext context, + Activity activity) { } public virtual void EnrichResolverError( - Activity activity, IMiddlewareContext context, - IError error) { } + IError error, + Activity activity) { } public virtual void EnrichExecuteBatch( - Activity activity, IDataLoader dataLoader, - IReadOnlyList keys) where TKey : notnull { } + IReadOnlyList keys, + Activity activity) where TKey : notnull { } public virtual void EnrichRunBatchDispatchCoordinator( Activity activity) { } public virtual void EnrichBatchDispatchError( - Activity activity, - Exception exception) { } + Exception exception, + Activity activity) { } public virtual void EnrichOnSubscriptionEvent( - Activity activity, RequestContext context, - ulong subscriptionId) { } + ulong subscriptionId, + Activity activity) { } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs index ea8300a348d..785291a1891 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityDataLoaderDiagnosticListener.cs @@ -48,7 +48,7 @@ public override void BatchDispatchError(Exception error) activity.SetStatus(ActivityStatusCode.Error); activity.AddException(error); - enricher.EnrichBatchDispatchError(activity, error); + enricher.EnrichBatchDispatchError(error, activity); } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index 9da5972c45d..530135bbb9f 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -57,7 +57,7 @@ public override void RequestError(RequestContext context, Exception error) activity.SetStatus(ActivityStatusCode.Error); activity.AddException(error); - enricher.EnrichRequestError(activity, context, error); + enricher.EnrichRequestError(context, error, activity); } } @@ -70,7 +70,7 @@ public override void RequestError(RequestContext context, IError error) activity.SetStatus(ActivityStatusCode.Error); activity.AddGraphQLError(error); - enricher.EnrichRequestError(activity, context, error); + enricher.EnrichRequestError(context, error, activity); } } @@ -121,7 +121,7 @@ public override void ValidationErrors(RequestContext context, IReadOnlyList` down to the base class: + +```diff +public class CustomActivityEnricher( +- ObjectPool stringBuilderPool, + InstrumentationOptions options +-) : ActivityEnricher(stringBuilderPool, options); ++) : ActivityEnricher(options); +``` + +## OpenTelemetry span and status changes + +The OpenTelemetry spans and attributes emitted by `AddInstrumentation()` have been updated to align with the [proposed OpenTelemetry semantic conventions for GraphQL](https://github.com/graphql/otel-wg/blob/main/spec). If you have dashboards or alerts that filter on the old attribute names or values, update them accordingly. -## Removed attributes +### Removed attributes -| Attribute | -| --------- | -| TODO | +| Attribute | +| ----------------------------- | +| `graphql.operation.id` | +| `graphql.selection.type` | +| `graphql.selection.hierarchy` | ### Renamed attributes @@ -616,13 +638,30 @@ If you have dashboards or alerts that filter on the old attribute names or value | `graphql.selection.field.declaringType` | `graphql.selection.field.parent_type` | | `graphql.dataLoader.keys.count` | `graphql.dataloader.batch.size` | | `graphql.dataLoader.keys` | `graphql.dataloader.batch.keys` | +| `graphql.fusion.node.schema` | `graphql.source.name` | +| `graphql.fusion.node.type` | `graphql.operation.step.kind` | +| `graphql.error.location.line/column` | `graphql.error.locations` | ### Changed attribute values -| Attribute | Old Value | New Value | -| ------------------------ | ------------------------------------- | ------------------------------------- | -| `graphql.operation.type` | `Query` / `Mutation` / `Subscription` | `query` / `mutation` / `subscription` | -| `graphql.http.kind` | `operation-batch` | `operation_batch` | +| Attribute | Old Value | New Value | +| ------------------------ | ------------------------------------- | --------------------------------------------------- | +| `graphql.operation.type` | `Query` / `Mutation` / `Subscription` | `query` / `mutation` / `subscription` | +| `graphql.http.kind` | `operation-batch` | `operation_batch` | +| `graphql.document.hash` | `` | `:` , e.g. `md5:` | +| `graphql.document.id` | - | Value is only set if document is a trusted document | + +## Diagnostic Listeners + +We removed the following methods from the `IExecutionDiagnosticEventListener` since they no longer apply: + +- `ExecuteStream` +- `ExecuteDeferredTask` +- `DispatchBatch` +- `SubscriptionTransportError` +- `SubscriptionEventResult` + +Some other methods also had a change in their signature - simply override them again to fix any compilation issues. # Deprecations From 67734b153cf911c81c08c53772807f865fe94e15 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 15:55:27 +0100 Subject: [PATCH 22/37] Cleanup tests --- .../QueryInstrumentationTests.cs | 120 +--------- .../ServerInstrumentationTests.cs | 74 +------ ...nTests.Allow_Document_To_Be_Captured.snap} | 0 ..._Error_That_Deletes_The_Whole_Result.snap} | 0 ...or_that_deletes_the_whole_result_deep.snap | 69 ------ ...idation_Activity_Has_An_Error_Status.snap} | 0 ...peration_name_is_used_as_request_name.snap | 145 ------------ ...perationName_UsesAnonymousDisplayName.snap | 133 ----------- ...meInRequest_UsedAsActivityDisplayName.snap | 145 ------------ ...ack_Events_Of_A_Simple_Query_Default.snap} | 0 ...ack_events_of_a_simple_query_detailed.snap | 133 ----------- ...mentationTests.Http_Get_SDL_Download.snap} | 0 ..._Post_Add_Variables_To_Http_Activity.snap} | 0 ....Http_Post_Capture_Deferred_Response.snap} | 0 ..._Ensure_List_Path_Is_Correctly_Built.snap} | 0 ...NameInRequest_SetsActivityDisplayName.snap | 201 ----------------- ...entationTests.Http_Post_Parser_Error.snap} | 0 ...ot_Automatically_Added_To_Activities.snap} | 0 ...nTests.Http_Post_With_Extensions_Map.snap} | 0 ...not_automatically_added_to_activities.snap | 185 ---------------- ..._Error_When_Rename_Root_Is_Activated.snap} | 0 ..._Error_When_Rename_Root_Is_Activated.snap} | 0 .../QueryInstrumentationTests.cs | 202 ----------------- .../ServerInstrumentationTests.cs | 70 ------ ...or_That_Deletes_The_Whole_Result_Deep.snap | 69 ------ ...peration_Name_Is_Used_As_Request_Name.snap | 165 -------------- ...perationName_UsesAnonymousDisplayName.snap | 149 ------------- ...meInRequest_UsedAsActivityDisplayName.snap | 165 -------------- ...ack_Events_Of_A_Simple_Query_Detailed.snap | 149 ------------- ...ts_Of_A_Simple_Query_With_Node_Scopes.snap | 149 ------------- ....Http_Post_Add_Query_To_Http_Activity.snap | 189 ---------------- ...NameInRequest_SetsActivityDisplayName.snap | 209 ------------------ ...ntationTests.Http_Post_Single_Request.snap | 15 +- 33 files changed, 30 insertions(+), 2706 deletions(-) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Allow_document_to_be_captured.snap => QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap => QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap} (100%) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap => QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap} (100%) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap => QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap} (100%) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Get_SDL_download.snap => ServerInstrumentationTests.Http_Get_SDL_Download.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap => ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_capture_deferred_response.snap => ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap => ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap} (100%) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_parser_error.snap => ServerInstrumentationTests.Http_Post_Parser_Error.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap => ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_with_extensions_map.snap => ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap} (100%) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap => ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap => ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap} (100%) delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index ea7e15aa44b..7119e100699 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -11,7 +11,7 @@ namespace HotChocolate.Diagnostics; public partial class QueryInstrumentationTests { [Fact] - public async Task Track_events_of_a_simple_query_default() + public async Task Track_Events_Of_A_Simple_Query_Default() { using (CaptureActivities(out var activities)) { @@ -28,7 +28,7 @@ public async Task Track_events_of_a_simple_query_default() } [Fact(Skip = "This test is flaky with the new DL batching.")] - public async Task Track_data_loader_events() + public async Task Track_Data_Loader_Events() { using (CaptureActivities(out var activities)) { @@ -45,7 +45,7 @@ public async Task Track_data_loader_events() } [Fact(Skip = "This test is flaky with the new DL batching.")] - public async Task Track_data_loader_events_with_keys() + public async Task Track_Data_Loader_Events_With_Keys() { using (CaptureActivities(out var activities)) { @@ -62,7 +62,7 @@ public async Task Track_data_loader_events_with_keys() } [Fact] - public async Task Track_events_of_a_simple_query_default_rename_root() + public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() { using (CaptureActivities(out _)) { @@ -79,7 +79,7 @@ public async Task Track_events_of_a_simple_query_default_rename_root() } [Fact] - public async Task Parsing_error_when_rename_root_is_activated() + public async Task Parsing_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out _)) { @@ -96,7 +96,7 @@ public async Task Parsing_error_when_rename_root_is_activated() } [Fact] - public async Task Validation_error_when_rename_root_is_activated() + public async Task Validation_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out _)) { @@ -113,41 +113,7 @@ public async Task Validation_error_when_rename_root_is_activated() } [Fact] - public async Task Track_events_of_a_simple_query_detailed() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Ensure_operation_name_is_used_as_request_name() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("query SayHelloOperation { sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Allow_document_to_be_captured() + public async Task Allow_Document_To_Be_Captured() { using (CaptureActivities(out var activities)) { @@ -168,7 +134,7 @@ public async Task Allow_document_to_be_captured() } [Fact] - public async Task Ensure_that_the_validation_activity_has_an_error_status() + public async Task Ensure_That_The_Validation_Activity_Has_An_Error_Status() { using (CaptureActivities(out var activities)) { @@ -189,7 +155,7 @@ public async Task Ensure_that_the_validation_activity_has_an_error_status() } [Fact] - public async Task Cause_a_resolver_error_that_deletes_the_whole_result() + public async Task Cause_A_Resolver_Error_That_Deletes_The_Whole_Result() { using (CaptureActivities(out var activities)) { @@ -209,40 +175,6 @@ public async Task Cause_a_resolver_error_that_deletes_the_whole_result() } } - [Fact] - public async Task Cause_a_resolver_error_that_deletes_the_whole_result_deep() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => - { - o.Scopes = ActivityScopes.All; - o.IncludeDocument = true; - }) - .AddQueryType() - .ExecuteRequestAsync( - """ - query SayHelloOperation { - deep { - deeper { - deeps { - deeper { - causeFatalError - } - } - } - } - } - """); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task PersistedOperation_LoadsFromStorage_DefaultScopes() { @@ -359,40 +291,6 @@ public async Task CustomScopes_OnlyValidateAndCompile_LimitsSpans() } } - [Fact] - public async Task OperationNameInRequest_UsedAsActivityDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("query MyOp { sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task NoOperationName_UsesAnonymousDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ sayHello }"); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task ResolverError_AtRootLevel_MarksOperationAsError() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index 48dfa6acd0f..da4d49b98d4 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -88,7 +88,7 @@ await server.GetAsync(new ClientQueryRequest } [Fact] - public async Task Http_Post_variables_are_not_automatically_added_to_activities() + public async Task Http_Post_Variables_Are_Not_Automatically_Added_To_Activities() { using (CaptureActivities(out var activities)) { @@ -114,7 +114,7 @@ await server.PostAsync(new ClientQueryRequest } [Fact] - public async Task Http_Post_add_variables_to_http_activity() + public async Task Http_Post_Add_Variables_To_Http_Activity() { using (CaptureActivities(out var activities)) { @@ -144,37 +144,7 @@ await server.PostAsync(new ClientQueryRequest } [Fact] - public async Task Http_Post_add_query_to_http_activity() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateInstrumentedServer( - o => - { - o.Scopes = ActivityScopes.All; - o.RequestDetails = RequestDetails.Default | RequestDetails.OperationName; - }); - - // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" - query ($episode: Episode!) { - hero(episode: $episode) { - name - } - }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } } - }); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Http_Post_with_extensions_map() + public async Task Http_Post_With_Extensions_Map() { using (CaptureActivities(out var activities)) { @@ -201,7 +171,7 @@ await server.PostAsync(new ClientQueryRequest } [Fact] - public async Task Http_Get_SDL_download() + public async Task Http_Get_SDL_Download() { using (CaptureActivities(out var activities)) { @@ -222,7 +192,7 @@ public async Task Http_Get_SDL_download() } [Fact] - public async Task Http_Post_capture_deferred_response() + public async Task Http_Post_Capture_Deferred_Response() { using (CaptureActivities(out var activities)) { @@ -251,7 +221,7 @@ ... on Droid @defer(label: "my_id") { } [Fact] - public async Task Http_Post_ensure_list_path_is_correctly_built() + public async Task Http_Post_Ensure_List_Path_Is_Correctly_Built() { using (CaptureActivities(out var activities)) { @@ -286,7 +256,7 @@ await server.PostRawAsync(new ClientQueryRequest } [Fact] - public async Task Http_Post_parser_error() + public async Task Http_Post_Parser_Error() { using (CaptureActivities(out var activities)) { @@ -322,7 +292,7 @@ await server.PostRawAsync(new ClientQueryRequest } [Fact] - public async Task Parsing_error_when_rename_root_is_activated() + public async Task Parsing_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out var activities)) { @@ -346,7 +316,7 @@ await server.PostRawAsync(new ClientQueryRequest } [Fact] - public async Task Validation_error_when_rename_root_is_activated() + public async Task Validation_Error_When_Rename_Root_Is_Activated() { using (CaptureActivities(out var activities)) { @@ -485,32 +455,6 @@ query GetHero { } } - [Fact] - public async Task Http_Post_OperationNameInRequest_SetsActivityDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateInstrumentedServer( - o => o.Scopes = ActivityScopes.All); - - // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" - query GetHeroByEpisode($episode: Episode!) { - hero(episode: $episode) { - name - } - }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } } - }); - - // assert - activities.MatchSnapshot(); - } - } - private TestServer CreateInstrumentedServer( Action? options = null) => CreateStarWarsServer( diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_document_to_be_captured.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap deleted file mode 100644 index 1a25c0b220d..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_a_resolver_error_that_deletes_the_whole_result_deep.snap +++ /dev/null @@ -1,69 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `causeFatalError` does not exist on the type `Deeper`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 6, - "column": 21 - } - ] - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_that_the_validation_activity_has_an_error_status.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap deleted file mode 100644 index 3a98c0e8fa6..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_operation_name_is_used_as_request_name.snap +++ /dev/null @@ -1,145 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [], - "activities": [ - { - "OperationName": "SimpleQuery.sayHello", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.path", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap deleted file mode 100644 index 49f7e009662..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap +++ /dev/null @@ -1,133 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "SimpleQuery.sayHello", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.path", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap deleted file mode 100644 index c80085b8eb2..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap +++ /dev/null @@ -1,145 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [], - "activities": [ - { - "OperationName": "SimpleQuery.sayHello", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.path", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_default.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap deleted file mode 100644 index 49f7e009662..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_events_of_a_simple_query_detailed.snap +++ /dev/null @@ -1,133 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "SimpleQuery.sayHello", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.path", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_download.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_variables_to_http_activity.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_capture_deferred_response.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_ensure_list_path_is_correctly_built.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap deleted file mode 100644 index 5062a1fc85c..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap +++ /dev/null @@ -1,201 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Variable Coercion", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetHeroByEpisode" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:2c13f23738dd0ee7712bcb326e40ca72" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Query.hero", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_parser_error.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_add_query_to_http_activity.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_with_extensions_map.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap deleted file mode 100644 index e9750924864..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_variables_are_not_automatically_added_to_activities.snap +++ /dev/null @@ -1,185 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [ - { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Variable Coercion", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Query.hero", - "DisplayName": "Query.hero", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.path", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.name", - "Value": "hero" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "Query.hero" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "Query" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_error_when_rename_root_is_activated.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_error_when_rename_root_is_activated.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index a6565a825a1..41f31933895 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -135,68 +135,6 @@ public async Task Validation_Error_When_Rename_Root_Is_Activated() } } - [Fact] - public async Task Track_Events_Of_A_Simple_Query_Detailed() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Ensure_Operation_Name_Is_Used_As_Request_Name() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("query SayHelloOperation { sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Allow_Document_To_Be_Captured() { @@ -299,84 +237,6 @@ public async Task Cause_A_Resolver_Error_That_Deletes_The_Whole_Result() } } - [Fact] - public async Task Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - { - o.Scopes = FusionActivityScopes.All; - o.IncludeDocument = true; - })); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument( - """ - query SayHelloOperation { - deep { - deeper { - deeps { - deeper { - causeFatalError - } - } - } - } - } - """) - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Track_Events_Of_A_Simple_Query_With_Node_Scopes() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Source_Schema_Transport_Error() { @@ -636,68 +496,6 @@ public async Task CustomScopes_OnlyValidateAndPlan_LimitsSpans() } } - [Fact] - public async Task OperationNameInRequest_UsedAsActivityDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("query MyOp { sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task NoOperationName_UsesAnonymousDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b.AddInstrumentation(o => - o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task MultipleSources_HttpRequestError_MarksNodeSpanAsError() { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index 3c7bafb8774..a423d1c7eeb 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -161,43 +161,6 @@ public async Task Http_Post_Add_Variables_To_Http_Activity() } } - [Fact] - public async Task Http_Post_Add_Query_To_Http_Activity() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [("a", server)], - configureGatewayBuilder: b => b.AddInstrumentation( - o => - { - o.Scopes = FusionActivityScopes.All; - o.RequestDetails = RequestDetails.Default | RequestDetails.OperationName; - })); - - using var client = GraphQLHttpClient.Create(gateway.CreateClient()); - - var request = new OperationRequest( - query: """ - query ($name: String!) { - greeting(name: $name) - } - """, - variables: new Dictionary { { "name", "World" } }); - - // act - using var result = await client.PostAsync(request, s_url); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Http_Post_With_Extensions_Map() { @@ -523,39 +486,6 @@ query GetGreeting { } } - [Fact] - public async Task Http_Post_OperationNameInRequest_SetsActivityDisplayName() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [("a", server)], - configureGatewayBuilder: b => b.AddInstrumentation( - o => o.Scopes = FusionActivityScopes.All)); - - using var client = GraphQLHttpClient.Create(gateway.CreateClient()); - - var request = new OperationRequest( - query: """ - query GetGreetingByName($name: String!) { - greeting(name: $name) - } - """, - variables: new Dictionary { { "name", "World" } }); - - // act - using var result = await client.PostAsync(request, s_url); - - // assert - activities.MatchSnapshot(); - } - } - public class Query { public string SayHello() => "hello"; diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap deleted file mode 100644 index 1a25c0b220d..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result_Deep.snap +++ /dev/null @@ -1,69 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - }, - { - "Key": "graphql.document.body", - "Value": "query SayHelloOperation {\n deep {\n deeper {\n deeps {\n deeper {\n causeFatalError\n }\n }\n }\n }\n}" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:803df9346db185e9dc0b22dd3909aa70" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `causeFatalError` does not exist on the type `Deeper`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 6, - "column": 21 - } - ] - } - ] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap deleted file mode 100644 index a84aa0b3fcb..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_Operation_Name_Is_Used_As_Request_Name.snap +++ /dev/null @@ -1,165 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "1334fb0da1250c6db5db84b6c98ccb2556f066942f8836d6ebd18fd870172787" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "SayHelloOperation_6af18618_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:80b0d05aefd2459dcda18d0e26977b91c512e4ef58ab3e4e8a82c1ec98249b58" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap deleted file mode 100644 index 33b122e09fc..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.NoOperationName_UsesAnonymousDisplayName.snap +++ /dev/null @@ -1,149 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap deleted file mode 100644 index 250e9873a59..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.OperationNameInRequest_UsedAsActivityDisplayName.snap +++ /dev/null @@ -1,165 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "MyOp" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cb42fac0ac6021461c1538f843ffe88c" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "a98170628f191ebff09f0fb9fb2dfbe571198d565b457fa166c0b4efe3bc9e20" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "MyOp_cb42fac0_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a490aca65a3bd8d348ab10c71053c9bcdda1f81c52c1106d66e112d2e56d36e9" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap deleted file mode 100644 index 33b122e09fc..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Detailed.snap +++ /dev/null @@ -1,149 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap deleted file mode 100644 index 33b122e09fc..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_With_Node_Scopes.snap +++ /dev/null @@ -1,149 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - } - ], - "event": [] - } - ] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap deleted file mode 100644 index 3d7a83ab9da..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Query_To_Http_Activity.snap +++ /dev/null @@ -1,189 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Variable Coercion", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "d58281f7cf44ca2751c4a435c0249e686bd1c146f6ddae23ed35ec6e4b83eb77" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_c46cf8c9_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:a6738007b3546a7458414ee647c93aa373bc22ca57256f4a4a5c8ef3aa886470" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap deleted file mode 100644 index 5ba7e372b41..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_OperationNameInRequest_SetsActivityDisplayName.snap +++ /dev/null @@ -1,209 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Variable Coercion", - "DisplayName": "GraphQL Variable Coercion", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "variable_coercion" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.operation.name", - "Value": "GetGreetingByName" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:4f33a60d4ccb822195345aaf7258b649" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "ca1b7ddc139a796427bb8f038fd7b1d78e4b678141df887304f916363259661d" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "GetGreetingByName_4f33a60d_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:4edb6cbcb2c1a6f3b39ac971526043d760b69a6d2dc5324a9cdbce30a3e786b1" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 7cdab36908c..4aba82a22e4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,9 +2,18 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "ExecuteHttpRequest", - "Status": "Unset", - "tags": [], + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + } + ], "event": [], "activities": [ { From 64caa2c1336677155e3256b940a0fa1ea6c1195b Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:47:34 +0100 Subject: [PATCH 23/37] Fix snapshots --- .../Spans/Http/ExecuteHttpRequestSpan.cs | 10 +- .../Diagnostics.Tests/ActivityTestHelper.cs | 2 +- .../QueryInstrumentationTests.cs | 21 ++ ...ityAnalysis_Enabled_RecordsCostInSpan.snap | 8 + ...oader_BatchExecution_RecordsBatchSpan.snap | 4 + ...hExecution_With_Keys_RecordsBatchSpan.snap | 192 ++++++++++++++++++ ...umentationTests.Http_Get_SDL_Download.snap | 4 + ...ts.Http_Get_SingleRequest_GetHeroName.snap | 16 ++ ...p_Post_Add_Variables_To_Http_Activity.snap | 20 ++ ...s.Http_Post_Capture_Deferred_Response.snap | 20 ++ ...t_Ensure_List_Path_Is_Correctly_Built.snap | 20 ++ ...mentationTests.Http_Post_Parser_Error.snap | 4 + ...s.Http_Post_SingleRequest_GetHeroName.snap | 20 ++ ...ost_SingleRequest_GetHeroName_Default.snap | 12 ++ ...Not_Automatically_Added_To_Activities.snap | 20 ++ ...onTests.Http_Post_With_Extensions_Map.snap | 20 ++ ...g_Error_When_Rename_Root_Is_Activated.snap | 4 + ...RequestDetails_All_IncludesAllDetails.snap | 20 ++ ...IncludesIdHashOperationNameExtensions.snap | 20 ++ ...ails_DocumentOnly_IncludesDocumentTag.snap | 12 ++ ...equestDetails_None_ExcludesAllDetails.snap | 12 ++ ...n_Error_When_Rename_Root_Is_Activated.snap | 12 ++ ...umentationTests.Http_Get_SDL_Download.snap | 4 + ...entationTests.Http_Get_Single_Request.snap | 8 + ...p_Post_Add_Variables_To_Http_Activity.snap | 12 ++ ...mentationTests.Http_Post_Parser_Error.snap | 4 + ...ntationTests.Http_Post_Single_Request.snap | 15 +- ...ests.Http_Post_Single_Request_Default.snap | 12 ++ ...Not_Automatically_Added_To_Activities.snap | 12 ++ ...onTests.Http_Post_With_Extensions_Map.snap | 12 ++ ...g_Error_When_Rename_Root_Is_Activated.snap | 4 + ...RequestDetails_All_IncludesAllDetails.snap | 12 ++ ...IncludesIdHashOperationNameExtensions.snap | 12 ++ ...ails_DocumentOnly_IncludesDocumentTag.snap | 4 + ...equestDetails_None_ExcludesAllDetails.snap | 4 + ...n_Error_When_Rename_Root_Is_Activated.snap | 12 ++ 36 files changed, 582 insertions(+), 18 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index f44242a4e56..eacda017ef0 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -47,7 +47,7 @@ internal sealed class ExecuteHttpRequestSpan( break; } - activity.SetTag(GraphQL.Http.Kind, kind); + activity.SetTag(GraphQL.Http.Kind, kind.ToString()); if (!(httpContext.Items.TryGetValue(SchemaName, out var value) && value is string schemaName)) @@ -67,13 +67,13 @@ public void SetSingleRequestDetails(GraphQLRequest request) if (request.DocumentId is not null && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value.Value); } if (request.DocumentHash is not null && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value.Value); } if (request.Document is not null @@ -178,13 +178,13 @@ public void SetOperationBatchRequestDetails( if (request.DocumentId is not null && (options.RequestDetails & RequestDetails.Id) == RequestDetails.Id) { - Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value); + Activity.SetTag(GraphQL.Http.Request.QueryId, request.DocumentId.Value.Value); } if (request.DocumentHash is not null && (options.RequestDetails & RequestDetails.Hash) == RequestDetails.Hash) { - Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value); + Activity.SetTag(GraphQL.Http.Request.QueryHash, request.DocumentHash.Value.Value); } if (request.Document is not null diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs index 783ca73a4fc..7e22981dc86 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs @@ -75,7 +75,7 @@ private static void SerializeActivity(Activity activity) data["OperationName"] = activity.OperationName; data["DisplayName"] = activity.DisplayName; data["Status"] = activity.Status; - data["tags"] = activity.Tags; + data["tags"] = activity.TagObjects; data["event"] = activity.Events.Select(t => new { t.Name, t.Tags }); } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index 7119e100699..a0e744cabb2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -382,6 +382,27 @@ public async Task DataLoader_BatchExecution_RecordsBatchSpan() } } + [Fact] + public async Task DataLoader_BatchExecution_With_Keys_RecordsBatchSpan() + { + using (CaptureActivities(out var activities)) + { + // arrange & act + await new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => + { + o.Scopes = ActivityScopes.All; + o.IncludeDataLoaderKeys = true; + }) + .AddQueryType() + .ExecuteRequestAsync("{ dataLoader(key: \"abc\") }"); + + // assert + activities.MatchSnapshot(); + } + } + [Fact] public async Task VariableCoercion_WithAllScopes_RecordsCoercionSpan() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap index b102cd0a9fe..4051715f9f3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap @@ -61,6 +61,14 @@ { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 0.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 1.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap index 12f52991c63..3a1922dc668 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap @@ -168,6 +168,10 @@ { "Key": "graphql.dataloader.name", "Value": "CustomDataLoader" + }, + { + "Key": "graphql.dataloader.batch.size", + "Value": 1 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap new file mode 100644 index 00000000000..f36210d5447 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap @@ -0,0 +1,192 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "query", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "query" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:9b20745108c8de5afccc35cd56ead9fc" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleQuery.dataLoader", + "DisplayName": "SimpleQuery.dataLoader", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.path", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.field.name", + "Value": "dataLoader" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleQuery.dataLoader" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleQuery" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL DataLoader Dispatch", + "DisplayName": "GraphQL DataLoader Dispatch", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_dispatch" + } + ], + "event": [ + { + "Name": "BatchEvaluated", + "Tags": [ + { + "Key": "openBatches", + "Value": 1 + } + ] + }, + { + "Name": "BatchDispatched", + "Tags": [ + { + "Key": "dispatchedBatches", + "Value": 1 + } + ] + } + ], + "activities": [ + { + "OperationName": "GraphQL DataLoader Batch CustomDataLoader", + "DisplayName": "GraphQL DataLoader Batch CustomDataLoader", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "dataloader_batch" + }, + { + "Key": "graphql.dataloader.name", + "Value": "CustomDataLoader" + }, + { + "Key": "graphql.dataloader.batch.size", + "Value": 1 + }, + { + "Key": "graphql.dataloader.batch.keys", + "Value": [ + "abc" + ] + } + ], + "event": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap index 1669a6a2090..d77edd7831a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP GET SDL", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpGetSchema" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 8b7ebe7e9b2..713e98f51a8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP GET", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpGet" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,10 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "530cb46cabc38757c74c05cc7a96b636" } ], "event": [], @@ -72,6 +80,14 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 37f00469d69..5c530e48e0b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "1d4bca4d0dff630390ddf48e9085589d" + }, { "Key": "graphql.http.request.variables", "Value": "{\"episode\":\"NEW_HOPE\"}" @@ -76,6 +88,14 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap index bd2c4c1ccef..ce7db6b67d8 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "dd31323224a6428d4dc301134352aeab" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "dd31323224a6428d4dc301134352aeab" } ], "event": [], @@ -72,6 +84,14 @@ { "Key": "graphql.document.hash", "Value": "md5:3beaca4ee1714ac9c9dfec8e445529df" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap index 147b908927b..3e6d5af113d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "c0513b4b6f0cf7430f64de4aa3dcd7c6" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "c0513b4b6f0cf7430f64de4aa3dcd7c6" } ], "event": [], @@ -72,6 +84,14 @@ { "Key": "graphql.document.hash", "Value": "md5:668e9631148921208d08dbb69513fa8e" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index 12163143e55..774711bad83 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 874ef70b943..40aa5c93eff 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "a570a6bff748b5916eadf153261d9c6d" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "a570a6bff748b5916eadf153261d9c6d" } ], "event": [], @@ -72,6 +84,14 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap index e897b8cfb22..007fefef81a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap @@ -5,6 +5,10 @@ "DisplayName": "query", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "a570a6bff748b5916eadf153261d9c6d" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "a570a6bff748b5916eadf153261d9c6d" + }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index e9750924864..26d34ef6b06 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "1d4bca4d0dff630390ddf48e9085589d" } ], "event": [], @@ -72,6 +84,14 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 4beeebc258b..4f131c64baa 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "1d4bca4d0dff630390ddf48e9085589d" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "1d4bca4d0dff630390ddf48e9085589d" + }, { "Key": "graphql.http.request.extensions", "Value": "{\"test\":\"abc\"}" @@ -76,6 +88,14 @@ { "Key": "graphql.document.hash", "Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index 82a6b94e61b..4a420c1e099 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index b83ba8ff2fd..0e3d5f442e1 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "b45805c675e9fff20b0367e5ff31735f" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "b45805c675e9fff20b0367e5ff31735f" + }, { "Key": "graphql.http.request.query.body", "Value": "query GetHero(\n $episode: Episode!\n) {\n hero(episode: $episode) {\n name\n }\n}" @@ -88,6 +100,14 @@ { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index 18131e1c576..77960a6c701 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "029e67e1b2d8493b3dd23fdaf6545b03" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "029e67e1b2d8493b3dd23fdaf6545b03" + }, { "Key": "graphql.http.request.extensions", "Value": "{\"test\":\"abc\"}" @@ -80,6 +92,14 @@ { "Key": "graphql.document.hash", "Value": "md5:06731ff10fea3ec8e9b2aabceee6ddd9" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index 11bf49462dc..53d55baf6ff 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -76,6 +80,14 @@ { "Key": "graphql.document.hash", "Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index 9fa0b533d02..f10663b143d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -72,6 +76,14 @@ { "Key": "graphql.document.hash", "Value": "md5:9335388c19fd2e230b6294a596d13a93" + }, + { + "Key": "graphql.operation.fieldCost", + "Value": 1.0 + }, + { + "Key": "graphql.operation.typeCost", + "Value": 2.0 } ], "event": [] diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index ce98da6bec0..ab527170e1a 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "e2b13c5332af8a70da160fcb96894e5c" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "e2b13c5332af8a70da160fcb96894e5c" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap index 1669a6a2090..d77edd7831a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP GET SDL", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpGetSchema" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 8bf42f82815..0d6da976091 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP GET", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpGet" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,10 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index e8e9d5461ea..f845b72beb9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" + }, { "Key": "graphql.http.request.variables", "Value": "{\"name\":\"World\"}" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap index b0d6d9b7444..955f4d24f0c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 4aba82a22e4..7cdab36908c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,18 +2,9 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - } - ], + "DisplayName": "ExecuteHttpRequest", + "Status": "Unset", + "tags": [], "event": [], "activities": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index ce5aedb5061..a469528f931 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -5,6 +5,10 @@ "DisplayName": "query", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, { "Key": "graphql.operation.type", "Value": "query" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 3d7a83ab9da..cb6a3165688 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 415a5878598..36086806591 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "bfa5986a5299f46421057dd3eb27ec5c" + }, { "Key": "graphql.http.request.extensions", "Value": "{\"test\":\"abc\"}" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap index fde78095229..73a68f7b51e 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index 7633cb0dece..63c7c8fad4a 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "08c6969c8d553f85d6541aa54ef01acb" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "08c6969c8d553f85d6541aa54ef01acb" + }, { "Key": "graphql.http.request.query.body", "Value": "query GetGreeting(\n $name: String!\n) {\n greeting(name: $name)\n}" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index a243603489f..4b054bfe817 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -13,6 +17,14 @@ "Key": "graphql.http.request.type", "Value": "single" }, + { + "Key": "graphql.http.request.query.id", + "Value": "82d594dc9843e825769c127e8ae2db6f" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "82d594dc9843e825769c127e8ae2db6f" + }, { "Key": "graphql.http.request.extensions", "Value": "{\"test\":\"abc\"}" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index e9183e48061..73521356758 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index b8150e5e921..7cc2c859b04 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap index 3e03450d58a..f9ba644115b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap @@ -5,6 +5,10 @@ "DisplayName": "GraphQL HTTP POST", "Status": "Ok", "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, { "Key": "graphql.schema.name", "Value": "_Default" @@ -12,6 +16,14 @@ { "Key": "graphql.http.request.type", "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "346f68539881f0624dca2927281d1a2f" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "346f68539881f0624dca2927281d1a2f" } ], "event": [], From 0b7418cfd195830fe7d1f13f44d9cd363bc8b30f Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 16:54:51 +0100 Subject: [PATCH 24/37] Mark flaky tests --- .../QueryInstrumentationTests.cs | 34 ------------------- .../QueryInstrumentationTests.cs | 2 +- .../ServerInstrumentationTests.cs | 30 ---------------- 3 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index a0e744cabb2..a3b334bc1ca 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -27,40 +27,6 @@ public async Task Track_Events_Of_A_Simple_Query_Default() } } - [Fact(Skip = "This test is flaky with the new DL batching.")] - public async Task Track_Data_Loader_Events() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation() - .AddQueryType() - .ExecuteRequestAsync("{ dataLoader(key: \"abc\") }"); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact(Skip = "This test is flaky with the new DL batching.")] - public async Task Track_Data_Loader_Events_With_Keys() - { - using (CaptureActivities(out var activities)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.IncludeDataLoaderKeys = true) - .AddQueryType() - .ExecuteRequestAsync("{ dataLoader(key: \"abc\") }"); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index 41f31933895..fbea39b591f 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -496,7 +496,7 @@ public async Task CustomScopes_OnlyValidateAndPlan_LimitsSpans() } } - [Fact] + [Fact(Skip = "This is flaky")] public async Task MultipleSources_HttpRequestError_MarksNodeSpanAsError() { using (CaptureActivities(out var activities)) diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index a423d1c7eeb..a404ffff6c8 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -222,36 +222,6 @@ public async Task Http_Get_SDL_Download() } } - [Fact(Skip = "Not yet implemented")] - public async Task Http_Post_Capture_Deferred_Response() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [("a", server)], - configureGatewayBuilder: b => b.AddInstrumentation( - o => o.Scopes = FusionActivityScopes.All)); - - using var client = GraphQLHttpClient.Create(gateway.CreateClient()); - - var request = new OperationRequest( - """ - TODO - """); - - // act - using var result = await client.PostAsync(request, s_url); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task Http_Post_Parser_Error() { From 6fa230e17796737d6f426859b52ea76bf9978804 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:12:53 +0100 Subject: [PATCH 25/37] Small refactorings --- .../Extensions/ActivityExtensions.cs | 38 ++++++++++++++ .../Extensions/DocumentNodeExtensions.cs | 51 ------------------- .../Spans/AnalyzeOperationComplexitySpan.cs | 13 +---- .../Spans/ExecuteOperationSpan.cs | 21 +------- .../Spans/ExecuteRequestSpanBase.cs | 24 +++++---- .../src/Diagnostics.Core/Spans/ParsingSpan.cs | 19 +++---- .../Diagnostics.Core/Spans/ValidationSpan.cs | 13 +---- .../Spans/VariableCoercionSpan.cs | 21 +------- .../Diagnostics/Spans/CompileOperationSpan.cs | 21 +------- .../Diagnostics/Spans/ExecuteRequestSpan.cs | 25 +++++---- .../Spans/ExecutePlanNodeSpan.cs | 24 +-------- .../Spans/ExecuteRequestSpan.cs | 27 +++++----- .../Spans/PlanOperationSpan.cs | 35 +------------ 13 files changed, 95 insertions(+), 237 deletions(-) delete mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs index 118742248b1..e49fc39b11e 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs @@ -1,4 +1,7 @@ using System.Diagnostics; +using System.Runtime.CompilerServices; +using HotChocolate.Execution; +using HotChocolate.Language; namespace HotChocolate.Diagnostics; @@ -63,5 +66,40 @@ public void AddGraphQLError(IError error) activity.AddEvent(new ActivityEvent("exception", default, tags)); } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void EnrichDocumentInfo(OperationDocumentInfo documentInfo) + { + var hash = documentInfo.Hash; + + if (!hash.IsEmpty) + { + activity.SetTag( + SemanticConventions.GraphQL.Document.Hash, + $"{hash.AlgorithmName}:{hash.Value}"); + } + + if (documentInfo is { IsPersisted: true, Id.HasValue: true }) + { + activity.SetTag( + SemanticConventions.GraphQL.Document.Id, + documentInfo.Id.Value); + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void EnrichOperation(OperationType operationType, string? operationName) + { + activity.SetTag( + SemanticConventions.GraphQL.Operation.Type, + SemanticConventions.GraphQL.Operation.TypeValues[operationType]); + + if (!string.IsNullOrEmpty(operationName)) + { + activity.SetTag( + SemanticConventions.GraphQL.Operation.Name, + operationName); + } + } } } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs deleted file mode 100644 index a9f5032718e..00000000000 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/DocumentNodeExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -using HotChocolate.Language; - -namespace HotChocolate.Diagnostics; - -internal static class DocumentNodeExtensions -{ - public static OperationDefinitionNode? GetOperation( - this DocumentNode document, - string? operationName) - { - if (string.IsNullOrEmpty(operationName)) - { - OperationDefinitionNode? operation = null; - var definitions = document.Definitions; - var length = definitions.Count; - - for (var i = 0; i < length; i++) - { - if (definitions[i] is not OperationDefinitionNode op) - { - continue; - } - - if (operation is null) - { - operation = op; - } - else - { - // More than one operation in document. - return null; - } - } - - return operation; - } - else - { - for (var i = 0; i < document.Definitions.Count; i++) - { - if (document.Definitions[i] is OperationDefinitionNode { Name: not null } op - && op.Name!.Value.Equals(operationName, StringComparison.Ordinal)) - { - return op; - } - } - - return null; - } - } -} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index 3352eae5432..c29af40ae8c 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -23,18 +23,7 @@ internal sealed class AnalyzeOperationComplexitySpan( return null; } - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new AnalyzeOperationComplexitySpan(activity, context, enricher); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs index 15fedecd622..50d3604bc2b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteOperationSpan.cs @@ -27,25 +27,8 @@ internal sealed class ExecuteOperationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichOperation(operationType, operationName); + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new ExecuteOperationSpan(activity, context, enricher); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs index ddf666fc420..02e61a0bea1 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using HotChocolate.Execution; +using HotChocolate.Language; using HotChocolate.Language.Utilities; using static HotChocolate.Diagnostics.SemanticConventions; @@ -19,8 +20,19 @@ internal abstract class ExecuteRequestSpanBase( return source.StartActivity("GraphQL Operation", ActivityKind.Server); } + protected abstract bool TryGetOperationInfo( + out OperationType operationType, + out string? operationName); + protected override void OnComplete() { + if (TryGetOperationInfo(out var operationType, out var operationName)) + { + var operationTypeValue = GraphQL.Operation.TypeValues[operationType]; + Activity.DisplayName = operationTypeValue; + Activity.EnrichOperation(operationType, operationName); + } + if (Activity.Status != ActivityStatusCode.Error) { Activity.SetStatus(ActivityStatusCode.Ok); @@ -28,17 +40,7 @@ protected override void OnComplete() var documentInfo = Context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + Activity.EnrichDocumentInfo(documentInfo); if (options.IncludeDocument && documentInfo.Document is not null) { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index 68d7ae28fd7..a7603636970 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -22,6 +22,12 @@ internal sealed class ParsingSpan( return null; } + // We do not set this here, as parsing can happen in the HTTP middleware + // or the HotChocolate pipeline. + // For the moment we just track both as regular spans. + // Maybe in the future we can reconcile this. + // activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Parse); + return new ParsingSpan(activity, context, enricher); } @@ -32,18 +38,7 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); } - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - Activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - Activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + Activity.EnrichDocumentInfo(context.OperationDocumentInfo); enricher.EnrichParseDocument(context, Activity); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index f27b15bdffd..dcd10f77f35 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -24,18 +24,7 @@ internal sealed class ValidationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Validate); - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new ValidationSpan(activity, context, enricher); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs index a26ed09a4ed..c54786d9387 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/VariableCoercionSpan.cs @@ -27,25 +27,8 @@ internal sealed class VariableCoercionSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.VariableCoercion); - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichOperation(operationType, operationName); + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new VariableCoercionSpan(activity, context, enricher); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs index 916cd319fe5..78d40a07a6b 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/CompileOperationSpan.cs @@ -23,18 +23,7 @@ internal sealed class CompileOperationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new CompileOperationSpan(activity, context, enricher); } @@ -45,13 +34,7 @@ protected override void OnComplete() { Activity.SetStatus(ActivityStatusCode.Ok); - Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Kind]); - - var operationName = operation.Name; - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } + Activity.EnrichOperation(operation.Kind, operation.Name); } enricher.EnrichCompileOperation(context, Activity); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs index fc98a8d711c..8a60d10a264 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Spans/ExecuteRequestSpan.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using HotChocolate.Execution; -using static HotChocolate.Diagnostics.SemanticConventions; +using HotChocolate.Language; namespace HotChocolate.Diagnostics; @@ -9,7 +9,8 @@ internal sealed class ExecuteRequestSpan( RequestContext context, InstrumentationOptionsBase options, ActivityEnricherBase? enricher, - bool shouldDisposeActivity) : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) + bool shouldDisposeActivity) + : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) { public static ExecuteRequestSpan? Start( ActivitySource source, @@ -32,21 +33,19 @@ internal sealed class ExecuteRequestSpan( true); } - protected override void OnComplete() + protected override bool TryGetOperationInfo( + out OperationType operationType, + out string? operationName) { if (Context.TryGetOperation(out var operation)) { - var operationType = GraphQL.Operation.TypeValues[operation.Kind]; - Activity.SetTag(GraphQL.Operation.Type, operationType); - Activity.DisplayName = operationType; - - var operationName = operation.Name; - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } + operationType = operation.Kind; + operationName = operation.Name; + return true; } - base.OnComplete(); + operationType = default; + operationName = null; + return false; } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs index 7845a4a93da..c3f7b26f4fe 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecutePlanNodeSpan.cs @@ -41,28 +41,8 @@ internal sealed class ExecutePlanNodeSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.StepExecute); var operation = context.OperationPlan.Operation; - var operationType = operation.Definition.Operation; - var operationName = operation.Name; - - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - - var documentInfo = context.RequestContext.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichOperation(operation.Definition.Operation, operation.Name); + activity.EnrichDocumentInfo(context.RequestContext.OperationDocumentInfo); activity.SetTag(GraphQL.Operation.Step.Id, node.Id.ToString(CultureInfo.InvariantCulture)); activity.SetTag(GraphQL.Operation.Step.Kind, KindValues[node.Type]); diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs index efcd94ecfc2..ab6e528af29 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/ExecuteRequestSpan.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using HotChocolate.Execution; -using static HotChocolate.Diagnostics.SemanticConventions; +using HotChocolate.Language; namespace HotChocolate.Diagnostics; @@ -9,7 +9,8 @@ internal sealed class ExecuteRequestSpan( RequestContext context, InstrumentationOptionsBase options, ActivityEnricherBase? enricher, - bool shouldDisposeActivity) : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) + bool shouldDisposeActivity) + : ExecuteRequestSpanBase(activity, context, options, enricher, shouldDisposeActivity) { public static ExecuteRequestSpan? Start( ActivitySource source, @@ -32,21 +33,19 @@ internal sealed class ExecuteRequestSpan( true); } - protected override void OnComplete() + protected override bool TryGetOperationInfo( + out OperationType operationType, + out string? operationName) { - if (Context.GetOperationPlan() is { Operation: var operation}) + if (Context.GetOperationPlan() is { Operation: var operation }) { - var operationType = GraphQL.Operation.TypeValues[operation.Definition.Operation]; - Activity.SetTag(GraphQL.Operation.Type, operationType); - Activity.DisplayName = operationType; - - var operationName = operation.Name; - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } + operationType = operation.Definition.Operation; + operationName = operation.Name; + return true; } - base.OnComplete(); + operationType = default; + operationName = null; + return false; } } diff --git a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs index fda680e2ea6..0fb245e03d8 100644 --- a/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs +++ b/src/HotChocolate/Fusion-vnext/src/Fusion.Diagnostics/Spans/PlanOperationSpan.cs @@ -26,30 +26,7 @@ internal sealed class PlanOperationSpan( activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Plan); - if (context.TryGetDocument(out var document, out _) - && document.GetOperation(context.Request.OperationName) is { } operation) - { - activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operation.Operation]); - - var operationName = operation.Name?.Value; - if (!string.IsNullOrEmpty(operationName)) - { - activity.SetTag(GraphQL.Operation.Name, operationName); - } - } - - var documentInfo = context.OperationDocumentInfo; - var hash = documentInfo.Hash; - - if (!hash.IsEmpty) - { - activity.SetTag(GraphQL.Document.Hash, $"{hash.AlgorithmName}:{hash.Value}"); - } - - if (documentInfo is { IsPersisted: true, Id.HasValue: true }) - { - activity.SetTag(GraphQL.Document.Id, documentInfo.Id.Value); - } + activity.EnrichDocumentInfo(context.OperationDocumentInfo); return new PlanOperationSpan(activity, context, enricher, operationPlanId); } @@ -61,15 +38,7 @@ protected override void OnComplete() Activity.SetStatus(ActivityStatusCode.Ok); var operation = plan.Operation; - var operationType = operation.Definition.Operation; - var operationName = operation.Name; - - Activity.SetTag(GraphQL.Operation.Type, GraphQL.Operation.TypeValues[operationType]); - - if (!string.IsNullOrEmpty(operationName)) - { - Activity.SetTag(GraphQL.Operation.Name, operationName); - } + Activity.EnrichOperation(operation.Definition.Operation, operation.Name); } enricher.EnrichPlanOperation(context, operationPlanId, Activity); From e874d3752cbd59bb38018ef06c14a5f6a81fe2cf Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:21:57 +0100 Subject: [PATCH 26/37] Update snapshots --- .../test/Execution.Tests/ArgumentNonNullValidatorTests.cs | 2 +- ...ectiveTypeTests.Directive_ValidateArgs_ArgMissing.snap | 2 +- ...ectiveTypeTests.Directive_ValidateArgs_InvalidArg.snap | 2 +- ...TypeTests.Directive_ValidateArgs_NonNullArgIsNull.snap | 2 +- ...irectiveTypeTests.Directive_ValidateArgs_Overflow.snap | 2 +- ...ryInstrumentationTests.AllScopes_IncludesAllSpans.snap | 8 ++++---- ...nstrumentationTests.Allow_Document_To_Be_Captured.snap | 8 ++++---- ...se_A_Resolver_Error_That_Deletes_The_Whole_Result.snap | 8 ++++---- ...ests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap | 8 ++++---- ...copes_ExcludesExecuteRequestAndParseDocumentSpans.snap | 8 ++++---- ...ocumentCache_SecondExecution_RecordsCacheHitEvent.snap | 8 ++++---- ...ourceSchemaResolverError_RecordsDeeplyNestedError.snap | 8 ++++---- ...PersistedOperation_LoadsFromStorage_DefaultScopes.snap | 8 ++++---- ...nstrumentationTests.Source_Schema_Transport_Error.snap | 8 ++++---- ...sts.Track_Events_Of_A_Query_With_Multiple_Sources.snap | 8 ++++---- ...ationTests.Track_Events_Of_A_Simple_Query_Default.snap | 8 ++++---- ...erverInstrumentationTests.Http_Get_Single_Request.snap | 8 ++++---- ...ionTests.Http_Post_Add_Variables_To_Http_Activity.snap | 8 ++++---- ...rverInstrumentationTests.Http_Post_Single_Request.snap | 8 ++++---- ...rumentationTests.Http_Post_Single_Request_Default.snap | 8 ++++---- ...riables_Are_Not_Automatically_Added_To_Activities.snap | 8 ++++---- ...nstrumentationTests.Http_Post_With_Extensions_Map.snap | 8 ++++---- ...tationTests.RequestDetails_All_IncludesAllDetails.snap | 8 ++++---- ...ils_Default_IncludesIdHashOperationNameExtensions.snap | 8 ++++---- ...s.RequestDetails_DocumentOnly_IncludesDocumentTag.snap | 8 ++++---- ...ationTests.RequestDetails_None_ExcludesAllDetails.snap | 8 ++++---- .../Text/Json/CompositeResultDocumentTests.cs | 4 ++-- 27 files changed, 91 insertions(+), 91 deletions(-) diff --git a/src/HotChocolate/Core/test/Execution.Tests/ArgumentNonNullValidatorTests.cs b/src/HotChocolate/Core/test/Execution.Tests/ArgumentNonNullValidatorTests.cs index 204f3bc70c7..b18252aa979 100644 --- a/src/HotChocolate/Core/test/Execution.Tests/ArgumentNonNullValidatorTests.cs +++ b/src/HotChocolate/Core/test/Execution.Tests/ArgumentNonNullValidatorTests.cs @@ -62,6 +62,6 @@ input Bar { // assert Assert.True(report.HasErrors); - Assert.Equal("/root/a", report.Path.ToString()); + Assert.Equal("root.a", report.Path.ToString()); } } diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_ArgMissing.snap b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_ArgMissing.snap index f15f7688408..8d6c72af09c 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_ArgMissing.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_ArgMissing.snap @@ -1,2 +1,2 @@ -The directive arguments have invalid values: 'The required input field `d` is missing.' at /d. +The directive arguments have invalid values: 'The required input field `d` is missing.' at d. @a diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_InvalidArg.snap b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_InvalidArg.snap index f0be062aa3e..800f228a1b0 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_InvalidArg.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_InvalidArg.snap @@ -1,2 +1,2 @@ -The directive arguments have invalid values: 'Int cannot coerce the given literal of type `BooleanValue` to a runtime value.' at /e. +The directive arguments have invalid values: 'Int cannot coerce the given literal of type `BooleanValue` to a runtime value.' at e. @a(d: 1, e: true) diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_NonNullArgIsNull.snap b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_NonNullArgIsNull.snap index 5f94dc0e628..1e61efe51b6 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_NonNullArgIsNull.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_NonNullArgIsNull.snap @@ -1,2 +1,2 @@ -The directive arguments have invalid values: 'Cannot accept null for non-nullable input.' at /d. +The directive arguments have invalid values: 'Cannot accept null for non-nullable input.' at d. @a(d: null) diff --git a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_Overflow.snap b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_Overflow.snap index 47d5dd351d8..1bba165cbe6 100644 --- a/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_Overflow.snap +++ b/src/HotChocolate/Core/test/Types.Tests/Types/__snapshots__/DirectiveTypeTests.Directive_ValidateArgs_Overflow.snap @@ -1,2 +1,2 @@ -The directive arguments have invalid values: 'Int cannot coerce the given literal of type `IntValue` to a runtime value.' at /d. +The directive arguments have invalid values: 'Int cannot coerce the given literal of type `IntValue` to a runtime value.' at d. @a(d: 9223372036854775807) diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap index 33b122e09fc..3fef61eea55 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap @@ -62,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap index 83253985fa5..fd10dc4ecf5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap @@ -70,6 +70,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -77,10 +81,6 @@ { "Key": "graphql.operation.name", "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:6af18618ae20c266f6ffc352b78cb69b" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap index 7a6515281e5..f00d97076dc 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap @@ -70,6 +70,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -77,10 +81,6 @@ { "Key": "graphql.operation.name", "Value": "SayHelloOperation" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:851fb754d9ba6b5cc5a55ebcbea2621d" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap index edcb1cef283..6e5564554ca 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap @@ -25,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap index 02d1557c5dd..bfbb9fd1ca2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap @@ -25,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap index c2c12aaf823..12af4767fd7 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -62,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap index c4cc9d6d059..1f496ab6824 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap @@ -66,13 +66,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:241c617bf9ec34fef187d8b149fd8498" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap index a587cb7e489..2021a373452 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap @@ -29,10 +29,6 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" @@ -40,6 +36,10 @@ { "Key": "graphql.document.id", "Value": "sayHelloOp" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap index 80080053c85..394c091d706 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap @@ -66,13 +66,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap index 99fe5fb135e..5e45bdc3399 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap @@ -62,13 +62,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:073bf7696c078e52587c88890ef21bbe" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap index 02d1557c5dd..bfbb9fd1ca2 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap @@ -25,13 +25,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap index 0d6da976091..9ff8b608f7b 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap @@ -81,13 +81,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index f845b72beb9..c85efc6ffab 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -89,13 +89,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index 7cdab36908c..ac096a58c42 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -64,13 +64,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap index a469528f931..4676e5c2059 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap @@ -77,13 +77,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index cb6a3165688..5363d19dcde 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -85,13 +85,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 36086806591..3fa877086c4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -89,13 +89,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:c46cf8c9811934ddea095f10ee722dc4" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index 63c7c8fad4a..90f30afb640 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -101,6 +101,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -108,10 +112,6 @@ { "Key": "graphql.operation.name", "Value": "GetGreeting" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index 4b054bfe817..d4b1970c371 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -93,6 +93,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:cf203f646caf64f424638bd2f09e490a" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -100,10 +104,6 @@ { "Key": "graphql.operation.name", "Value": "GetGreeting" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:cf203f646caf64f424638bd2f09e490a" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index 73521356758..b222a1e8ef9 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -81,13 +81,13 @@ "Key": "graphql.processing.type", "Value": "plan" }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, { "Key": "graphql.document.hash", "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.operation.type", + "Value": "query" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index 7cc2c859b04..271d5d3e822 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -77,6 +77,10 @@ "Key": "graphql.processing.type", "Value": "plan" }, + { + "Key": "graphql.document.hash", + "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" + }, { "Key": "graphql.operation.type", "Value": "query" @@ -84,10 +88,6 @@ { "Key": "graphql.operation.name", "Value": "GetGreeting" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:111e40f921c6c6a35bc7eb0e3873630e" } ], "event": [] diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/Text/Json/CompositeResultDocumentTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/Text/Json/CompositeResultDocumentTests.cs index 0e6bfaffd23..7b5b6f04306 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/Text/Json/CompositeResultDocumentTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/Text/Json/CompositeResultDocumentTests.cs @@ -360,7 +360,7 @@ fragment Product on Product { var path = productBySlug.GetProperty("name").Path; // assert - Assert.Equal("/productBySlug/name", path.ToString()); + Assert.Equal("productBySlug.name", path.ToString()); } [Fact] @@ -413,7 +413,7 @@ public void Path_Array_Index() var path = name.Path; // assert - Assert.Equal("/users/nodes[0]/name", path.ToString()); + Assert.Equal("users.nodes[0].name", path.ToString()); } [Fact] From e85f686a46599f51d3f066ee49f90df45f7852e9 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:37:33 +0100 Subject: [PATCH 27/37] Cleanup --- .../Spans/AnalyzeOperationComplexitySpan.cs | 2 +- .../Spans/ExecuteRequestSpanBase.cs | 7 +- .../Diagnostics.Core/Spans/ValidationSpan.cs | 2 +- .../Diagnostics.Tests/ActivityTestHelper.cs | 40 +++++++- .../QueryInstrumentationTests.cs | 52 ---------- .../ServerInstrumentationTests.cs | 47 --------- ...ityAnalysis_Enabled_RecordsCostInSpan.snap | 4 +- ...lidGraphQLDocument_ReportsErrorStatus.snap | 2 +- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 4 +- ...p_Post_Add_Variables_To_Http_Activity.snap | 4 +- ...s.Http_Post_Capture_Deferred_Response.snap | 4 +- ...t_Ensure_List_Path_Is_Correctly_Built.snap | 4 +- ...s.Http_Post_SingleRequest_GetHeroName.snap | 4 +- ...Not_Automatically_Added_To_Activities.snap | 4 +- ...onTests.Http_Post_With_Extensions_Map.snap | 4 +- ...g_Error_When_Rename_Root_Is_Activated.snap | 59 ----------- ...RequestDetails_All_IncludesAllDetails.snap | 4 +- ...IncludesIdHashOperationNameExtensions.snap | 4 +- ...ails_DocumentOnly_IncludesDocumentTag.snap | 4 +- ...equestDetails_None_ExcludesAllDetails.snap | 4 +- ...n_Error_When_Rename_Root_Is_Activated.snap | 97 ------------------- .../ActivityTestHelper.cs | 23 +++-- .../QueryInstrumentationTests.cs | 94 ------------------ .../ServerInstrumentationTests.cs | 55 ----------- ...ntationTests.Http_Post_Single_Request.snap | 27 +++++- ...g_Error_When_Rename_Root_Is_Activated.snap | 59 ----------- ...n_Error_When_Rename_Root_Is_Activated.snap | 97 ------------------- 27 files changed, 106 insertions(+), 605 deletions(-) delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap delete mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs index c29af40ae8c..ad2a778f7c7 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/AnalyzeOperationComplexitySpan.cs @@ -16,7 +16,7 @@ internal sealed class AnalyzeOperationComplexitySpan( RequestContext context, ActivityEnricherBase enricher) { - var activity = source.StartActivity("GraphQL Complexity Analyzation"); + var activity = source.StartActivity("GraphQL Complexity Analysis"); if (activity is null) { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs index 02e61a0bea1..d3cc3bef269 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ExecuteRequestSpanBase.cs @@ -33,11 +33,6 @@ protected override void OnComplete() Activity.EnrichOperation(operationType, operationName); } - if (Activity.Status != ActivityStatusCode.Error) - { - Activity.SetStatus(ActivityStatusCode.Ok); - } - var documentInfo = Context.OperationDocumentInfo; Activity.EnrichDocumentInfo(documentInfo); @@ -51,7 +46,7 @@ protected override void OnComplete() { Activity.SetStatus(ActivityStatusCode.Error); } - else + else if (Activity.Status != ActivityStatusCode.Error) { Activity.SetStatus(ActivityStatusCode.Ok); } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs index dcd10f77f35..62df9746771 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ValidationSpan.cs @@ -15,7 +15,7 @@ internal sealed class ValidationSpan( RequestContext context, ActivityEnricherBase enricher) { - var activity = source.StartActivity( "GraphQL Document Validation"); + var activity = source.StartActivity("GraphQL Document Validation"); if (activity is null) { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs index 7e22981dc86..c2bb62b3a17 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs @@ -1,10 +1,14 @@ using System.Diagnostics; +using System.Text.RegularExpressions; using HotChocolate.Utilities; namespace HotChocolate.Diagnostics; public static class ActivityTestHelper { + private static readonly Regex _stackTracePathRegex = + new(@" in (?.+?):line (?\d+)", RegexOptions.Compiled | RegexOptions.CultureInvariant); + public static IDisposable CaptureActivities(out object activities) { var sync = new object(); @@ -76,7 +80,41 @@ private static void SerializeActivity(Activity activity) data["DisplayName"] = activity.DisplayName; data["Status"] = activity.Status; data["tags"] = activity.TagObjects; - data["event"] = activity.Events.Select(t => new { t.Name, t.Tags }); + data["event"] = activity.Events.Select(t => new + { + t.Name, + Tags = ScrubEventTags(t.Tags) + }); + } + + private static IEnumerable> ScrubEventTags( + IEnumerable>? tags) + { + if (tags is null) + { + yield break; + } + + foreach (var tag in tags) + { + if (tag.Value is string stackTrace + && (tag.Key.Equals("exception.stacktrace", StringComparison.Ordinal) + || tag.Key.EndsWith(".stacktrace", StringComparison.Ordinal))) + { + yield return new KeyValuePair( + tag.Key, + _stackTracePathRegex.Replace(stackTrace, match => + { + var fileName = System.IO.Path.GetFileName(match.Groups["path"].Value); + var lineNumber = match.Groups["line"].Value; + return $" in {fileName}:line {lineNumber}"; + })); + } + else + { + yield return tag; + } + } } private sealed class Session : IDisposable diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index a3b334bc1ca..0d1515c47f3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using Microsoft.Extensions.DependencyInjection; using HotChocolate.Execution; using HotChocolate.Language; @@ -27,57 +26,6 @@ public async Task Track_Events_Of_A_Simple_Query_Default() } } - [Fact] - public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() - { - using (CaptureActivities(out _)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ sayHello }"); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - - [Fact] - public async Task Parsing_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out _)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ sayHello"); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - - [Fact] - public async Task Validation_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out _)) - { - // arrange & act - await new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .ExecuteRequestAsync("{ abc123 }"); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - [Fact] public async Task Allow_Document_To_Be_Captured() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index da4d49b98d4..450eae3e9b3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -291,53 +291,6 @@ await server.PostRawAsync(new ClientQueryRequest } } - [Fact] - public async Task Parsing_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateInstrumentedServer( - o => o.Scopes = ActivityScopes.All); - - // act - await server.PostRawAsync(new ClientQueryRequest - { - // lang=text - Query = @" - { - 1 - }" - }); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Validation_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateInstrumentedServer( - o => o.Scopes = ActivityScopes.All); - - // act - await server.PostRawAsync(new ClientQueryRequest - { - Query = @" - { - abc - }" - }); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task RequestDetails_None_ExcludesAllDetails() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap index 4051715f9f3..18b75c1afa7 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap @@ -54,8 +54,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap index 3796df85e59..aec02c711c2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap @@ -20,7 +20,7 @@ }, { "Key": "exception.stacktrace", - "Value": "HotChocolate.Language.SyntaxException: Expected a `RightBrace`-token, but found a `EndOfFile`-token.\n at HotChocolate.Language.Utf8GraphQLParser.ParseSelectionSet() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs:line 221\n at HotChocolate.Language.Utf8GraphQLParser.ParseShortOperationDefinition() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Operations.cs:line 73\n at HotChocolate.Language.Utf8GraphQLParser.ParseDefinition() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 215\n at HotChocolate.Language.Utf8GraphQLParser.Parse() in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 98\n at HotChocolate.Language.Utf8GraphQLParser.Parse(String sourceText, ParserOptions options) in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs:line 326\n at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(RequestContext context) in /Users/tobiastengler/src/graphql-platform/src/HotChocolate/Core/src/Execution.Pipeline/DocumentParserMiddleware.cs:line 63" + "Value": "HotChocolate.Language.SyntaxException: Expected a `RightBrace`-token, but found a `EndOfFile`-token.\n at HotChocolate.Language.Utf8GraphQLParser.ParseSelectionSet() in Utf8GraphQLParser.Operations.cs:line 221\n at HotChocolate.Language.Utf8GraphQLParser.ParseShortOperationDefinition() in Utf8GraphQLParser.Operations.cs:line 73\n at HotChocolate.Language.Utf8GraphQLParser.ParseDefinition() in Utf8GraphQLParser.cs:line 215\n at HotChocolate.Language.Utf8GraphQLParser.Parse() in Utf8GraphQLParser.cs:line 98\n at HotChocolate.Language.Utf8GraphQLParser.Parse(String sourceText, ParserOptions options) in Utf8GraphQLParser.cs:line 326\n at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(RequestContext context) in DocumentParserMiddleware.cs:line 63" }, { "Key": "exception.type", diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 713e98f51a8..8189a723c0b 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -73,8 +73,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap index 5c530e48e0b..f0a0844464d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap @@ -81,8 +81,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap index ce7db6b67d8..16356a5b239 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap @@ -77,8 +77,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap index 3e6d5af113d..a4c809a7deb 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap @@ -77,8 +77,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap index 40aa5c93eff..5735177229f 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap @@ -77,8 +77,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap index 26d34ef6b06..357e78284ce 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap @@ -77,8 +77,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap index 4f131c64baa..66aac757f7e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap @@ -81,8 +81,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap deleted file mode 100644 index 4a420c1e099..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ /dev/null @@ -1,59 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.http.kind", - "Value": "HttpPost" - }, - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 3, - "column": 21 - } - ] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap index 0e3d5f442e1..3ae9d85ab7e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap @@ -93,8 +93,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap index 77960a6c701..62db38168d3 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap @@ -85,8 +85,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap index 53d55baf6ff..a8ba3e91332 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap @@ -73,8 +73,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap index f10663b143d..d79cffdd6df 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap @@ -69,8 +69,8 @@ "event": [] }, { - "OperationName": "GraphQL Complexity Analyzation", - "DisplayName": "GraphQL Complexity Analyzation", + "OperationName": "GraphQL Complexity Analysis", + "DisplayName": "GraphQL Complexity Analysis", "Status": "Ok", "tags": [ { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap deleted file mode 100644 index ab527170e1a..00000000000 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ /dev/null @@ -1,97 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.http.kind", - "Value": "HttpPost" - }, - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.query.id", - "Value": "e2b13c5332af8a70da160fcb96894e5c" - }, - { - "Key": "graphql.http.request.query.hash", - "Value": "e2b13c5332af8a70da160fcb96894e5c" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 3, - "column": 21 - } - ] - } - ] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs index f05657828b7..7aebb9253f1 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs @@ -5,6 +5,9 @@ namespace HotChocolate.Fusion.Diagnostics; public static partial class ActivityTestHelper { + private static readonly Regex _stackTracePathRegex = + new(@" in (?.+?):line (?\d+)", RegexOptions.Compiled | RegexOptions.CultureInvariant); + public static IDisposable CaptureActivities(out object activities) { var sync = new object(); @@ -85,18 +88,25 @@ private static void SerializeActivity(Activity activity) } private static IEnumerable> ScrubEventTags( - IEnumerable> tags) + IEnumerable>? tags) { + if (tags is null) + { + yield break; + } + foreach (var tag in tags) { - if (tag is { Key: "exception.stacktrace", Value: string stackTrace }) + if (tag.Value is string stackTrace + && (tag.Key.Equals("exception.stacktrace", StringComparison.Ordinal) + || tag.Key.EndsWith(".stacktrace", StringComparison.Ordinal))) { yield return new KeyValuePair( tag.Key, - StackTracePathRegex().Replace(stackTrace, match => + _stackTracePathRegex.Replace(stackTrace, match => { - var fileName = System.IO.Path.GetFileName(match.Groups[1].Value); - var lineNumber = match.Groups[2].Value; + var fileName = System.IO.Path.GetFileName(match.Groups["path"].Value); + var lineNumber = match.Groups["line"].Value; return $" in {fileName}:line {lineNumber}"; })); } @@ -107,9 +117,6 @@ private static void SerializeActivity(Activity activity) } } - [GeneratedRegex(@" in (.+):line (\d+)")] - private static partial Regex StackTracePathRegex(); - private sealed class Session : IDisposable { private readonly Activity _activity; diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index fbea39b591f..e874df8ce28 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -1,4 +1,3 @@ -using System.Diagnostics; using HotChocolate.Diagnostics; using HotChocolate.Execution; using HotChocolate.Language; @@ -42,99 +41,6 @@ public async Task Track_Events_Of_A_Simple_Query_Default() } } - [Fact] - public async Task Track_Events_Of_A_Simple_Query_Default_Rename_Root() - { - using (CaptureActivities(out _)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - - [Fact] - public async Task Parsing_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out _)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - - [Fact] - public async Task Validation_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out _)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [ - ("a", server1) - ], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - var executor = await gateway.Services.GetRequestExecutorAsync(); - - var request = OperationRequestBuilder.New() - .SetDocument("{ abc123 }") - .Build(); - - // act - await executor.ExecuteAsync(request); - - // assert - Assert.Equal("CaptureActivities", Activity.Current!.DisplayName); - } - } - [Fact] public async Task Allow_Document_To_Be_Captured() { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index a404ffff6c8..8bcbefe48b5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -261,61 +261,6 @@ public async Task Http_Post_Parser_Error() } } - [Fact] - public async Task Parsing_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [("a", server)], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - using var client = GraphQLHttpClient.Create(gateway.CreateClient()); - - // lang=text - var request = new OperationRequest("{ 1 }"); - - // act - using var result = await client.PostAsync(request, s_url); - - // assert - activities.MatchSnapshot(); - } - } - - [Fact] - public async Task Validation_Error_When_Rename_Root_Is_Activated() - { - using (CaptureActivities(out var activities)) - { - // arrange - using var server = CreateSourceSchema( - "a", - b => b.AddQueryType()); - - using var gateway = await CreateCompositeSchemaAsync( - [("a", server)], - configureGatewayBuilder: b => b - .AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - - using var client = GraphQLHttpClient.Create(gateway.CreateClient()); - - var request = new OperationRequest("{ abc }"); - - // act - using var result = await client.PostAsync(request, s_url); - - // assert - activities.MatchSnapshot(); - } - } - [Fact] public async Task RequestDetails_None_ExcludesAllDetails() { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap index ac096a58c42..879f232de5c 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap @@ -2,9 +2,30 @@ "activities": [ { "OperationName": "ExecuteHttpRequest", - "DisplayName": "ExecuteHttpRequest", - "Status": "Unset", - "tags": [], + "DisplayName": "GraphQL HTTP POST", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.http.kind", + "Value": "HttpPost" + }, + { + "Key": "graphql.schema.name", + "Value": "_Default" + }, + { + "Key": "graphql.http.request.type", + "Value": "single" + }, + { + "Key": "graphql.http.request.query.id", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + }, + { + "Key": "graphql.http.request.query.hash", + "Value": "f7e9989fbb67af7fa747a9983313c9e5" + } + ], "event": [], "activities": [ { diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap deleted file mode 100644 index 73a68f7b51e..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Parsing_Error_When_Rename_Root_Is_Activated.snap +++ /dev/null @@ -1,59 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.http.kind", - "Value": "HttpPost" - }, - { - "Key": "graphql.schema.name", - "Value": "_Default" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Error", - "tags": [], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "Expected a `Name`-token, but found a `Integer`-token." - }, - { - "Key": "graphql.error.code", - "Value": "HC0011" - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 1, - "column": 3 - } - ] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap deleted file mode 100644 index f9ba644115b..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Validation_Error_When_Rename_Root_Is_Activated.snap +++ /dev/null @@ -1,97 +0,0 @@ -{ - "activities": [ - { - "OperationName": "ExecuteHttpRequest", - "DisplayName": "GraphQL HTTP POST", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.http.kind", - "Value": "HttpPost" - }, - { - "Key": "graphql.schema.name", - "Value": "_Default" - }, - { - "Key": "graphql.http.request.type", - "Value": "single" - }, - { - "Key": "graphql.http.request.query.id", - "Value": "346f68539881f0624dca2927281d1a2f" - }, - { - "Key": "graphql.http.request.query.hash", - "Value": "346f68539881f0624dca2927281d1a2f" - } - ], - "event": [], - "activities": [ - { - "OperationName": "Parse HTTP Request", - "DisplayName": "Parse HTTP Request", - "Status": "Ok", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "GraphQL Operation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:346f68539881f0624dca2927281d1a2f" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "graphql.error.message", - "Value": "The field `abc` does not exist on the type `Query`." - }, - { - "Key": "graphql.error.locations", - "Value": [ - { - "line": 1, - "column": 3 - } - ] - } - ] - } - ] - } - ] - }, - { - "OperationName": "Format HTTP Response", - "DisplayName": "Format HTTP Response", - "Status": "Ok", - "tags": [], - "event": [] - } - ] - } - ] -} From aed5f55d83ddb30371fc7e9d578730a784d56b8e Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:48:06 +0100 Subject: [PATCH 28/37] Fix snapshots --- .../QueryInstrumentationTests.cs | 32 ++-- ..._SecondExecution_RecordsCacheHitEvent.snap | 159 +--------------- .../QueryInstrumentationTests.cs | 28 +-- ..._SecondExecution_RecordsCacheHitEvent.snap | 175 +---------------- ...HttpRequestError_MarksNodeSpanAsError.snap | 178 ------------------ 5 files changed, 36 insertions(+), 536 deletions(-) delete mode 100644 src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs index 0d1515c47f3..91013c96e5d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs @@ -342,21 +342,27 @@ public async Task VariableCoercion_WithAllScopes_RecordsCoercionSpan() [Fact] public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() { - using (CaptureActivities(out var activities)) - { - // arrange - var services = new ServiceCollection() - .AddGraphQL() - .AddInstrumentation(o => o.Scopes = ActivityScopes.All) - .AddQueryType() - .Services - .BuildServiceProvider(); + // arrange + var services = new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .Services + .BuildServiceProvider(); - var executor = await services.GetRequestExecutorAsync(); + var executor = await services.GetRequestExecutorAsync(); + + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .SetDocumentHash(new OperationDocumentHash("abc", "sha256", HashFormat.Hex)) + .Build(); - // act - execute twice so second uses cached document - await executor.ExecuteAsync("{ sayHello }"); - await executor.ExecuteAsync("{ sayHello }"); + // act - execute twice so second uses cached document + await executor.ExecuteAsync(request); + + using (CaptureActivities(out var activities)) + { + await executor.ExecuteAsync(request); // assert activities.MatchSnapshot(); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap index 70a59b001c4..e6b686d9426 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -16,168 +16,11 @@ ], "event": [ { - "Name": "AddedOperationToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "SimpleQuery.sayHello", - "DisplayName": "SimpleQuery.sayHello", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "resolve" - }, - { - "Key": "graphql.selection.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.path", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.name", - "Value": "sayHello" - }, - { - "Key": "graphql.selection.field.coordinate", - "Value": "SimpleQuery.sayHello" - }, - { - "Key": "graphql.selection.field.parent_type", - "Value": "SimpleQuery" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedDocumentToCache", + "Name": "RetrievedDocumentFromCache", "Tags": [] } ], "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, { "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs index e874df8ce28..ac51445d5b5 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs @@ -494,28 +494,30 @@ public async Task MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedE [Fact] public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() { - using (CaptureActivities(out var activities)) - { - // arrange - using var server1 = CreateSourceSchema( - "a", - b => b.AddQueryType()); + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b.AddQueryType()); - using var gateway = await CreateCompositeSchemaAsync( + using var gateway = await CreateCompositeSchemaAsync( [ ("a", server1) ], configureGatewayBuilder: b => b.AddInstrumentation(o => o.Scopes = FusionActivityScopes.All)); - var executor = await gateway.Services.GetRequestExecutorAsync(); + var executor = await gateway.Services.GetRequestExecutorAsync(); - // act - execute twice so second uses cached document - var request = OperationRequestBuilder.New() - .SetDocument("{ sayHello }") - .Build(); + // act - execute twice so second uses cached document + var request = OperationRequestBuilder.New() + .SetDocument("{ sayHello }") + .SetDocumentHash(new OperationDocumentHash("abc", "sha256", HashFormat.Hex)) + .Build(); - await executor.ExecuteAsync(request); + await executor.ExecuteAsync(request); + + using (CaptureActivities(out var activities)) + { await executor.ExecuteAsync(request); // assert diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap index 12af4767fd7..8f8fb30f6f4 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap @@ -16,184 +16,11 @@ ], "event": [ { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - }, - { - "Key": "graphql.operation.step.id", - "Value": "1" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "456132b93ebaf15a39534753bf72f9f4bfa1152a08d04bc8a88539feec1cb52c" - }, - { - "Key": "graphql.source.name", - "Value": "a" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_f7e9989f_1" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:35c1feb1208268226c7d5d5d0ae122e4d38cb79621e862b1e252d37fc83c530a" - } - ], - "event": [] - } - ] - } - ] - }, - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [ - { - "Name": "AddedDocumentToCache", + "Name": "RetrievedDocumentFromCache", "Tags": [] } ], "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:f7e9989fbb67af7fa747a9983313c9e5" - } - ], - "event": [] - }, { "OperationName": "GraphQL Operation Execution", "DisplayName": "GraphQL Operation Execution", diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap deleted file mode 100644 index 600eba8e3e4..00000000000 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_HttpRequestError_MarksNodeSpanAsError.snap +++ /dev/null @@ -1,178 +0,0 @@ -{ - "activities": [ - { - "OperationName": "GraphQL Operation", - "DisplayName": "query", - "Status": "Error", - "tags": [ - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "graphql.document.body", - "Value": "{\n sayHello\n sayGoodbye\n}" - } - ], - "event": [ - { - "Name": "AddedOperationPlanToCache", - "Tags": [] - }, - { - "Name": "AddedDocumentToCache", - "Tags": [] - } - ], - "activities": [ - { - "OperationName": "GraphQL Document Parsing", - "DisplayName": "GraphQL Document Parsing", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Document Validation", - "DisplayName": "GraphQL Document Validation", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "validate" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Planning", - "DisplayName": "GraphQL Operation Planning", - "Status": "Ok", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "plan" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - } - ], - "event": [] - }, - { - "OperationName": "GraphQL Operation Execution", - "DisplayName": "GraphQL Operation Execution", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - } - ], - "event": [], - "activities": [ - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Unset", - "tags": [], - "event": [] - }, - { - "OperationName": "GraphQL Step Execution", - "DisplayName": "GraphQL Step Execution", - "Status": "Error", - "tags": [ - { - "Key": "graphql.processing.type", - "Value": "step_execute" - }, - { - "Key": "graphql.operation.type", - "Value": "query" - }, - { - "Key": "graphql.document.hash", - "Value": "md5:073bf7696c078e52587c88890ef21bbe" - }, - { - "Key": "graphql.operation.step.id", - "Value": "2" - }, - { - "Key": "graphql.operation.step.kind", - "Value": "operation" - }, - { - "Key": "graphql.operation.step.plan.id", - "Value": "9babcd211d7b162261fa15a119462370a3f30c61ea319946c30bc4051a265a5d" - }, - { - "Key": "graphql.source.name", - "Value": "b" - }, - { - "Key": "graphql.source.operation.name", - "Value": "Op_073bf769_2" - }, - { - "Key": "graphql.source.operation.kind", - "Value": "query" - }, - { - "Key": "graphql.source.operation.hash", - "Value": "sha256:1fa50769ad5084334414d5ceb8029c7787ded48ac5cc01dac775b0b814348e88" - } - ], - "event": [ - { - "Name": "exception", - "Tags": [ - { - "Key": "exception.message", - "Value": "Response status code does not indicate success: 500 (Internal Server Error)." - }, - { - "Key": "exception.stacktrace", - "Value": "System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).\n at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()\n at HotChocolate.Fusion.Transport.Http.GraphQLHttpResponse.ReadAsResultAsync(CancellationToken cancellationToken) in GraphQLHttpResponse.cs:line 150\n at HotChocolate.Fusion.Execution.Clients.SourceSchemaHttpClient.Response.ReadAsResultStreamAsync(CancellationToken cancellationToken)+MoveNext() in SourceSchemaHttpClient.cs:line 577\n at HotChocolate.Fusion.Execution.Clients.SourceSchemaHttpClient.Response.ReadAsResultStreamAsync(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158\n at HotChocolate.Fusion.Execution.Nodes.OperationExecutionNode.OnExecuteAsync(OperationPlanContext context, CancellationToken cancellationToken) in OperationExecutionNode.cs:line 158" - }, - { - "Key": "exception.type", - "Value": "System.Net.Http.HttpRequestException" - } - ] - } - ] - } - ] - } - ] - } - ] -} From 8d520d9e70fc6234993db6ce150a87ad230164d5 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:58:45 +0100 Subject: [PATCH 29/37] Fix test flakiness --- .../ServerInstrumentationTests.cs | 120 ++++++++++-------- ...ts.Http_Get_SingleRequest_GetHeroName.snap | 2 +- .../ServerInstrumentationTests.cs | 11 ++ 3 files changed, 79 insertions(+), 54 deletions(-) diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs index 450eae3e9b3..ea5b6b75e64 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs @@ -1,13 +1,17 @@ using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using HotChocolate.AspNetCore.Tests.Utilities; +using HotChocolate.Transport.Http; using static HotChocolate.Diagnostics.ActivityTestHelper; +using OperationRequest = HotChocolate.Transport.OperationRequest; namespace HotChocolate.Diagnostics; [Collection("Instrumentation")] public class ServerInstrumentationTests : ServerTestBase { + private static readonly Uri s_url = new("http://localhost:5000/graphql"); + public ServerInstrumentationTests(TestServerFactory serverFactory) : base(serverFactory) { @@ -20,17 +24,18 @@ public async Task Http_Post_SingleRequest_GetHeroName_Default() { // arrange using var server = CreateInstrumentedServer(); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + @" { hero { name } - }" - }); + }"); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -45,17 +50,18 @@ public async Task Http_Post_SingleRequest_GetHeroName() // arrange using var server = CreateInstrumentedServer( o => o.Scopes = ActivityScopes.All); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + @" { hero { name } - }" - }); + }"); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -70,17 +76,18 @@ public async Task Http_Get_SingleRequest_GetHeroName() // arrange using var server = CreateInstrumentedServer( o => o.Scopes = ActivityScopes.All); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.GetAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + @" { hero { name } - }" - }); + }"); + using var result = await client.GetAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -95,18 +102,19 @@ public async Task Http_Post_Variables_Are_Not_Automatically_Added_To_Activities( // arrange using var server = CreateInstrumentedServer( o => o.Scopes = ActivityScopes.All); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query ($episode: Episode!) { hero(episode: $episode) { name } }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } } - }); + variables: new Dictionary { { "episode", "NEW_HOPE" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -125,18 +133,19 @@ public async Task Http_Post_Add_Variables_To_Http_Activity() o.Scopes = ActivityScopes.All; o.RequestDetails = RequestDetails.Default | RequestDetails.Variables; }); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query ($episode: Episode!) { hero(episode: $episode) { name } }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } } - }); + variables: new Dictionary { { "episode", "NEW_HOPE" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -151,19 +160,20 @@ public async Task Http_Post_With_Extensions_Map() // arrange using var server = CreateInstrumentedServer( o => o.Scopes = ActivityScopes.All); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query ($episode: Episode!) { hero(episode: $episode) { name } }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } }, - Extensions = new Dictionary { { "test", "abc" } } - }); + variables: new Dictionary { { "episode", "NEW_HOPE" } }, + extensions: new Dictionary { { "test", "abc" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -303,19 +313,20 @@ public async Task RequestDetails_None_ExcludesAllDetails() o.Scopes = ActivityScopes.All; o.RequestDetails = RequestDetails.None; }); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query GetHero($episode: Episode!) { hero(episode: $episode) { name } }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } }, - Extensions = new Dictionary { { "test", "abc" } } - }); + variables: new Dictionary { { "episode", "NEW_HOPE" } }, + extensions: new Dictionary { { "test", "abc" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -334,19 +345,20 @@ public async Task RequestDetails_All_IncludesAllDetails() o.Scopes = ActivityScopes.All; o.RequestDetails = RequestDetails.All; }); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query GetHero($episode: Episode!) { hero(episode: $episode) { name } }", - Variables = new Dictionary { { "episode", "NEW_HOPE" } }, - Extensions = new Dictionary { { "test", "abc" } } - }); + variables: new Dictionary { { "episode", "NEW_HOPE" } }, + extensions: new Dictionary { { "test", "abc" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -365,17 +377,18 @@ public async Task RequestDetails_DocumentOnly_IncludesDocumentTag() o.Scopes = ActivityScopes.All; o.RequestDetails = RequestDetails.Document; }); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + @" { hero { name } - }" - }); + }"); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -390,18 +403,19 @@ public async Task RequestDetails_Default_IncludesIdHashOperationNameExtensions() // arrange using var server = CreateInstrumentedServer( o => o.Scopes = ActivityScopes.All); + using var client = GraphQLHttpClient.Create(server.CreateClient()); // act - await server.PostAsync(new ClientQueryRequest - { - Query = @" + var request = new OperationRequest( + query: @" query GetHero { hero { name } }", - Extensions = new Dictionary { { "test", "abc" } } - }); + extensions: new Dictionary { { "test", "abc" } }); + using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap index 8189a723c0b..549d391b410 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap @@ -19,7 +19,7 @@ }, { "Key": "graphql.http.request.query.hash", - "Value": "530cb46cabc38757c74c05cc7a96b636" + "Value": "a570a6bff748b5916eadf153261d9c6d" } ], "event": [], diff --git a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs index 8bcbefe48b5..afed8158024 100644 --- a/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion-vnext/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs @@ -31,6 +31,7 @@ public async Task Http_Post_Single_Request_Default() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -58,6 +59,7 @@ public async Task Http_Post_Single_Request() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -85,6 +87,7 @@ public async Task Http_Get_Single_Request() // act using var result = await client.GetAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -118,6 +121,7 @@ public async Task Http_Post_Variables_Are_Not_Automatically_Added_To_Activities( // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -155,6 +159,7 @@ public async Task Http_Post_Add_Variables_To_Http_Activity() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -189,6 +194,7 @@ public async Task Http_Post_With_Extensions_Map() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -255,6 +261,7 @@ public async Task Http_Post_Parser_Error() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -293,6 +300,7 @@ query GetGreeting($name: String!) { // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -331,6 +339,7 @@ query GetGreeting($name: String!) { // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -362,6 +371,7 @@ public async Task RequestDetails_DocumentOnly_IncludesDocumentTag() // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); @@ -395,6 +405,7 @@ query GetGreeting { // act using var result = await client.PostAsync(request, s_url); + await result.ReadAsResultAsync(); // assert activities.MatchSnapshot(); From 3e6c0f96c513954b6099123ce736f49835b0a573 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 5 Mar 2026 18:46:45 +0100 Subject: [PATCH 30/37] Retrigger CI From 4c4d87abbdc378bdecf7fdfec6f03a315452967a Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:10:24 +0100 Subject: [PATCH 31/37] Cleanup --- .../src/Diagnostics.Core/Extensions/ActivityExtensions.cs | 4 ++-- .../Diagnostics/src/Diagnostics.Core/SemanticConventions.cs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs index e49fc39b11e..7a1e602c086 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Extensions/ActivityExtensions.cs @@ -56,8 +56,8 @@ public void AddGraphQLError(IError error) var location = error.Locations[i]; locations[i] = new Dictionary { - ["line"] = location.Line, - ["column"] = location.Column + [SemanticConventions.GraphQL.Error.Location.Line] = location.Line, + [SemanticConventions.GraphQL.Error.Location.Column] = location.Column }; } diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index a71d3b966b9..1d679aa1217 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -132,7 +132,6 @@ public static class Operation } } - // Note: This is not part of the OTEL semantic conventions public static class Error { public const string Message = "graphql.error.message"; @@ -142,8 +141,8 @@ public static class Error public static class Location { - public const string Column = "graphql.error.location.column"; - public const string Line = "graphql.error.location.line"; + public const string Column = "column"; + public const string Line = "line"; } } From 3b9a4996944e0b4413d0808ba83f88b6a992cb22 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 17:35:25 +0100 Subject: [PATCH 32/37] Undo TryGetOperationDocument change --- .../src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs | 2 +- .../Execution/Extensions/RequestContextExtensions.cs | 2 +- .../CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs | 2 +- .../Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs b/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs index b00334fdffd..c17c494a8c3 100644 --- a/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs +++ b/src/HotChocolate/Core/src/Authorization/Pipeline/AuthorizeRequestMiddleware.cs @@ -9,7 +9,7 @@ internal sealed class AuthorizeRequestMiddleware( { public async ValueTask InvokeAsync(RequestContext context) { - if (!context.TryGetDocument(out var document, out var documentId)) + if (!context.TryGetOperationDocument(out var document, out var documentId)) { throw new InvalidOperationException( "The document or document id is not set."); diff --git a/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs b/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs index ab086f7bf1b..6062965289d 100644 --- a/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs +++ b/src/HotChocolate/Core/src/Execution.Abstractions/Execution/Extensions/RequestContextExtensions.cs @@ -29,7 +29,7 @@ public static bool IsPersistedOperationDocument(this RequestContext context) return context.OperationDocumentInfo.IsPersisted; } - public static bool TryGetDocument( + public static bool TryGetOperationDocument( this RequestContext context, [NotNullWhen(true)] out DocumentNode? document, out OperationDocumentId documentId) diff --git a/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs b/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs index 716d0aec273..ac3c5f85507 100644 --- a/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs +++ b/src/HotChocolate/CostAnalysis/src/CostAnalysis/CostAnalyzerMiddleware.cs @@ -22,7 +22,7 @@ internal sealed class CostAnalyzerMiddleware( { public async ValueTask InvokeAsync(RequestContext context) { - if (!context.TryGetDocument(out var document, out var documentId) + if (!context.TryGetOperationDocument(out var document, out var documentId) || documentId.IsEmpty) { context.Result = ResultHelper.StateInvalidForCostAnalysis(); diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs index a7603636970..7cedcfbc343 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/ParsingSpan.cs @@ -33,7 +33,7 @@ internal sealed class ParsingSpan( protected override void OnComplete() { - if (context.TryGetDocument(out _, out _)) + if (context.TryGetOperationDocument(out _, out _)) { Activity.SetStatus(ActivityStatusCode.Ok); } From 0fec0af903f6f2a86fc49d5ea9ffb4fae7872f66 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 18:04:14 +0100 Subject: [PATCH 33/37] Update migration guide --- .../Diagnostics.Core/ActivityEnricherBase.cs | 6 +-- .../Spans/Http/ExecuteHttpRequestSpan.cs | 6 +-- .../v16/migrating/migrate-from-15-to-16.md | 46 ++++++++++++++----- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs index 100af8b0db5..a5f9fab1732 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/ActivityEnricherBase.cs @@ -17,17 +17,17 @@ public virtual void EnrichExecuteHttpRequest( HttpRequestKind kind, Activity activity) { } - public virtual void EnrichStartSingleRequest( + public virtual void EnrichSingleRequest( HttpContext httpContext, GraphQLRequest request, Activity activity) { } - public virtual void EnrichStartBatchRequest( + public virtual void EnrichBatchRequest( HttpContext httpContext, IReadOnlyList batch, Activity activity) { } - public virtual void EnrichStartOperationBatchRequest( + public virtual void EnrichOperationBatchRequest( HttpContext httpContext, GraphQLRequest request, IReadOnlyList operations, diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs index eacda017ef0..94373731cf5 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/Http/ExecuteHttpRequestSpan.cs @@ -107,7 +107,7 @@ public void SetSingleRequestDetails(GraphQLRequest request) } } - enricher.EnrichStartSingleRequest(httpContext, request, Activity); + enricher.EnrichSingleRequest(httpContext, request, Activity); } public void SetBatchRequestDetails(IReadOnlyList batch) @@ -166,7 +166,7 @@ public void SetBatchRequestDetails(IReadOnlyList batch) } } - enricher.EnrichStartBatchRequest(httpContext, batch, Activity); + enricher.EnrichBatchRequest(httpContext, batch, Activity); } public void SetOperationBatchRequestDetails( @@ -218,7 +218,7 @@ public void SetOperationBatchRequestDetails( } } - enricher.EnrichStartOperationBatchRequest(httpContext, request, operations, Activity); + enricher.EnrichOperationBatchRequest(httpContext, request, operations, Activity); } protected override void OnComplete() diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index 552c89ba6be..e8882ad8ec2 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -695,18 +695,6 @@ builder - `RequestDetails.Operation` was renamed to `RequestDetails.OperationName`. - `RequestDetails.Query` was renamed to `RequestDetails.Document`. -### Custom enricher changes - -If you've implemented a custom `ActivityEnricher`, you now no longer need to pass the `ObjectPool` down to the base class: - -```diff -public class CustomActivityEnricher( -- ObjectPool stringBuilderPool, - InstrumentationOptions options --) : ActivityEnricher(stringBuilderPool, options); -+) : ActivityEnricher(options); -``` - ## OpenTelemetry span and status changes The OpenTelemetry spans and attributes emitted by `AddInstrumentation()` have been updated to align with the [proposed OpenTelemetry semantic conventions for GraphQL](https://github.com/graphql/otel-wg/blob/main/spec). @@ -742,6 +730,39 @@ If you have dashboards or alerts that filter on the old attribute names or value | `graphql.document.hash` | `` | `:` , e.g. `md5:` | | `graphql.document.id` | - | Value is only set if document is a trusted document | +### Custom enricher changes + +If you've implemented a custom `ActivityEnricher`, you no longer need to pass the `ObjectPool` down to the base class: + +```diff +public class CustomActivityEnricher( +- ObjectPool stringBuilderPool, + InstrumentationOptions options +-) : ActivityEnricher(stringBuilderPool, options); ++) : ActivityEnricher(options); +``` + +There have also been some changes to the methods you can override in your enricher: + +| v15 | v16 | +| ------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `EnrichParserErrors(HttpContext, IError, Activity)` | Replaced by `EnrichParserErrors(HttpContext, IReadOnlyList, Activity)`. | +| `EnrichRequestError(RequestContext, Activity, Exception)` | Replaced by `EnrichRequestError(RequestContext, Exception, Activity)`. | +| `EnrichRequestError(RequestContext, Activity, IError)` | Replaced by `EnrichRequestError(RequestContext, IError, Activity)`. | +| `EnrichValidationError(RequestContext, Activity, IError)` | Replaced by `EnrichValidationErrors(RequestContext, IReadOnlyList, Activity)`. | +| `EnrichAnalyzeOperationComplexity(RequestContext, Activity)` | Replaced by `EnrichAnalyzeOperationCost(RequestContext, Activity)`. | +| `EnrichDataLoaderBatch(IDataLoader, IReadOnlyList, Activity)` | Replaced by `EnrichExecuteBatch(IDataLoader, IReadOnlyList, Activity)`. | +| `EnrichResolverError(RequestContext, IError, Activity)` | Removed. Use `EnrichRequestError(...)` for request-level errors and `EnrichResolverError(IMiddlewareContext, IError, Activity)` for field resolver errors. | +| `EnrichRequestVariables(...)` | Removed. | +| `EnrichBatchVariables(...)` | Removed. | +| `EnrichRequestExtensions(...)` | Removed. | +| `EnrichBatchExtensions(...)` | Removed. | +| `CreateOperationDisplayName(...)` | Removed. | +| `CreateRootActivityName(...)` | Removed. | +| `EnrichError(...)` | Removed. | + +> Note: Overriding enricher methods without calling `base` no longer prevents the standard span attributes from being emitted. The semantic-convention attributes are now applied by the instrumentation itself, and custom enrichers are only intended for adding extra information. + ## Diagnostic Listeners We removed the following methods from the `IExecutionDiagnosticEventListener` since they no longer apply: @@ -753,6 +774,7 @@ We removed the following methods from the `IExecutionDiagnosticEventListener` si - `SubscriptionEventResult` Some other methods also had a change in their signature - simply override them again to fix any compilation issues. + # Deprecations Things that will continue to function this release, but we encourage you to move away from. From 81f370ea73ae29c7c2d2e4066e6089373b9da55f Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 18:11:50 +0100 Subject: [PATCH 34/37] Fix build issue --- .../test/Diagnostics.Tests/ActivityTestHelper.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs index c2bb62b3a17..bc6aada2949 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs @@ -4,10 +4,10 @@ namespace HotChocolate.Diagnostics; -public static class ActivityTestHelper +public static partial class ActivityTestHelper { - private static readonly Regex _stackTracePathRegex = - new(@" in (?.+?):line (?\d+)", RegexOptions.Compiled | RegexOptions.CultureInvariant); + [GeneratedRegex(@" in (?.+?):line (?\d+)", RegexOptions.CultureInvariant)] + private static partial Regex StackTracePathRegex(); public static IDisposable CaptureActivities(out object activities) { @@ -103,7 +103,7 @@ private static void SerializeActivity(Activity activity) { yield return new KeyValuePair( tag.Key, - _stackTracePathRegex.Replace(stackTrace, match => + StackTracePathRegex().Replace(stackTrace, match => { var fileName = System.IO.Path.GetFileName(match.Groups["path"].Value); var lineNumber = match.Groups["line"].Value; From c40b318e430d4776e14b3d6bdbf1c734d5cc02fc Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 20:50:55 +0100 Subject: [PATCH 35/37] Add subscription event span --- .../Diagnostics.Core/SemanticConventions.cs | 5 + .../Spans/SubscriptionEventSpan.cs | 42 ++++ .../ActivityExecutionDiagnosticListener.cs | 56 ++++- ...tivityExecutionDiagnosticListenerTests.cs} | 100 ++++++++- ... ActivityServerDiagnosticListenerTests.cs} | 7 +- .../Diagnostics.Tests/ActivityTestHelper.cs | 13 ++ .../Diagnostics.Tests/CustomDataLoader.cs | 2 +- ...sExecuteRequestAndParseDocumentSpans.snap} | 0 ...rTests.Allow_Document_To_Be_Captured.snap} | 0 ..._Error_That_Deletes_The_Whole_Result.snap} | 0 ...tyAnalysis_Enabled_RecordsCostInSpan.snap} | 0 ...s_OnlyValidateAndCompile_LimitsSpans.snap} | 0 ...ader_BatchExecution_RecordsBatchSpan.snap} | 0 ...Execution_With_Keys_RecordsBatchSpan.snap} | 0 ...sExecuteRequestAndParseDocumentSpans.snap} | 0 ...SecondExecution_RecordsCacheHitEvent.snap} | 0 ...idation_Activity_Has_An_Error_Status.snap} | 0 ...idGraphQLDocument_ReportsErrorStatus.snap} | 0 ...ation_LoadsFromStorage_DefaultScopes.snap} | 0 ...or_AtRootLevel_MarksOperationAsError.snap} | 0 ...r_DeepInTree_MarksNestedFieldAsError.snap} | 0 ...rror_Records_Subscription_Event_Error.snap | 201 ++++++++++++++++++ ...Event_Records_Subscription_Event_Span.snap | 175 +++++++++++++++ ...ack_Events_Of_A_Simple_Query_Default.snap} | 0 ...rror_UnknownField_ReportsErrorStatus.snap} | 0 ...on_WithAllScopes_RecordsCoercionSpan.snap} | 0 ...cListenerTests.Http_Get_SDL_Download.snap} | 0 ...s.Http_Get_SingleRequest_GetHeroName.snap} | 0 ..._Post_Add_Variables_To_Http_Activity.snap} | 0 ....Http_Post_Capture_Deferred_Response.snap} | 0 ..._Ensure_List_Path_Is_Correctly_Built.snap} | 0 ...ListenerTests.Http_Post_Parser_Error.snap} | 0 ....Http_Post_SingleRequest_GetHeroName.snap} | 0 ...st_SingleRequest_GetHeroName_Default.snap} | 0 ...ot_Automatically_Added_To_Activities.snap} | 0 ...rTests.Http_Post_With_Extensions_Map.snap} | 0 ...equestDetails_All_IncludesAllDetails.snap} | 0 ...ncludesIdHashOperationNameExtensions.snap} | 0 ...ils_DocumentOnly_IncludesDocumentTag.snap} | 0 ...questDetails_None_ExcludesAllDetails.snap} | 0 .../FusionActivityEnricher.cs | 44 +++- ...ctivityExecutionDiagnosticEventListener.cs | 79 ++++++- .../ActivityTestHelper.cs | 13 ++ ...tivityExecutionDiagnosticListenerTests.cs} | 159 +++++++++++++- ...nActivityServerDiagnosticListenerTests.cs} | 2 +- ...enerTests.AllScopes_IncludesAllSpans.snap} | 0 ...rTests.Allow_Document_To_Be_Captured.snap} | 0 ..._Error_That_Deletes_The_Whole_Result.snap} | 0 ...opes_OnlyValidateAndPlan_LimitsSpans.snap} | 0 ...sExecuteRequestAndParseDocumentSpans.snap} | 0 ...SecondExecution_RecordsCacheHitEvent.snap} | 0 ...idation_Activity_Has_An_Error_Status.snap} | 0 ...solverError_RecordsDeeplyNestedError.snap} | 0 ...idGraphQLDocument_ReportsErrorStatus.snap} | 0 ...ation_LoadsFromStorage_DefaultScopes.snap} | 0 ...rTests.Source_Schema_Transport_Error.snap} | 0 ...Event_Records_Subscription_Event_Span.snap | 193 +++++++++++++++++ ...nts_Of_A_Query_With_Multiple_Sources.snap} | 0 ...ack_Events_Of_A_Simple_Query_Default.snap} | 0 ...rror_UnknownField_ReportsErrorStatus.snap} | 0 ...cListenerTests.Http_Get_SDL_Download.snap} | 0 ...istenerTests.Http_Get_Single_Request.snap} | 0 ..._Post_Add_Variables_To_Http_Activity.snap} | 0 ...ListenerTests.Http_Post_Parser_Error.snap} | 0 ...stenerTests.Http_Post_Single_Request.snap} | 0 ...sts.Http_Post_Single_Request_Default.snap} | 0 ...ot_Automatically_Added_To_Activities.snap} | 0 ...rTests.Http_Post_With_Extensions_Map.snap} | 0 ...equestDetails_All_IncludesAllDetails.snap} | 0 ...ncludesIdHashOperationNameExtensions.snap} | 0 ...ils_DocumentOnly_IncludesDocumentTag.snap} | 0 ...questDetails_None_ExcludesAllDetails.snap} | 0 .../v16/migrating/migrate-from-15-to-16.md | 2 + 73 files changed, 1068 insertions(+), 25 deletions(-) create mode 100644 src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SubscriptionEventSpan.cs rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/{QueryInstrumentationTests.cs => ActivityExecutionDiagnosticListenerTests.cs} (78%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/{ServerInstrumentationTests.cs => ActivityServerDiagnosticListenerTests.cs} (98%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap => ActivityExecutionDiagnosticListenerTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap => ActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap => ActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap => ActivityExecutionDiagnosticListenerTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap => ActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap => ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_RecordsBatchSpan.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap => ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap => ActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap => ActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap => ActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap => ActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap => ActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap => ActivityExecutionDiagnosticListenerTests.ResolverError_AtRootLevel_MarksOperationAsError.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap => ActivityExecutionDiagnosticListenerTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap} (100%) create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap create mode 100644 src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap => ActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap => ActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap => ActivityExecutionDiagnosticListenerTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Get_SDL_Download.snap => ActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap => ActivityServerDiagnosticListenerTests.Http_Get_SingleRequest_GetHeroName.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap => ActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap => ActivityServerDiagnosticListenerTests.Http_Post_Capture_Deferred_Response.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap => ActivityServerDiagnosticListenerTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Parser_Error.snap => ActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap => ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap => ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName_Default.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap => ActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap => ActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap => ActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap => ActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap => ActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap} (100%) rename src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap => ActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/{QueryInstrumentationTests.cs => FusionActivityExecutionDiagnosticListenerTests.cs} (77%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/{ServerInstrumentationTests.cs => FusionActivityServerDiagnosticListenerTests.cs} (99%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap => FusionActivityExecutionDiagnosticListenerTests.AllScopes_IncludesAllSpans.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap => FusionActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap => FusionActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap => FusionActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap => FusionActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap => FusionActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap => FusionActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap => FusionActivityExecutionDiagnosticListenerTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap => FusionActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap => FusionActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Source_Schema_Transport_Error.snap => FusionActivityExecutionDiagnosticListenerTests.Source_Schema_Transport_Error.snap} (100%) create mode 100644 src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap => FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap => FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap => FusionActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Get_SDL_Download.snap => FusionActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Get_Single_Request.snap => FusionActivityServerDiagnosticListenerTests.Http_Get_Single_Request.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Parser_Error.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Single_Request.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Single_Request_Default.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request_Default.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap => FusionActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap => FusionActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap => FusionActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap => FusionActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap} (100%) rename src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/{ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap => FusionActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap} (100%) diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs index 1d679aa1217..a51c1e5d158 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/SemanticConventions.cs @@ -146,6 +146,11 @@ public static class Location } } + public static class Subscription + { + public const string Id = "graphql.subscription.id"; + } + // Note: This is not part of the OTEL semantic conventions public static class Http { diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SubscriptionEventSpan.cs b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SubscriptionEventSpan.cs new file mode 100644 index 00000000000..31e83e1e6e5 --- /dev/null +++ b/src/HotChocolate/Diagnostics/src/Diagnostics.Core/Spans/SubscriptionEventSpan.cs @@ -0,0 +1,42 @@ +using System.Diagnostics; +using System.Globalization; +using HotChocolate.Execution; +using HotChocolate.Language; +using static HotChocolate.Diagnostics.SemanticConventions; + +namespace HotChocolate.Diagnostics; + +internal sealed class SubscriptionEventSpan(Activity activity) : SpanBase(activity) +{ + public static SubscriptionEventSpan? Start( + ActivitySource source, + RequestContext context, + string? operationName, + ulong subscriptionId, + ActivityContext? subscriptionContext = null) + { + var activity = subscriptionContext is { } parent + ? source.StartActivity("GraphQL Subscription Event", ActivityKind.Internal, parent) + : source.StartActivity("GraphQL Subscription Event"); + + if (activity is null) + { + return null; + } + + activity.SetTag(GraphQL.Processing.Type, GraphQL.Processing.TypeValues.Execute); + activity.EnrichOperation(OperationType.Subscription, operationName); + activity.EnrichDocumentInfo(context.OperationDocumentInfo); + activity.SetTag(GraphQL.Subscription.Id, subscriptionId.ToString(CultureInfo.InvariantCulture)); + + return new SubscriptionEventSpan(activity); + } + + protected override void OnComplete() + { + if (Activity.Status != ActivityStatusCode.Error) + { + Activity.SetStatus(ActivityStatusCode.Ok); + } + } +} diff --git a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs index 530135bbb9f..8c5cdb9cbea 100644 --- a/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs +++ b/src/HotChocolate/Diagnostics/src/Diagnostics/Listeners/ActivityExecutionDiagnosticListener.cs @@ -240,18 +240,61 @@ public override void ResolverError(IMiddlewareContext context, IError error) } } + public override IDisposable ExecuteSubscription( + RequestContext context, + ulong subscriptionId) + { + if (Activity.Current is not { } currentActivity) + { + return EmptyScope; + } + + context.Features.Set( + new SubscriptionContextFeature + { + SubscriptionContext = currentActivity.Context + }); + + return EmptyScope; + } + public override IDisposable OnSubscriptionEvent(RequestContext context, ulong subscriptionId) { - var activity = Source.StartActivity(); + ActivityContext? subscriptionContext = null; + + if (context.Features.TryGet(out var feature) + && feature.SubscriptionContext is { } storedSubscriptionContext) + { + subscriptionContext = storedSubscriptionContext; + } + + var span = SubscriptionEventSpan.Start( + Source, + context, + context.TryGetOperation(out var operation) ? operation.Name : null, + subscriptionId, + subscriptionContext); - if (activity is null) + if (span is null) { return EmptyScope; } - enricher.EnrichOnSubscriptionEvent(context, subscriptionId, activity); + enricher.EnrichOnSubscriptionEvent(context, subscriptionId, span.Activity); - return activity; + return span; + } + + public override void SubscriptionEventError( + RequestContext context, + ulong subscriptionId, + Exception exception) + { + if (Activity.Current is { } activity) + { + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(exception); + } } public override void RetrievedDocumentFromCache(RequestContext context) @@ -285,4 +328,9 @@ public override void AddedOperationToCache(RequestContext context) span.Activity.AddEvent(new(nameof(AddedOperationToCache))); } } + + private sealed class SubscriptionContextFeature + { + public ActivityContext? SubscriptionContext { get; set; } + } } diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityExecutionDiagnosticListenerTests.cs similarity index 78% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityExecutionDiagnosticListenerTests.cs index 91013c96e5d..0afb95988a2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityExecutionDiagnosticListenerTests.cs @@ -2,12 +2,14 @@ using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.PersistedOperations; +using HotChocolate.Subscriptions; +using HotChocolate.Types; using static HotChocolate.Diagnostics.ActivityTestHelper; namespace HotChocolate.Diagnostics; [Collection("Instrumentation")] -public partial class QueryInstrumentationTests +public partial class ActivityExecutionDiagnosticListenerTests { [Fact] public async Task Track_Events_Of_A_Simple_Query_Default() @@ -369,6 +371,92 @@ public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() } } + [Fact] + public async Task SubscriptionEvent_Records_Subscription_Event_Span() + { + using var cts = new CancellationTokenSource(5000); + + using (CaptureActivities(out var activities)) + { + // arrange + var services = new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .AddSubscriptionType() + .AddInMemorySubscriptions() + .Services + .BuildServiceProvider(); + + var executor = await services.GetRequestExecutorAsync(); + var sender = services.GetRequiredService(); + + await using var result = await executor.ExecuteAsync( + "subscription OnMessageSubscription { onMessage }"); + await using var responseStream = result.ExpectResponseStream(); + + var results = responseStream.ReadResultsAsync().GetAsyncEnumerator(cts.Token); + + try + { + var moveNext = results.MoveNextAsync().AsTask(); + await sender.SendAsync("OnMessage", "hello", cts.Token); + Assert.True(await moveNext); + await sender.CompleteAsync("OnMessage"); + } + finally + { + await results.DisposeAsync(); + } + + // assert + activities.MatchSnapshot(); + } + } + + [Fact] + public async Task SubscriptionEventError_Records_Subscription_Event_Error() + { + using var cts = new CancellationTokenSource(5000); + + using (CaptureActivities(out var activities)) + { + // arrange + var services = new ServiceCollection() + .AddGraphQL() + .AddInstrumentation(o => o.Scopes = ActivityScopes.All) + .AddQueryType() + .AddSubscriptionType() + .AddInMemorySubscriptions() + .Services + .BuildServiceProvider(); + + var executor = await services.GetRequestExecutorAsync(); + var sender = services.GetRequiredService(); + + await using var result = await executor.ExecuteAsync( + "subscription OnFailingMessageSubscription { onFailingMessage }"); + await using var responseStream = result.ExpectResponseStream(); + + var results = responseStream.ReadResultsAsync().GetAsyncEnumerator(cts.Token); + + try + { + var moveNext = results.MoveNextAsync().AsTask(); + await sender.SendAsync("OnFailingMessage", "hello", cts.Token); + Assert.True(await moveNext); + await sender.CompleteAsync("OnFailingMessage"); + } + finally + { + await results.DisposeAsync(); + } + + // assert + activities.MatchSnapshot(); + } + } + public class SimpleQuery { public string SayHello() => "hello"; @@ -395,6 +483,16 @@ public class Deeper public Deep[] Deeps() => [new Deep()]; } + public class SimpleSubscription + { + [Subscribe] + public string OnMessage([EventMessage] string message) => message; + + [Subscribe] + public string OnFailingMessage([EventMessage] string message) + => throw new InvalidOperationException("Subscription event failed."); + } + private sealed class InMemoryOperationDocumentStorage : IOperationDocumentStorage { private readonly Dictionary _cache = []; diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityServerDiagnosticListenerTests.cs similarity index 98% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityServerDiagnosticListenerTests.cs index ea5b6b75e64..f4da56a8650 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityServerDiagnosticListenerTests.cs @@ -8,15 +8,10 @@ namespace HotChocolate.Diagnostics; [Collection("Instrumentation")] -public class ServerInstrumentationTests : ServerTestBase +public class ActivityServerDiagnosticListenerTests(TestServerFactory serverFactory) : ServerTestBase(serverFactory) { private static readonly Uri s_url = new("http://localhost:5000/graphql"); - public ServerInstrumentationTests(TestServerFactory serverFactory) - : base(serverFactory) - { - } - [Fact] public async Task Http_Post_SingleRequest_GetHeroName_Default() { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs index bc6aada2949..78e6a5b5d94 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs @@ -15,6 +15,7 @@ public static IDisposable CaptureActivities(out object activities) var listener = new ActivityListener(); var root = new OrderedDictionary(); var lookup = new Dictionary>(); + var spanLookup = new Dictionary>(); Activity rootActivity = null!; listener.ShouldListenTo = source => source.Name.EqualsOrdinal("HotChocolate.Diagnostics"); @@ -35,6 +36,17 @@ public static IDisposable CaptureActivities(out object activities) { RegisterActivity(a, parentData); lookup[a] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + spanLookup[a.SpanId] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + return; + } + + if (a.Parent is null + && a.ParentSpanId != default + && spanLookup.TryGetValue(a.ParentSpanId, out parentData)) + { + RegisterActivity(a, parentData); + lookup[a] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + spanLookup[a.SpanId] = (OrderedDictionary)a.GetCustomProperty("test.data")!; } } }; @@ -46,6 +58,7 @@ public static IDisposable CaptureActivities(out object activities) rootActivity = HotChocolateActivitySource.Source.StartActivity()!; rootActivity.SetCustomProperty("test.data", root); lookup[rootActivity] = root; + spanLookup[rootActivity.SpanId] = root; activities = root; return new Session(rootActivity, listener); diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs index 06d8ebdf422..255914f2b0e 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/CustomDataLoader.cs @@ -2,7 +2,7 @@ namespace HotChocolate.Diagnostics; -public partial class QueryInstrumentationTests +public partial class ActivityExecutionDiagnosticListenerTests { public class CustomDataLoader(IBatchScheduler batchScheduler, DataLoaderOptions options) : BatchDataLoader(batchScheduler, options) diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.AllScopes_IncludesExecuteRequestAndParseDocumentSpans.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ComplexityAnalysis_Enabled_RecordsCostInSpan.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndCompile_LimitsSpans.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_RecordsBatchSpan.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_RecordsBatchSpan.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_RecordsBatchSpan.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DataLoader_BatchExecution_With_Keys_RecordsBatchSpan.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ResolverError_AtRootLevel_MarksOperationAsError.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_AtRootLevel_MarksOperationAsError.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ResolverError_AtRootLevel_MarksOperationAsError.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ResolverError_DeepInTree_MarksNestedFieldAsError.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap new file mode 100644 index 00000000000..820e47e0f23 --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap @@ -0,0 +1,201 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "subscription", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnFailingMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnFailingMessageSubscription" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnFailingMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Subscription Event", + "DisplayName": "GraphQL Subscription Event", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnFailingMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:1f38a1bfe720ad0cb6083bf8b309d3aa" + }, + { + "Key": "graphql.subscription.id", + "Value": "1" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleSubscription.onFailingMessage", + "DisplayName": "SimpleSubscription.onFailingMessage", + "Status": "Error", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "onFailingMessage" + }, + { + "Key": "graphql.selection.path", + "Value": "onFailingMessage" + }, + { + "Key": "graphql.selection.field.name", + "Value": "onFailingMessage" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleSubscription.onFailingMessage" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleSubscription" + } + ], + "event": [ + { + "Name": "exception", + "Tags": [ + { + "Key": "graphql.error.message", + "Value": "Unexpected Execution Error" + }, + { + "Key": "exception.message", + "Value": "Subscription event failed." + }, + { + "Key": "exception.stacktrace", + "Value": "System.InvalidOperationException: Subscription event failed.\n at HotChocolate.Diagnostics.ActivityExecutionDiagnosticListenerTests.SimpleSubscription.OnFailingMessage(String message) in ActivityExecutionDiagnosticListenerTests.cs:line 493\n at lambda_method58(Closure, IResolverContext)\n at HotChocolate.Types.Helpers.FieldMiddlewareCompiler.<>c__DisplayClass9_0.<b__0>d.MoveNext() in FieldMiddlewareCompiler.cs:line 127\n--- End of stack trace from previous location ---\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 135\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 81" + }, + { + "Key": "exception.type", + "Value": "System.InvalidOperationException" + }, + { + "Key": "graphql.error.path", + "Value": "onFailingMessage" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap new file mode 100644 index 00000000000..dab79a8bcac --- /dev/null +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap @@ -0,0 +1,175 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "subscription", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [ + { + "Name": "AddedOperationToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Subscription Event", + "DisplayName": "GraphQL Subscription Event", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + }, + { + "Key": "graphql.subscription.id", + "Value": "1" + } + ], + "event": [], + "activities": [ + { + "OperationName": "SimpleSubscription.onMessage", + "DisplayName": "SimpleSubscription.onMessage", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "resolve" + }, + { + "Key": "graphql.selection.name", + "Value": "onMessage" + }, + { + "Key": "graphql.selection.path", + "Value": "onMessage" + }, + { + "Key": "graphql.selection.field.name", + "Value": "onMessage" + }, + { + "Key": "graphql.selection.field.coordinate", + "Value": "SimpleSubscription.onMessage" + }, + { + "Key": "graphql.selection.field.parent_type", + "Value": "SimpleSubscription" + } + ], + "event": [] + } + ] + } + ] + } + ] + } + ] +} diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.VariableCoercion_WithAllScopes_RecordsCoercionSpan.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Get_SingleRequest_GetHeroName.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SingleRequest_GetHeroName.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Get_SingleRequest_GetHeroName.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Capture_Deferred_Response.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Capture_Deferred_Response.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Capture_Deferred_Response.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Ensure_List_Path_Is_Correctly_Built.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName_Default.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_SingleRequest_GetHeroName_Default.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_SingleRequest_GetHeroName_Default.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap similarity index 100% rename from src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap rename to src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap diff --git a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs index b3b2ecb4ead..8abbe68e970 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -19,38 +19,70 @@ public class FusionActivityEnricher(InstrumentationOptions options) : ActivityEn public virtual void EnrichPlanOperation( RequestContext context, string operationPlanId, - Activity activity) { } + Activity activity) + { + } public virtual void EnrichExecutePlanNode( OperationPlanContext context, ExecutionNode node, string? schemaName, - Activity activity) { } + Activity activity) + { + } public virtual void EnrichExecutionNodeError( OperationPlanContext context, ExecutionNode node, Exception exception, - Activity activity) { } + Activity activity) + { + } public virtual void EnrichSourceSchemaTransportError( OperationPlanContext context, ExecutionNode node, string schemaName, Exception exception, - Activity activity) { } + Activity activity) + { + } public virtual void EnrichSourceSchemaStoreError( OperationPlanContext context, ExecutionNode node, string schemaName, Exception exception, - Activity activity) { } + Activity activity) + { + } public virtual void EnrichOnSubscriptionEvent( OperationPlanContext context, ExecutionNode node, string schemaName, ulong subscriptionId, - Activity activity) { } + Activity activity) + { + } + + public virtual void EnrichSubscriptionTransportError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId, + Exception exception, + Activity activity) + { + } + + public virtual void EnrichSubscriptionEventError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId, + Exception exception, + Activity featureActivity) + { + } } diff --git a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 367babe2bb2..268fb537c07 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -188,6 +188,22 @@ public override IDisposable ExecuteOperationBatchNode( string schemaName) => ExecuteNode(context, node, schemaName); + public override IDisposable ExecuteSubscriptionNode( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId) + { + var nodeScope = ExecuteNode(context, node, schemaName); + context.RequestContext.Features.Set( + new SubscriptionContextFeature + { + SubscriptionContext = Activity.Current?.Context + }); + + return nodeScope; + } + public override IDisposable ExecuteNodeFieldNode( OperationPlanContext context, NodeFieldExecutionNode node) @@ -248,16 +264,66 @@ public override IDisposable OnSubscriptionEvent( string schemaName, ulong subscriptionId) { - var activity = Source.StartActivity(); + ActivityContext? subscriptionContext = null; + + if (context.RequestContext.Features.TryGet(out var feature) + && feature.SubscriptionContext is { } storedSubscriptionContext) + { + subscriptionContext = storedSubscriptionContext; + } - if (activity is null) + var span = SubscriptionEventSpan.Start( + Source, + context.RequestContext, + context.OperationPlan.Operation.Name, + subscriptionId, + subscriptionContext); + + if (span is null) { return EmptyScope; } - enricher.EnrichOnSubscriptionEvent(context, node, schemaName, subscriptionId, activity); + enricher.EnrichOnSubscriptionEvent(context, node, schemaName, subscriptionId, span.Activity); + + return span; + } + + public override void SubscriptionEventError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId, + Exception exception) + { + if (Activity.Current is { } activity) + { + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(exception); + enricher.EnrichSubscriptionEventError( + context, + node, + schemaName, + subscriptionId, + exception, + activity); + } + } + + public override void SubscriptionTransportError( + OperationPlanContext context, + ExecutionNode node, + string schemaName, + ulong subscriptionId, + Exception exception) + { + if (Activity.Current is { } activity) + { + activity.SetStatus(ActivityStatusCode.Error); + activity.AddException(exception); - return activity; + enricher.EnrichSubscriptionTransportError(context, node, schemaName, subscriptionId, exception, activity); + } } public override void RetrievedDocumentFromCache(RequestContext context) @@ -292,6 +358,11 @@ public override void AddedOperationPlanToCache(RequestContext context, string op } } + private sealed class SubscriptionContextFeature + { + public ActivityContext? SubscriptionContext { get; set; } + } + private IDisposable ExecuteNode(OperationPlanContext context, ExecutionNode node, string? schemaName) { if (options.SkipExecutePlanNodes) diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs index 22807369e83..73d6efe9eac 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ActivityTestHelper.cs @@ -14,6 +14,7 @@ public static IDisposable CaptureActivities(out object activities) var listener = new ActivityListener(); var root = new OrderedDictionary(); var lookup = new Dictionary>(); + var spanLookup = new Dictionary>(); Activity rootActivity = null!; listener.ShouldListenTo = source => @@ -35,6 +36,17 @@ public static IDisposable CaptureActivities(out object activities) { RegisterActivity(a, parentData); lookup[a] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + spanLookup[a.SpanId] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + return; + } + + if (a.Parent is null + && a.ParentSpanId != default + && spanLookup.TryGetValue(a.ParentSpanId, out parentData)) + { + RegisterActivity(a, parentData); + lookup[a] = (OrderedDictionary)a.GetCustomProperty("test.data")!; + spanLookup[a.SpanId] = (OrderedDictionary)a.GetCustomProperty("test.data")!; } } }; @@ -46,6 +58,7 @@ public static IDisposable CaptureActivities(out object activities) rootActivity = HotChocolateFusionActivitySource.Source.StartActivity()!; rootActivity.SetCustomProperty("test.data", root); lookup[rootActivity] = root; + spanLookup[rootActivity.SpanId] = root; activities = root; return new Session(rootActivity, listener); diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityExecutionDiagnosticListenerTests.cs similarity index 77% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityExecutionDiagnosticListenerTests.cs index ac51445d5b5..848b1658fc7 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/QueryInstrumentationTests.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityExecutionDiagnosticListenerTests.cs @@ -1,14 +1,14 @@ -using HotChocolate.Diagnostics; using HotChocolate.Execution; using HotChocolate.Language; using HotChocolate.PersistedOperations; +using HotChocolate.Types; using Microsoft.Extensions.DependencyInjection; using static HotChocolate.Fusion.Diagnostics.ActivityTestHelper; namespace HotChocolate.Fusion.Diagnostics; [Collection("Instrumentation")] -public class QueryInstrumentationTests : FusionTestBase +public class FusionActivityExecutionDiagnosticListenerTests : FusionTestBase { [Fact] public async Task Track_Events_Of_A_Simple_Query_Default() @@ -525,6 +525,139 @@ public async Task DocumentCache_SecondExecution_RecordsCacheHitEvent() } } + [Fact] + public async Task SubscriptionEvent_Records_Subscription_Event_Span() + { + using var cts = new CancellationTokenSource(5000); + + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b + .AddQueryType() + .AddSubscriptionType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + // act + await using var result = await executor.ExecuteAsync( + "subscription OnMessageSubscription { onMessage }"); + await using var responseStream = result.ExpectResponseStream(); + var results = responseStream.ReadResultsAsync().GetAsyncEnumerator(cts.Token); + + try + { + Assert.True(await results.MoveNextAsync()); + } + finally + { + await results.DisposeAsync(); + } + + // assert + activities.MatchSnapshot(); + } + } + + [Fact(Skip = "Errors are not correctly triggered")] + public async Task SubscriptionEventError_Records_Subscription_Event_Error() + { + using var cts = new CancellationTokenSource(5000); + + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b + .AddQueryType() + .AddSubscriptionType()); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + // act + await using var result = await executor.ExecuteAsync( + "subscription OnFailingMessageSubscription { onFailingMessage }"); + await using var responseStream = result.ExpectResponseStream(); + var results = responseStream.ReadResultsAsync().GetAsyncEnumerator(cts.Token); + + try + { + Assert.True(await results.MoveNextAsync()); + } + finally + { + await results.DisposeAsync(); + } + + // assert + activities.MatchSnapshot(); + } + } + + [Fact(Skip = "Errors are not correctly triggered")] + public async Task SubscriptionRequestFails_When_SourceSchema_Is_Offline() + { + using (CaptureActivities(out var activities)) + { + // arrange + using var server1 = CreateSourceSchema( + "a", + b => b + .AddQueryType() + .AddSubscriptionType(), + isOffline: true); + + using var gateway = await CreateCompositeSchemaAsync( + [ + ("a", server1) + ], + configureGatewayBuilder: b => b.AddInstrumentation(o => + o.Scopes = FusionActivityScopes.All)); + + var executor = await gateway.Services.GetRequestExecutorAsync(); + + // act + IExecutionResult? result = null; + + try + { + result = await executor.ExecuteAsync( + "subscription OnMessageSubscription { onMessage }"); + } + catch + { + // expected for failed subscription handshake. + } + finally + { + if (result is not null) + { + await result.DisposeAsync(); + } + } + + // assert + activities.MatchSnapshot(); + } + } + public class Query { public string SayHello() => "hello"; @@ -576,6 +709,28 @@ public class Deeper public Deep[] Deeps() => [new Deep()]; } + public class Subscription + { + public async IAsyncEnumerable OnMessageStream() + { + yield return "hello"; + await Task.CompletedTask; + } + + [Subscribe(With = nameof(OnMessageStream))] + public string OnMessage([EventMessage] string message) => message; + + public async IAsyncEnumerable OnFailingMessageStream() + { + yield return "hello"; + await Task.CompletedTask; + } + + [Subscribe(With = nameof(OnFailingMessageStream))] + public string OnFailingMessage([EventMessage] string message) + => throw new InvalidOperationException("Subscription event failed."); + } + private sealed class InMemoryOperationDocumentStorage : IOperationDocumentStorage { private readonly Dictionary _cache = []; diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityServerDiagnosticListenerTests.cs similarity index 99% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityServerDiagnosticListenerTests.cs index afed8158024..fd0d7d27498 100644 --- a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/ServerInstrumentationTests.cs +++ b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionActivityServerDiagnosticListenerTests.cs @@ -7,7 +7,7 @@ namespace HotChocolate.Fusion.Diagnostics; [Collection("Instrumentation")] -public class ServerInstrumentationTests : FusionTestBase +public class FusionActivityServerDiagnosticListenerTests : FusionTestBase { private static readonly Uri s_url = new("http://localhost:5000/graphql"); diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.AllScopes_IncludesAllSpans.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.AllScopes_IncludesAllSpans.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.AllScopes_IncludesAllSpans.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Allow_Document_To_Be_Captured.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Allow_Document_To_Be_Captured.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Cause_A_Resolver_Error_That_Deletes_The_Whole_Result.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.CustomScopes_OnlyValidateAndPlan_LimitsSpans.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.DefaultScopes_ExcludesExecuteRequestAndParseDocumentSpans.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.DocumentCache_SecondExecution_RecordsCacheHitEvent.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Ensure_That_The_Validation_Activity_Has_An_Error_Status.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.MultipleSources_SourceSchemaResolverError_RecordsDeeplyNestedError.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.ParsingError_InvalidGraphQLDocument_ReportsErrorStatus.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.PersistedOperation_LoadsFromStorage_DefaultScopes.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Source_Schema_Transport_Error.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Source_Schema_Transport_Error.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Source_Schema_Transport_Error.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap new file mode 100644 index 00000000000..255ef236318 --- /dev/null +++ b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.SubscriptionEvent_Records_Subscription_Event_Span.snap @@ -0,0 +1,193 @@ +{ + "activities": [ + { + "OperationName": "GraphQL Operation", + "DisplayName": "subscription", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [ + { + "Name": "AddedOperationPlanToCache", + "Tags": [] + }, + { + "Name": "AddedDocumentToCache", + "Tags": [] + } + ], + "activities": [ + { + "OperationName": "GraphQL Document Parsing", + "DisplayName": "GraphQL Document Parsing", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Document Validation", + "DisplayName": "GraphQL Document Validation", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "validate" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Planning", + "DisplayName": "GraphQL Operation Planning", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "plan" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + } + ], + "event": [] + }, + { + "OperationName": "GraphQL Operation Execution", + "DisplayName": "GraphQL Operation Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + } + ], + "event": [] + } + ] + }, + { + "OperationName": "GraphQL Step Execution", + "DisplayName": "GraphQL Step Execution", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "step_execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + }, + { + "Key": "graphql.operation.step.id", + "Value": "1" + }, + { + "Key": "graphql.operation.step.kind", + "Value": "operation" + }, + { + "Key": "graphql.operation.step.plan.id", + "Value": "2e566740582971b4b247348976bca6cb8a84255526b80e73273aa94781bca0fc" + }, + { + "Key": "graphql.source.name", + "Value": "a" + }, + { + "Key": "graphql.source.operation.name", + "Value": "OnMessageSubscription_ef859b98_1" + }, + { + "Key": "graphql.source.operation.kind", + "Value": "subscription" + }, + { + "Key": "graphql.source.operation.hash", + "Value": "sha256:f9abddbb651ad8e118793eb7c4a7c8db7fe43cae95faba710a0ff35b26b17136" + } + ], + "event": [], + "activities": [ + { + "OperationName": "GraphQL Subscription Event", + "DisplayName": "GraphQL Subscription Event", + "Status": "Ok", + "tags": [ + { + "Key": "graphql.processing.type", + "Value": "execute" + }, + { + "Key": "graphql.operation.type", + "Value": "subscription" + }, + { + "Key": "graphql.operation.name", + "Value": "OnMessageSubscription" + }, + { + "Key": "graphql.document.hash", + "Value": "md5:ef859b98c9d8c17038c8fd9aeecdb1e2" + }, + { + "Key": "graphql.subscription.id", + "Value": "1" + } + ], + "event": [] + } + ] + } + ] +} diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Query_With_Multiple_Sources.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.Track_Events_Of_A_Simple_Query_Default.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.Track_Events_Of_A_Simple_Query_Default.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/QueryInstrumentationTests.ValidationError_UnknownField_ReportsErrorStatus.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityExecutionDiagnosticListenerTests.ValidationError_UnknownField_ReportsErrorStatus.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_SDL_Download.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Get_SDL_Download.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Get_Single_Request.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Get_Single_Request.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Get_Single_Request.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Add_Variables_To_Http_Activity.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Add_Variables_To_Http_Activity.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Parser_Error.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Parser_Error.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request_Default.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Single_Request_Default.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Single_Request_Default.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_Variables_Are_Not_Automatically_Added_To_Activities.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.Http_Post_With_Extensions_Map.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.Http_Post_With_Extensions_Map.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_All_IncludesAllDetails.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_All_IncludesAllDetails.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_Default_IncludesIdHashOperationNameExtensions.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_DocumentOnly_IncludesDocumentTag.snap diff --git a/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap b/src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap similarity index 100% rename from src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/ServerInstrumentationTests.RequestDetails_None_ExcludesAllDetails.snap rename to src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/__snapshots__/FusionActivityServerDiagnosticListenerTests.RequestDetails_None_ExcludesAllDetails.snap diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index e8882ad8ec2..e32beec16f7 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -701,6 +701,8 @@ The OpenTelemetry spans and attributes emitted by `AddInstrumentation()` have be If you have dashboards or alerts that filter on the old attribute names or values, update them accordingly. +Besides changes to the attributes, the most notable change is that the name of the root GraphQL span has been changed to just include the operation type (`query`, `mutation` or `subscription`), and no longer the operation name, to keep the cardinality low. The operation name can still be retrieved from the `graphql.operation.name` span attribute. + ### Removed attributes | Attribute | From 55d06e7d03a35a0915491a61989bbcb4cfe0a7f4 Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 21:02:54 +0100 Subject: [PATCH 36/37] Consolidate source schema errors --- .../FusionActivityEnricher.cs | 10 ------ ...ctivityExecutionDiagnosticEventListener.cs | 17 +--------- ...ggregateFusionExecutionDiagnosticEvents.cs | 18 ----------- .../FusionExecutionDiagnosticEventListener.cs | 10 ------ .../IFusionExecutionDiagnosticEvents.cs | 27 ---------------- .../Execution/Nodes/OperationExecutionNode.cs | 2 +- .../v16/migrating/migrate-from-15-to-16.md | 32 +++++++++++++++++++ 7 files changed, 34 insertions(+), 82 deletions(-) diff --git a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs index 8abbe68e970..8a430c4b744 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/FusionActivityEnricher.cs @@ -66,16 +66,6 @@ public virtual void EnrichOnSubscriptionEvent( { } - public virtual void EnrichSubscriptionTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId, - Exception exception, - Activity activity) - { - } - public virtual void EnrichSubscriptionEventError( OperationPlanContext context, ExecutionNode node, diff --git a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs index 268fb537c07..816544718d6 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Diagnostics/Listeners/FusionActivityExecutionDiagnosticEventListener.cs @@ -300,6 +300,7 @@ public override void SubscriptionEventError( { activity.SetStatus(ActivityStatusCode.Error); activity.AddException(exception); + enricher.EnrichSubscriptionEventError( context, node, @@ -310,22 +311,6 @@ public override void SubscriptionEventError( } } - public override void SubscriptionTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId, - Exception exception) - { - if (Activity.Current is { } activity) - { - activity.SetStatus(ActivityStatusCode.Error); - activity.AddException(exception); - - enricher.EnrichSubscriptionTransportError(context, node, schemaName, subscriptionId, exception, activity); - } - } - public override void RetrievedDocumentFromCache(RequestContext context) { if (context.Features.TryGet(out var span)) diff --git a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs index 4012cf3643a..c2ef7993abc 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/AggregateFusionExecutionDiagnosticEvents.cs @@ -259,24 +259,6 @@ public IDisposable ExecuteSubscriptionNode( return new AggregateActivityScope(scopes); } - public void SubscriptionTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId, - Exception exception) - { - for (var i = 0; i < listeners.Length; i++) - { - listeners[i].SubscriptionTransportError( - context, - node, - schemaName, - subscriptionId, - exception); - } - } - public void SubscriptionEventError( OperationPlanContext context, ExecutionNode node, diff --git a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs index a967a80f601..aa224864e45 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/FusionExecutionDiagnosticEventListener.cs @@ -137,16 +137,6 @@ public virtual IDisposable ExecuteSubscriptionNode( ulong subscriptionId) => EmptyScope; - /// - public virtual void SubscriptionTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId, - Exception exception) - { - } - /// public virtual void SubscriptionEventError( OperationPlanContext context, diff --git a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs index f25cd9bfa6d..81284ae5c0d 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Execution/Diagnostics/IFusionExecutionDiagnosticEvents.cs @@ -234,33 +234,6 @@ void SourceSchemaStoreError( string schemaName, Exception error); - /// - /// Called when a transport error occurs while communicating with a source schema - /// during subscription operations. This includes connection drops, network timeouts, - /// and other communication failures specific to real-time subscriptions. - /// - /// - /// The operation plan context. - /// - /// - /// The execution node that was storing the response. - /// - /// - /// The name of the source schema whose response could not be stored. - /// - /// - /// An internal identifier for the subscription instance. - /// - /// - /// The transport exception that occurred. - /// - void SubscriptionTransportError( - OperationPlanContext context, - ExecutionNode node, - string schemaName, - ulong subscriptionId, - Exception exception); - /// /// Called when an error occurs while processing a subscription event result. /// This covers errors in event handling, data transformation, or result generation diff --git a/src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs b/src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs index aae561d3d1d..e0a7d462099 100644 --- a/src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs +++ b/src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs @@ -317,7 +317,7 @@ internal async Task SubscribeAsync( catch (Exception ex) { AddErrors(context, ex, variables, _responseNames); - context.DiagnosticEvents.SubscriptionTransportError(context, this, schemaName, subscriptionId, ex); + context.DiagnosticEvents.SourceSchemaTransportError(context, this, schemaName, ex); return SubscriptionResult.Failed(subscriptionId, ex); } } diff --git a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md index e32beec16f7..a9f75cf24c9 100644 --- a/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md +++ b/website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md @@ -777,6 +777,38 @@ We removed the following methods from the `IExecutionDiagnosticEventListener` si Some other methods also had a change in their signature - simply override them again to fix any compilation issues. + + # Deprecations Things that will continue to function this release, but we encourage you to move away from. From 2c6ac348ff2e251b4c8bcce3795fe948b2a6694b Mon Sep 17 00:00:00 2001 From: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com> Date: Fri, 13 Mar 2026 21:09:52 +0100 Subject: [PATCH 37/37] Fix lambda function flakiness --- .../test/Diagnostics.Tests/ActivityTestHelper.cs | 16 ++++++++++------ ...ntError_Records_Subscription_Event_Error.snap | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs index 78e6a5b5d94..97bd9804ec2 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/ActivityTestHelper.cs @@ -8,6 +8,8 @@ public static partial class ActivityTestHelper { [GeneratedRegex(@" in (?.+?):line (?\d+)", RegexOptions.CultureInvariant)] private static partial Regex StackTracePathRegex(); + [GeneratedRegex(@"lambda_method\d+", RegexOptions.CultureInvariant)] + private static partial Regex LambdaMethodRegex(); public static IDisposable CaptureActivities(out object activities) { @@ -114,14 +116,16 @@ private static void SerializeActivity(Activity activity) && (tag.Key.Equals("exception.stacktrace", StringComparison.Ordinal) || tag.Key.EndsWith(".stacktrace", StringComparison.Ordinal))) { + var scrubbedStackTrace = StackTracePathRegex().Replace(stackTrace, match => + { + var fileName = System.IO.Path.GetFileName(match.Groups["path"].Value); + var lineNumber = match.Groups["line"].Value; + return $" in {fileName}:line {lineNumber}"; + }); + yield return new KeyValuePair( tag.Key, - StackTracePathRegex().Replace(stackTrace, match => - { - var fileName = System.IO.Path.GetFileName(match.Groups["path"].Value); - var lineNumber = match.Groups["line"].Value; - return $" in {fileName}:line {lineNumber}"; - })); + LambdaMethodRegex().Replace(scrubbedStackTrace, "lambda_method")); } else { diff --git a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap index 820e47e0f23..f96698c579d 100644 --- a/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap +++ b/src/HotChocolate/Diagnostics/test/Diagnostics.Tests/__snapshots__/ActivityExecutionDiagnosticListenerTests.SubscriptionEventError_Records_Subscription_Event_Error.snap @@ -177,7 +177,7 @@ }, { "Key": "exception.stacktrace", - "Value": "System.InvalidOperationException: Subscription event failed.\n at HotChocolate.Diagnostics.ActivityExecutionDiagnosticListenerTests.SimpleSubscription.OnFailingMessage(String message) in ActivityExecutionDiagnosticListenerTests.cs:line 493\n at lambda_method58(Closure, IResolverContext)\n at HotChocolate.Types.Helpers.FieldMiddlewareCompiler.<>c__DisplayClass9_0.<b__0>d.MoveNext() in FieldMiddlewareCompiler.cs:line 127\n--- End of stack trace from previous location ---\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 135\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 81" + "Value": "System.InvalidOperationException: Subscription event failed.\n at HotChocolate.Diagnostics.ActivityExecutionDiagnosticListenerTests.SimpleSubscription.OnFailingMessage(String message) in ActivityExecutionDiagnosticListenerTests.cs:line 493\n at lambda_method(Closure, IResolverContext)\n at HotChocolate.Types.Helpers.FieldMiddlewareCompiler.<>c__DisplayClass9_0.<b__0>d.MoveNext() in FieldMiddlewareCompiler.cs:line 127\n--- End of stack trace from previous location ---\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 135\n at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken) in ResolverTask.Execute.cs:line 81" }, { "Key": "exception.type",