Skip to content

Trouble nesting children successfully with start_child. #1372

@CJKinni

Description

@CJKinni

I'm trying to use the Sentry.start_transaction, #start_child, and #finish to create nested Transactions and spans.

require 'sentry-ruby'
Sentry.init do |config|
  config.dsn = 'DSN'
  config.traces_sample_rate = 1
end


spans = []

op = 'testing depth'
description = 'test'
spans << Sentry.start_transaction(name: op, op: op, description: description)

op = "child at depth #{spans.count}"
spans << spans[-1].start_child(op: op, description: description)

op = "child at depth #{spans.count}"
spans << spans[-1].start_child(op: op, description: description)

op = "child at depth #{spans.count}"
spans << spans[-1].start_child(op: op, description: description)

spans.pop.finish until spans.empty?

I'd expect this to end up with a transaction 'testing_depth' with a child span 'child at depth 1', and that span to have a child 'child at depth 2' and a third child at 'child at depth 3', etc.

Instead, I just get the 'testing_depth' and 'child at depth 1' but that span shows as having no children. Is there something I'm missing about how to add child spans?

Thanks!

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions