Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a way to extract the parent ID from Transactions and Spans #909

Closed
axw opened this issue Mar 8, 2021 · 0 comments · Fixed by #956
Closed

Introduce a way to extract the parent ID from Transactions and Spans #909

axw opened this issue Mar 8, 2021 · 0 comments · Fixed by #956
Labels
agent-go enhancement New feature or request

Comments

@axw
Copy link
Member

axw commented Mar 8, 2021

Is your feature request related to a problem? Please describe.

It is currently not possible to extract the parent ID from a Transaction or Span. This makes it impossible to, for example, inject the parent ID into logs. See https://discuss.elastic.co/t/how-to-get-parent-span-id-from-span/266430

Describe the solution you'd like

Add a method to Transaction and Span to obtain the parent ID.

Describe alternatives you've considered

Alternatively, simply expose the parent ID as a field on Transaction and Span.

@axw axw added the enhancement New feature or request label Mar 8, 2021
@axw axw closed this as completed in #956 Apr 23, 2021
axw pushed a commit that referenced this issue Apr 23, 2021
* apm: add ParentID methods to Span and Transaction

Adds two new methods to the `Span` and `Transaction` types, expanding
the API so consumers can extract the ParentIDs should they desire to.

The `Transaction.ParentID()` call reuses the already existing method
`Transaction.EnsureParent()` since it handles all the cases already.

`Span.ParentID()` is much simpler and does not generate a new SpanID
when `parentID` is zero or nil, simply returns an empty `SpanID` with
its zero value.

Closes #909.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Address review comments

Adds a new `parentID` field to both `Transaction` and `Span` structures.
The `parentID` is only populated at start time and remains immutable
throughout the lifecycle of the Transaction or Span, making it possible
to retrieve the `parentID` for either after they have ended.
However, the `ParentID()` call might return a zero value `SpanID` when
a trace has no parent.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Address review comments

Removes the `TransactionData.parentSpan` field in favor of the new
`Transaction.parentID` and updates `EnsureParent()` to update that field
and `Transaction.ParentID()` to hold a read lock to read `tx.parentID`.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Remove SpanData.parentID in favor of Span.parentID

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Update changelog

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
stuartnelson3 pushed a commit that referenced this issue Jul 30, 2021
* apm: add ParentID methods to Span and Transaction

Adds two new methods to the `Span` and `Transaction` types, expanding
the API so consumers can extract the ParentIDs should they desire to.

The `Transaction.ParentID()` call reuses the already existing method
`Transaction.EnsureParent()` since it handles all the cases already.

`Span.ParentID()` is much simpler and does not generate a new SpanID
when `parentID` is zero or nil, simply returns an empty `SpanID` with
its zero value.

Closes #909.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Address review comments

Adds a new `parentID` field to both `Transaction` and `Span` structures.
The `parentID` is only populated at start time and remains immutable
throughout the lifecycle of the Transaction or Span, making it possible
to retrieve the `parentID` for either after they have ended.
However, the `ParentID()` call might return a zero value `SpanID` when
a trace has no parent.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Address review comments

Removes the `TransactionData.parentSpan` field in favor of the new
`Transaction.parentID` and updates `EnsureParent()` to update that field
and `Transaction.ParentID()` to hold a read lock to read `tx.parentID`.

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Remove SpanData.parentID in favor of Span.parentID

Signed-off-by: Marc Lopez <marc5.12@outlook.com>

* Update changelog

Signed-off-by: Marc Lopez <marc5.12@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-go enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant