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

Move Rails span resource setting to beginning of request #1626

Merged
merged 1 commit into from
Aug 4, 2021

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Aug 2, 2021

As of #1623, the profiler records the resource of the root span, on top of the span id and trace id during sampling.

Also, as discusssed in the description of #1623 (in the "Getting the correct resource" section) integrations where the
resource is only set at the end pose an extra challenge, as the request may not be finished in time for the resource to be included in the profiler payload.

This means that the profiler may miss the resource for some of the requests, depending on timing of when the sampling happens and when the request finishes.

(Note that in this case, the trace id and span id will still be propagated, so the samples will always be able to be tied back to the trace that originated them; it's just the resource that will not be included in the profiler data).

To avoid this issue for many of our customers, let's move the Rails resource setting to the beginning of the request, thus avoiding the issue altogether for the Rails (action_pack/action_controller) integration.

As of #1623, the profiler records the `resource` of the root span,
on top of the span id and trace id during sampling.

Also, as discusssed in the description of #1623 (in the
"Getting the correct `resource`" section) integrations where the
`resource` is only set at the end pose an extra challenge, as the
request may not be finished in time for the `resource` to be included
in the profiler payload.
This means that the profiler may miss the `resource` for some of the
requests, depending on timing of when the sampling happens and when the
request finishes.
(Note that in this case, the trace id and span id will still be
propagated, so the samples will always be able to be tied back to the
trace that originated them; it's just the `resource` that will not be
included in the profiler data).

To avoid this issue for many of our customers, let's move the Rails
`resource` setting to the beginning of the request, thus avoiding
the issue altogether for the Rails (action_pack/action_controller)
integration.
@ivoanjo ivoanjo requested a review from a team August 2, 2021 16:59
ivoanjo added a commit that referenced this pull request Aug 3, 2021
As of #1623, the profiler records the `resource` of the root span,
on top of the span id and trace id during sampling.

Also, as discusssed in the description of #1623 (in the
"Getting the correct `resource`" section) integrations where the
`resource` is only set at the end pose an extra challenge, as the
request may not be finished in time for the `resource` to be included
in the profiler payload.
This means that the profiler may miss the `resource` for some of the
requests, depending on timing of when the sampling happens and when the
request finishes.
(Note that in this case, the trace id and span id will still be
propagated, so the samples will always be able to be tied back to the
trace that originated them; it's just the `resource` that will not be
included in the profiler data).

To avoid this issue for many of our customers, let's set the Sinatra
`resource` setting to the beginning of the request, thus avoiding
the issue altogether for Sinatra.

Note that I did not touch the existing code to set the resource at the
end, which had a quite scary TODO (lines 47-64) and seemed like
something I shouldn't touch.

Note 2: This is similar to what we did in #1626 for the Rails
integration.
@ivoanjo ivoanjo merged commit cd0facf into master Aug 4, 2021
@ivoanjo ivoanjo deleted the ivoanjo/rails-set-resource-at-beginning-of-request branch August 4, 2021 07:46
@github-actions github-actions bot added this to the 0.52.0 milestone Aug 4, 2021
ivoanjo added a commit that referenced this pull request Aug 4, 2021
As of #1623, the profiler records the `resource` of the root span,
on top of the span id and trace id during sampling.

Also, as discusssed in the description of #1623 (in the
"Getting the correct `resource`" section) integrations where the
`resource` is only set at the end pose an extra challenge, as the
request may not be finished in time for the `resource` to be included
in the profiler payload.
This means that the profiler may miss the `resource` for some of the
requests, depending on timing of when the sampling happens and when the
request finishes.
(Note that in this case, the trace id and span id will still be
propagated, so the samples will always be able to be tied back to the
trace that originated them; it's just the `resource` that will not be
included in the profiler data).

To avoid this issue for many of our customers, let's move the Grape
`resource` setting to the beginning of the request, thus avoiding
the issue altogether for this integration.

(Note: This is similar to what we did for Rails in #1626 and Sinatra
in #1628)
ivoanjo added a commit that referenced this pull request Aug 4, 2021
As of #1623, the profiler records the `resource` of the root span,
on top of the span id and trace id during sampling.

Also, as discusssed in the description of #1623 (in the
"Getting the correct `resource`" section) integrations where the
`resource` is only set at the end pose an extra challenge, as the
request may not be finished in time for the `resource` to be included
in the profiler payload.
This means that the profiler may miss the `resource` for some of the
requests, depending on timing of when the sampling happens and when the
request finishes.
(Note that in this case, the trace id and span id will still be
propagated, so the samples will always be able to be tied back to the
trace that originated them; it's just the `resource` that will not be
included in the profiler data).

To avoid this issue for many of our customers, let's move the Grape
`resource` setting to the beginning of the request, thus avoiding
the issue altogether for this integration.

(Note: This is similar to what we did for Rails in #1626 and Sinatra
in #1628)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants