Slackbot
10/11/2022, 5:01 PMPranay
Allan Li
10/11/2022, 9:17 PMresponseHook field of the GraphQLInstrumentation module from @opentelemetry/instrumentation as shown in the example from the Signoz traces UI? Can we somehow modify the status of the span according to the `responseHook`(for example if responseHook shows an error that was caught, then the color of the span in the UI will change color)?
Or would we have to query for the errors field in responseHook periodically and set up some type of alert system?
Thanks again.Allan Li
10/12/2022, 1:53 PMAllan Li
10/12/2022, 5:36 PMPranay
Pranay
Allan Li
10/12/2022, 8:40 PMGraphQLInstrumentation module from @opentelemetry/instrucmentataions-graphql library, we see that the responseHook field provides two variables we can work with: span and data. The data object will return the response of your GraphQL operation. The errors field in data will not be empty if there is something wrong with your operation. Given this information we can edit the span object (which corresponds to the actual span opentelemetry will send to SigNoz) by adding custom attributes or attach exception to reflect that an error has occurred.
To make the error spans for visible we can use span.setStatus(SpanStatusCode.ERROR) to indicate that something is wrong with the span, and SigNoz will mark this span as red or we can easily query for it. We can attach the error message from data.errors to some attribute with span.setAttribute() , which will make the value visible on the attributes sidebar on the SigNoz traces UI.Pranay
Jonathan Sun
01/07/2023, 9:46 AMgetNodeAutoInstrumentations(),
new GraphQLInstrumentation({
allowValues: true,
responseHook: ???
}),],