-
Notifications
You must be signed in to change notification settings - Fork 226
fix: Capture correct descriptions for RSpec one-liner examples #1712
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
fix: Capture correct descriptions for RSpec one-liner examples #1712
Conversation
RSpec one-liner examples (e.g., `it { is_expected.not_to be_nil }`)
generate descriptions after execution. Updated formatter to capture
the final description in `example_finished` instead of relying on
the incomplete description at `example_started`.
## Why?
Span names and full descriptions for RSpec one-liner syntax (like `it {
is_expected.not_to be_nil }`) were incorrectly showing file locations
instead of the matcher-generated descriptions. This made tracing output
less useful for tests using the concise one-liner syntax.
## How?
RSpec generates descriptions for one-liner examples after execution,
when the matcher runs. The formatter was capturing `description` and
`full_description` at `example_started` time, before these values were
populated.
The fix updates both the span name and `full_description` attribute in
the `example_finished` callback, after RSpec has generated the proper
description from the matcher. This ensures accurate span names and
descriptions for both one-liner and traditional examples.
We need to point Intercom's Gemfile to this repo so that we get those
updates without waiting for the upstream repo to accept them.
---
**Note:** Upstream PR created at
open-telemetry#1712
kaylareopelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @americodls, thanks for catching this and providing a fix!
## Why?
Span names and full descriptions for RSpec one-liner syntax (like `it {
is_expected.not_to be_nil }`) were incorrectly showing file locations
instead of the matcher-generated descriptions. This made tracing output
less useful for tests using the concise one-liner syntax.
## How?
RSpec generates descriptions for one-liner examples after execution,
when the matcher runs. The formatter was capturing `description` and
`full_description` at `example_started` time, before these values were
populated.
The fix updates both the span name and `full_description` attribute in
the `example_finished` callback, after RSpec has generated the proper
description from the matcher. This ensures accurate span names and
descriptions for both one-liner and traditional examples.
We need to point Intercom's Gemfile to this repo so that we get those
updates without waiting for the upstream repo to accept them.
---
**Note:** Upstream PR created at
open-telemetry#1712
|
@chrisholmes may I ask for a review please? |
I'm away from computer so I can't test it myself, but the change is simple enough and it makes sense to me. |
|
Please review at your leisure. With your approval I will merge this PR. |
## Why?
Span names and full descriptions for RSpec one-liner syntax (like `it {
is_expected.not_to be_nil }`) were incorrectly showing file locations
instead of the matcher-generated descriptions. This made tracing output
less useful for tests using the concise one-liner syntax.
## How?
RSpec generates descriptions for one-liner examples after execution,
when the matcher runs. The formatter was capturing `description` and
`full_description` at `example_started` time, before these values were
populated.
The fix updates both the span name and `full_description` attribute in
the `example_finished` callback, after RSpec has generated the proper
description from the matcher. This ensures accurate span names and
descriptions for both one-liner and traditional examples.
We need to point Intercom's Gemfile to this repo so that we get those
updates without waiting for the upstream repo to accept them.
---
**Note:** Upstream PR created at
open-telemetry#1712
## Why?
Span names and full descriptions for RSpec one-liner syntax (like `it {
is_expected.not_to be_nil }`) were incorrectly showing file locations
instead of the matcher-generated descriptions. This made tracing output
less useful for tests using the concise one-liner syntax.
## How?
RSpec generates descriptions for one-liner examples after execution,
when the matcher runs. The formatter was capturing `description` and
`full_description` at `example_started` time, before these values were
populated.
The fix updates both the span name and `full_description` attribute in
the `example_finished` callback, after RSpec has generated the proper
description from the matcher. This ensures accurate span names and
descriptions for both one-liner and traditional examples.
We need to point Intercom's Gemfile to this repo so that we get those
updates without waiting for the upstream repo to accept them.
---
**Note:** Upstream PR created at
open-telemetry#1712
|
|
||
| # Update name and full_description for one-liner examples where description is generated after execution | ||
| span.name = example.description | ||
| span.set_attribute('rspec.example.full_description', example.full_description.to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💁🏼 Use add_attributes as opposed to setting each attribute separately because each call requires a lock when changing a span
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch. I agree. @americodls, can you update the method call to combine the attributes on line 76 and 77 into one add_attributes call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback. I just fixed that.
Using add_attributes instead of two separate set_attribute calls reduces lock acquisition overhead, since each attribute update requires locking the span.
RSpec one-liner examples (e.g.,
it { is_expected.not_to be_nil }) generate descriptions after execution.Updated formatter to capture the final description in
example_finishedinstead of relying on the incomplete description atexample_started.