getsentry / getsentry/sentry-javascript

Store metadata on spans separately from attributes

Ouverte
#22,670 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Feature javascript Spans
Langage dominant
TypeScript
Étoiles
8.7k
Forks
1.8k
Merge moyen
1 j 17 h
PR mergées (30 j)
515

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
observability-sre
Type d'issue
Refactorisation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Calme
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.