Skip to content

Allow to create spans as children of specific spans #12539

Closed
@mydea

Description

@mydea

It is possible today, with the new APIs, to create a span as a child of a specific other span:

const child = Sentry.withActiveSpan(parent, () => Sentry.startInactiveSpan(...));

However, this is not super intuitive for users. We should provide some helper/utility/way to do this easier.

I see two main ways we could do this:

  1. Create a new method, like Sentry.startInactiveChildSpan(parent, spanOptions)
  2. Add an optional parentSpan option to all startSpan* methods:
Sentry.startSpan({ name: 'xxx', parentSpan: parent }, () => {});
const span = Sentry.startInactiveSpan({ name: 'xxx', parentSpan: parent });

I think I'd tend to the second option, and we should be able to implement this both for core as well as for otel.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions