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

Use Rack compliant keys with deprecation #365

Merged
merged 2 commits into from
Mar 28, 2018

Conversation

delner
Copy link
Contributor

@delner delner commented Mar 7, 2018

This pull request is a reissue of #338 , which fixed an issue with use of symbols with Rack, by converting a key to a string instead.

That pull request had to be reverted since it introduced a breaking change for anyone dependent on env[:datadog_rack_request_span]. This pull request seeks to re-add those changes, but with backwards compatibility and a deprecation warning.

In a future version, likely 0.13.0, we will remove both the deprecation warning and the backwards compatibility present here.

@delner delner added bug Involves a bug integrations Involves tracing integrations labels Mar 7, 2018
@delner delner added this to the 0.12.0 milestone Mar 7, 2018
@delner delner self-assigned this Mar 7, 2018
@delner delner requested a review from palazzem March 7, 2018 18:20
Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea makes sense. This is an internal attribute, but better to be conservative since it was public-accessible. We should always deprecate a change and then remove it only in a major release (or minor in our case before going 1.0).

super
end

def []=(key, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the setter is required as a deprecation warning? we're not setting : datadog_rack_request_span anymore and if users do, it's not something we should not interfere I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was doing this out of abundance of caution, in case someone was overriding this value. Seems very unlikely, but possible.

env.instance_eval do
def [](key)
if key == :datadog_rack_request_span
Datadog::Tracer.log.warn(REQUEST_SPAN_DEPRECATION_WARNING)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one could be very spammy. If that internal attribute is used in a middleware, it means 1 log for each request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding an instance variable to scope this to once per request. Our own code shouldn't ever generate these warnings.

env[RACK_REQUEST_SPAN] = request_span

# For backwards compatibility; remove later.
env[:datadog_rack_request_span] = env[RACK_REQUEST_SPAN]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to me, but let's add a TODO: just for the highlight. Also we should probably think (before shipping / merging this part) to write in the comment: remove later -> this attribute is deprecated and will be removed in 0.13 (it's just an example).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good idea. I will add in the "will be removed in 0.13" for now, and if we change the plan, we can adjust it later.

@delner delner force-pushed the deprecation/rack_compliant_keys branch from 651d184 to a0b4571 Compare March 7, 2018 18:35
@delner
Copy link
Contributor Author

delner commented Mar 7, 2018

Feedback should be addressed.

@delner delner mentioned this pull request Mar 7, 2018
Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this PR on hold, though most of the work is ready.

private

REQUEST_SPAN_DEPRECATION_WARNING = %(
Use of :datadog_rack_request_span in the Rack env is DEPRECATED.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say: ":datadog_rack_request_span is an internal symbol in the Rack env and is DEPRECATED. If you need (etc...)"

REQUEST_SPAN_DEPRECATION_WARNING = %(
Use of :datadog_rack_request_span in the Rack env is DEPRECATED.
If you need the Rack request span, try using `Datadog.tracer.active_span`.
This key will be removed in version 0.13.0).freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can think about it. We can introduce this change after at least 2-3 releases so people know that something is going to break because internal symbols (that unfortunately are public-facing) are used.

@delner delner force-pushed the deprecation/rack_compliant_keys branch from a0b4571 to 7edd458 Compare March 7, 2018 18:55
Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't solve the problem addressed with #338, but we can fix that in a newer release when we can remove the deprecation warning and the previous key.

Good to go with the backward compatibility.

@delner delner merged commit 62377c2 into 0.12-dev Mar 28, 2018
@delner delner deleted the deprecation/rack_compliant_keys branch April 5, 2018 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants