Skip to content

Type issue in "beforeSendSpan" #16505

@nikolovlazar

Description

@nikolovlazar

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

9.27.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

Image

I used the beforeSendSpan to intentionally drop a certain span, but once I added return null TypeScript warned me that the type of my callback doesn't match the expected type the SDK has defined. The docs in the preview say:

Returning null will cause this span to be dropped.

That's exactly what I wanted to achieve, but I'll have to mute typescript on that line. Is this the intended behavior? If we are allowed to return null to intentionally drop spans, then the SDK should define the expected type as (span: SpanJSON): SpanJSON | null instead.

Steps to Reproduce

Add return null in beforeSendSpan

Expected Result

No TypeScript error should appear

Actual Result

Getting a type mismatch

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions