getsentry / getsentry/sentry-javascript

Rework span start and end lifecycle hook emission

Đang mở
#21,368 1 bình luận 0 reaction 1 người được giao Được @Lms24 nhận Xem trên GitHub
Core javascript Spans
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

Currently, the behaviour for `spanStart` and `spanEnd`/`afterSpanEnd` client hook event emissions is a bit inconsistent across SDKs and span types

### Sentry Spans (non-OTel path)

| Case | Span class | `spanStart` | `spanEnd` | Notes |
|---|---|---|---|---|
| **Sampled root** | `SentrySpan` | Yes | Yes (via `_onSpanEnded`) | |
| **Negatively sampled root** | `SentrySpan` (`sampled: false`) | **Yes** | **Yes** (via `_onSpanEnded`) | Hooks fire, listeners must guard themselves |
| **Sampled child** | `SentrySpan` | **Yes** | **Yes** (via `_onSpanEnded`) | |
| **Negatively sampled child** | `SentryNonRecordingSpan` | **Yes** | **No** (`end()` is no-op) | **Unpaired!** `spanStart` fires, `spanEnd` never does |
| **Ignored span** | `SentryNonRecordingSpan` | **No** (returns before `_startChildSpan`) | **No** | |
| **`onlyIfParent`**, no parent | `SentryNonRecordingSpan` | **No** (created before `createChildOrRootSpan`) | **No** | |
| **Tracing disabled** | `SentryNonRecordingSpan` | **No** (`hasSpansEnabled()` = false) | **No** | |

### OTel Spans

| Case | OTel `SamplingDecision` | Reaches processor? | `spanStart` | `spanEnd` |
|---|---|---|---|---|
| **Sampled root** | `RECORD_AND_SAMPLED` | Yes | Yes | Yes |
| **Negatively sampled root** | `NOT_RECORD` | No | No | No |
| **Sampled child** | `RECORD_AND_SAMPLED` | Yes | Yes | Yes |
| **Negatively sampled child** | `NOT_RECORD` | No | No | No |
| **Ignored span** | `NOT_RECORD` | No | No | No |

### Goals

- We need to align on the behaviour and at the very least fix the unpaired occurance of the negatively sampled child span scenario
- We simplify which actor emits the events. Ideally, only the span classes (Sentry) and span processor (OTel) emit the hooks. Though this can be challenging with the cases where we early return for ignored/no_parent_span cases.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.