Skip to content

Add /analyze-crash and /analyze-error Claude commands#7961

Merged
bouwkast merged 2 commits intomasterfrom
steven/crash-analyze
Jan 5, 2026
Merged

Add /analyze-crash and /analyze-error Claude commands#7961
bouwkast merged 2 commits intomasterfrom
steven/crash-analyze

Conversation

@bouwkast
Copy link
Collaborator

Summary of changes

When investigating crashes or errors a main difficulty (in my opinion) is both the volume of them 😭 but also unfamiliarity of the various frames in the stacks. This PR adds two (experimental) Claude Code commands to assist with this /analyze-crash and /analyze-error.

Reason for change

As I have been going through stacks and frames from Crash Tracking I found myself constantly having to look up what things mean as I'm just not super familiar with most of the native bits at the moment. These two commands are largely created to help me speed up initial understanding and analysis of stacks from reported crashes that are (likely) caused by dd-trace-dotnet.

In addition to this, it made some sense to include a similar command for errors (that are not crashes, but are caused by us).

The analysis documents are intended to help de-mystify both and provide more human readable information.

Implementation details

Both commands will output a markdown file within your user .claude\analysis\ directory (creates it if necessary).

Test coverage

Other details

I would consider these experimental and will continue to test them out.

To use:

Intention is to click the Copy stack button in Error Tracking and then paste it into the command. That is it!

@bouwkast bouwkast added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Dec 17, 2025
@bouwkast bouwkast requested a review from a team as a code owner December 17, 2025 16:03
bouwkast added a commit that referenced this pull request Dec 19, 2025
## Summary of changes

This resolves a `System.InvalidCastException` that was happening in the
GRPC client instrumentation (I think just GrpcLegacy) when we attempted
to remove headers.


## Reason for change

Errors in Error Tracking

## Implementation details

> before

```
public void Remove(string name)
{
    var entry = _headers.Get(name);
    if (entry is not null)
    {
        _headers.Remove(name);
    }
}
```

> after
```
public void Remove(string name)
{
    var entry = _headers.Get(name);
    if (entry is not null)
    {
        _headers.Remove(entry);
    }
}
```

## Test coverage

Updated the sample application to detect this and if it is detected it
adds a tag which causes the tests to fail (and they did fail before I
applied the fix).

## Other details
<!-- Fixes #{issue} -->

Used #7961
`/analyze-error` command based on the reported error in Error Tracking.
Seemed to work okay, it identified the issue, follow up was able to get
a reproduction quickly, but it really struggled to get the tests
updated.

Helpfully, the command output a document that linked to and copied the
actual `Grpc.Core.Api` code that we hit 👍
Saves some time searching on GitHub ourselves I guess.

This is a bit of an edge case here so I don't think very wide spread.

Reproduced Error:

```
2025-12-18 10:03:42.678 -05:00 [ERR] Error creating inactive client span for GRPC call System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Entry'.
   at Grpc_Core_Api__D754F35622E28BAD.Grpc_Core_Metadata.Datadog_Trace_ClrProfiler_AutoInstrumentation_Grpc_IMetadata_3.Remove(Object )
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Grpc.MetadataHeadersCollection.Remove(String name)
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Grpc.MetadataHeadersCollection.Set(String name, String value)
   at Datadog.Trace.Headers.HeadersCollectionAccesor`1.Set(TCarrier carrier, String key, String value)
   at Datadog.Trace.Propagators.W3CTraceContextPropagator.Inject[TCarrier,TCarrierSetter](PropagationContext context, TCarrier carrier, TCarrierSetter carrierSetter)
   at Datadog.Trace.Propagators.SpanContextPropagator.Inject[TCarrier,TCarrierSetter](PropagationContext context, TCarrier carrier, TCarrierSetter carrierSetter)
   at Datadog.Trace.Propagators.SpanContextPropagator.Inject[TCarrier](PropagationContext context, TCarrier headers)
   at Datadog.Trace.ClrProfiler.AutoInstrumentation.Grpc.GrpcLegacy.Client.GrpcLegacyClientCommon.InjectHeaders[TMethod,TCallOptions](Tracer tracer, TMethod method, TCallOptions& callOptionsInstance)
 { MachineName: ".", Process: "[84684 Samples.GrpcLegacy]", AppDomain: "[1 Samples.GrpcLegacy.exe]", TracerVersion: "3.34.0.0" }

```
<!--  ⚠️ Note:

Where possible, please obtain 2 approvals prior to merging. Unless
CODEOWNERS specifies otherwise, for external teams it is typically best
to have one review from a team member, and one review from apm-dotnet.
Trivial changes do not require 2 reviews.

MergeQueue is NOT enabled in this repository. If you have write access
to the repo, the PR has 1-2 approvals (see above), and all of the
required checks have passed, you can use the Squash and Merge button to
merge the PR. If you don't have write access, or you need help, reach
out in the #apm-dotnet channel in Slack.
-->

---------

Co-authored-by: Andrew Lock <andrew.lock@datadoghq.com>
@bouwkast bouwkast merged commit e2908cf into master Jan 5, 2026
99 of 102 checks passed
@bouwkast bouwkast deleted the steven/crash-analyze branch January 5, 2026 14:11
@github-actions github-actions bot added this to the vNext-v3 milestone Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos area:docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants