From f70ad1835dd7f2dc976bf9f6477944cc74fdde58 Mon Sep 17 00:00:00 2001 From: Gabriel Lucaci Date: Wed, 12 Jan 2022 17:17:53 +0100 Subject: [PATCH] Update to HotChocolate 12 (#16) * Migrate to HC 12 * Upgrade APM to 1.12.0 and HC to 12.0.0 (#15) Co-authored-by: Vadim Hatsura --- src/Dependencies.props | 4 ++-- .../HotChocolateDiagnosticListener.cs | 8 ++++---- .../Scopes/FieldActivityScope.cs | 4 ++-- .../Scopes/RequestActivityScope.cs | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Dependencies.props b/src/Dependencies.props index 5154012..c8d1da9 100644 --- a/src/Dependencies.props +++ b/src/Dependencies.props @@ -1,8 +1,8 @@ - 1.8.0 - 11.0.0 + 1.12.0 + 12.0.0 7.1.0 4.7.0 diff --git a/src/Elastic.Apm.GraphQL.HotChocolate/HotChocolateDiagnosticListener.cs b/src/Elastic.Apm.GraphQL.HotChocolate/HotChocolateDiagnosticListener.cs index 726ee67..fc53c17 100644 --- a/src/Elastic.Apm.GraphQL.HotChocolate/HotChocolateDiagnosticListener.cs +++ b/src/Elastic.Apm.GraphQL.HotChocolate/HotChocolateDiagnosticListener.cs @@ -12,7 +12,7 @@ namespace Elastic.Apm.GraphQL.HotChocolate { - internal class HotChocolateDiagnosticListener : DiagnosticEventListener + internal class HotChocolateDiagnosticListener : ExecutionDiagnosticEventListener { private static readonly string ResolveFieldValueFailed = $"{nameof(ResolveFieldValue)} failed."; @@ -32,7 +32,7 @@ internal HotChocolateDiagnosticListener( _apmLogger = _apmAgent.Logger; } - public override IActivityScope ExecuteRequest(IRequestContext context) + public override IDisposable ExecuteRequest(IRequestContext context) { ITransaction? transaction = _apmAgent.Tracer.CurrentTransaction; return transaction != null @@ -40,7 +40,7 @@ public override IActivityScope ExecuteRequest(IRequestContext context) : EmptyScope; } - public override IActivityScope ResolveFieldValue(IMiddlewareContext context) + public override IDisposable ResolveFieldValue(IMiddlewareContext context) { if (_configuration.LogLevel > LogLevel.Debug) { @@ -58,7 +58,7 @@ public override IActivityScope ResolveFieldValue(IMiddlewareContext context) if (executionSegment == null) return EmptyScope; ISpan span = executionSegment.StartSpan( - context.Field.Name!.Value, ApiConstants.TypeRequest, Constants.Apm.SubType); + context.Selection.Field.Name, ApiConstants.TypeRequest, Constants.Apm.SubType); return new FieldActivityScope(span); } diff --git a/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/FieldActivityScope.cs b/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/FieldActivityScope.cs index b2eb79d..a3ed47b 100644 --- a/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/FieldActivityScope.cs +++ b/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/FieldActivityScope.cs @@ -1,9 +1,9 @@ +using System; using Elastic.Apm.Api; -using HotChocolate.Execution.Instrumentation; namespace Elastic.Apm.GraphQL.HotChocolate { - internal class FieldActivityScope : IActivityScope + internal class FieldActivityScope : IDisposable { private readonly ISpan _span; diff --git a/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/RequestActivityScope.cs b/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/RequestActivityScope.cs index 568e70c..26040af 100644 --- a/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/RequestActivityScope.cs +++ b/src/Elastic.Apm.GraphQL.HotChocolate/Scopes/RequestActivityScope.cs @@ -5,13 +5,12 @@ using Elastic.Apm.Api; using Elastic.Apm.Logging; using HotChocolate.Execution; -using HotChocolate.Execution.Instrumentation; using HotChocolate.Language; using IError = HotChocolate.IError; namespace Elastic.Apm.GraphQL.HotChocolate { - internal class RequestActivityScope : IActivityScope + internal class RequestActivityScope : IDisposable { private static readonly string ExecuteRequestFailed = "ExecuteRequest instrumentation failed.";