Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public void AddException(Exception exception)
public void AddGraphQLErrorEvent(
IError error,
string? operationType = null,
string? operationName = null)
string? operationName = null,
string? schemaCoordinate = null)
{
var tags = new ActivityTagsCollection
{
Expand All @@ -59,6 +60,11 @@ public void AddGraphQLErrorEvent(
tags[SemanticConventions.GraphQL.Field.Path] = error.Path.Print();
}

if (!string.IsNullOrEmpty(schemaCoordinate))
{
tags[SemanticConventions.GraphQL.Field.SchemaCoordinate] = schemaCoordinate;
}

if (!string.IsNullOrEmpty(error.Code))
{
tags[SemanticConventions.GraphQL.Error.Code] = error.Code;
Expand Down Expand Up @@ -100,6 +106,38 @@ public void AddGraphQLErrorEvent(
activity.AddEvent(new ActivityEvent("graphql.error", default, tags));
}

public void AddGraphQLErrorEvent(
Exception exception,
string? operationType = null,
string? operationName = null,
string? schemaCoordinate = null)
{
var tags = new ActivityTagsCollection
{
[SemanticConventions.GraphQL.Error.Message] = exception.Message,
["exception.type"] = exception.GetType().FullName,
["exception.message"] = exception.Message,
["exception.stacktrace"] = exception.ToString()
};

if (!string.IsNullOrEmpty(schemaCoordinate))
{
tags[SemanticConventions.GraphQL.Field.SchemaCoordinate] = schemaCoordinate;
}

if (!string.IsNullOrEmpty(operationType))
{
tags[SemanticConventions.GraphQL.Operation.Type] = operationType;
}

if (!string.IsNullOrEmpty(operationName))
{
tags[SemanticConventions.GraphQL.Operation.Name] = operationName;
}

activity.AddEvent(new ActivityEvent("graphql.error", default, tags));
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetErrorType(Exception exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public static class Field
public const string Path = "graphql.field.path";
public const string Name = "graphql.field.name";
public const string ParentType = "graphql.field.parent_type";
public const string Coordinate = "graphql.field.coordinate";
public const string SchemaCoordinate = "graphql.field.schema_coordinate";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ protected override void OnComplete()

if (Context.Result is OperationResult result)
{
// This was previously also always set to 0, so I just kept that behavior.
Activity.SetTag(GraphQL.Error.Count, result.Errors.Count);
if (result.Errors.Count > 0)
{
Activity.SetTag(GraphQL.Error.Count, result.Errors.Count);
}

EmitErrorEvents(result.Errors, operationTypeValue, operationName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ public override void ResolverError(IMiddlewareContext context, IError error)
error,
operationType: SemanticConventions.GraphQL.Operation.TypeValues[
context.Operation.Definition.Operation],
operationName: context.Operation.Name);
operationName: context.Operation.Name,
schemaCoordinate: context.Selection.Field.Coordinate.ToString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal sealed class ResolveFieldSpan(
activity.SetTag(GraphQL.Field.Alias, selection.ResponseName);
activity.SetTag(GraphQL.Field.Path, context.Path.Print());
activity.SetTag(GraphQL.Field.Name, coordinate.MemberName);
activity.SetTag(GraphQL.Field.Coordinate, activity.DisplayName);
activity.SetTag(GraphQL.Field.SchemaCoordinate, activity.DisplayName);
activity.SetTag(GraphQL.Field.ParentType, coordinate.Name);

return new ResolveFieldSpan(activity, context, enricher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:f7e9989fbb67af7fa747a9983313c9e5"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -129,7 +125,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
{
"Key": "graphql.document.body",
"Value": "query SayHelloOperation {\n sayHello\n}"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -145,7 +141,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"Value": "causeFatalError"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.causeFatalError"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:f7e9989fbb67af7fa747a9983313c9e5"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -150,7 +146,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:9b20745108c8de5afccc35cd56ead9fc"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -129,7 +125,7 @@
"Value": "dataLoader"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.dataLoader"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:9b20745108c8de5afccc35cd56ead9fc"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -129,7 +125,7 @@
"Value": "dataLoader"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.dataLoader"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:f7e9989fbb67af7fa747a9983313c9e5"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -74,7 +70,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"Value": "causeCodedError"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.causeCodedError"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"Value": "causeUncodedError"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.causeUncodedError"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"Value": "causeFatalError"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.causeFatalError"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"Value": "deep"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.deep"
},
{
Expand Down Expand Up @@ -195,7 +195,7 @@
"Value": "causeFatalError"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "Deep.causeFatalError"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"Value": "throwInvalidOperation"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.throwInvalidOperation"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
"Key": "graphql.field.path",
"Value": "onFailingMessage"
},
{
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleSubscription.onFailingMessage"
},
{
"Key": "graphql.operation.type",
"Value": "subscription"
Expand Down Expand Up @@ -204,7 +208,7 @@
"Value": "onFailingMessage"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleSubscription.onFailingMessage"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
"Value": "onMessage"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleSubscription.onMessage"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"Value": "sayHello"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.sayHello"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:c46cf8c9811934ddea095f10ee722dc4"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -150,7 +146,7 @@
"Value": "greeting"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "SimpleQuery.greeting"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:acb8d5d513c260b3cef3e3a12b0e29af"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -170,7 +166,7 @@
"Value": "hero"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "Query.hero"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
{
"Key": "graphql.document.hash",
"Value": "md5:cc68dfd8c0c54a586a03c35296c5d1f9"
},
{
"Key": "graphql.error.count",
"Value": 0
}
],
"event": [
Expand Down Expand Up @@ -199,7 +195,7 @@
"Value": "hero"
},
{
"Key": "graphql.field.coordinate",
"Key": "graphql.field.schema_coordinate",
"Value": "Query.hero"
},
{
Expand Down
Loading
Loading