getsentry / getsentry/sentry-dotnet

`Span.SetData("my.array", new string[] { /* some data */ })` is incorrectly serialized as an empty object

Open
#5,135 8 comments 0 reactions 1 assignee Claimed by @Flash0ver View on GitHub
.NET AOT Bug Spans
Dominant language
C#
Stars
770
Forks
248
Avg merge
3d 4h
Merged PRs (30d)
49

Description

### Package

Sentry

### .NET Flavor

.NET

### .NET Version

10.0.203

### OS

Windows

### OS Version

_No response_

### Development Environment

Rider 2025.x (Windows)

### Other Error Monitoring Solution

No

### Other Error Monitoring Solution Name

_No response_

### SDK Version

10.0

### Self-Hosted Sentry Version

_No response_

### Workload Versions

-

### UseSentry or SentrySdk.Init call

```csharp
// Should be unrelated to the issue
_initDisposable = SentrySdk.Init(o =>
{
o.Dsn = sentryKey;
o.CacheDirectoryPath = /* */;
o.IsGlobalModeEnabled = true;
o.TracesSampleRate = 1.0;
o.AddExceptionFilterForType();
o.DisableDiagnosticSourceIntegration();
o.DisableSystemDiagnosticsMetricsIntegration();
o.DisableWinUiUnhandledExceptionIntegration();
});
```

### Steps to Reproduce

1. Start a span
2. Call `Span.SetData("my.array", ["test1", "test2", "test3")`.
3. Finish the span, flush
4. Find the span in the dashboard and observer raw JSON or empty value in the table

I tried to find the issue in the code, if it's obvious, and it seems to be due to missing array branch in the `WriteDynamicValue` method here https://github.com/getsentry/sentry-dotnet/blob/e99c3d1911bbe371a8a5c6edd3432da42833e256/src/Sentry/Internal/Extensions/JsonExtensions.cs#L492

I noticed this method has branches for dictionaries and some other complex type but not arrays.
And I also found there a workaround for my issue - implement a simple ISentryJsonSerializable wrapper.

### Expected Result

```json
"data" {
"my.array": [
"test1", "test2", "test3"
]
}
```

### Actual Result

```json
"data" {
"my.array": { }
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.