getsentry / getsentry/sentry-javascript

Store metadata on spans separately from attributes

未关闭
#22,670 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Feature javascript Spans
主要语言
TypeScript
星标
8.7k
派生
1.8k
平均合并
1 天 17 小时
30 天内合并 PR
515

描述

Currently, our SDK stores metadata on spans in attributes that it cleans up before sending them. This isn't ideal, since it happened multiple times that such attributes were still sent because some code path sending spans or transactions didn't perform the cleanup.

Some examples:
- `sentry.sample_rate`
- `sentry.parentIsRemote`
- `sentry.custom_span_name`

It also makes things a bit awkward with sentry conventions. Adding these attributes has no value and they shouldn't be sent anyway.

It's easiest to store this information (which we need at runtime) on a separate field on the span, which never gets serialized to JSON and thus not sent.

This could work like so:

```js
const span = getActiveSpan();

span._metadata = {
sampleRate: 0.99;
}

// or

span.getMetadata().sampleRate = 0.99;

// or

getSpanMetadata(span).sampleRate = 0.99;
```

Which should now be possible, given all spans in the SDK will be ` instanceof SentrySpan` with v11.

贡献指南

打开贡献指南

调研方向

Start with the getActiveSpan entry point and the SentrySpan implementation, then trace how span metadata is currently stored and serialized to JSON. Done means runtime-only values such as sampleRate, parentIsRemote, and custom_span_name use separate metadata and are never included in serialized spans or transactions.

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
observability-sre
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。