Skip to content

Commit

Permalink
Merge pull request #37 from nenoNaninu/semconv_exception
Browse files Browse the repository at this point in the history
Support semconv for exception
  • Loading branch information
nenoNaninu authored May 11, 2024
2 parents 1cf7daf + 51f58a6 commit 5b0442e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal static class HubActivitySource

internal static Activity? StartInvocationActivity(string hubName, string methodName, string? address)
{
// https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/rpc/rpc-spans.md#span-name
// https://github.com/open-telemetry/semantic-conventions/blob/v1.25.0/docs/rpc/rpc-spans.md#span-name
var activity = ActivitySource.CreateActivity($"{hubName}/{methodName}", ActivityKind.Server);

// Activity.IsAllDataRequested is same as TelemetrySpan.IsRecording in OpenTelemetry API.
Expand All @@ -23,7 +23,7 @@ internal static class HubActivitySource
return null;
}

// https://github.com/open-telemetry/semantic-conventions/blob/v1.24.0/docs/rpc/rpc-spans.md#common-attributes
// https://github.com/open-telemetry/semantic-conventions/blob/v1.25.0/docs/rpc/rpc-spans.md#common-attributes
activity.SetTag("rpc.system", "signalr");
activity.SetTag("rpc.service", hubName);
activity.SetTag("rpc.method", methodName);
Expand Down Expand Up @@ -55,7 +55,11 @@ internal static void StopInvocationActivityError(Activity? activity, Exception e
}

activity.SetTag("otel.status_code", "ERROR");
activity.SetTag("signalr.hub.exception", exception.ToString());

// https://github.com/open-telemetry/semantic-conventions/blob/v1.25.0/docs/exceptions/exceptions-spans.md#attributes
activity.SetTag("exception.message", exception.Message);
activity.SetTag("exception.stacktrace", exception.StackTrace);
activity.SetTag("exception.type", exception.GetType().FullName);
}
}

Expand Down

0 comments on commit 5b0442e

Please sign in to comment.