Skip to content

Commit

Permalink
Update to HotChocolate 12 (#16)
Browse files Browse the repository at this point in the history
* Migrate to HC 12
* Upgrade APM to 1.12.0 and HC to 12.0.0 (#15)
Co-authored-by: Vadim Hatsura <[email protected]>
  • Loading branch information
glucaci authored Jan 12, 2022
1 parent aa256e8 commit f70ad18
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Dependencies.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>

<PropertyGroup>
<ElasticApmVersion>1.8.0</ElasticApmVersion>
<HotChocolateVersion>11.0.0</HotChocolateVersion>
<ElasticApmVersion>1.12.0</ElasticApmVersion>
<HotChocolateVersion>12.0.0</HotChocolateVersion>
<MassTransitVersion>7.1.0</MassTransitVersion>
<SystemDiagnosticSourceVersion>4.7.0</SystemDiagnosticSourceVersion>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.";

Expand All @@ -32,15 +32,15 @@ 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
? new RequestActivityScope(context, transaction, _apmAgent, _options)
: EmptyScope;
}

public override IActivityScope ResolveFieldValue(IMiddlewareContext context)
public override IDisposable ResolveFieldValue(IMiddlewareContext context)
{
if (_configuration.LogLevel > LogLevel.Debug)
{
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.";

Expand Down

0 comments on commit f70ad18

Please sign in to comment.