Use RESOURCE_NAME constant for resource tag check #6963
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Replaces hard-coded value for tag key used to identify a span's resource name with a reference to the corresponding constant.
Motivation
I was reviewing the source code to determine how a particular resource name was being assigned when I noticed an inconsistency between this implementation (the hard-coded string) vs others within the same package (which reference the
RESOURCE_NAMEinstead).For example, the
wrapMiddlewarefunction sources the tag key name from the constant:dd-trace-js/packages/dd-trace/src/plugins/util/web.js
Lines 192 to 194 in 68516f7
Even within the
addResourceTagfunction's implementation, there seems to be an inconsistency between the following:dd-trace-js/packages/dd-trace/src/plugins/util/web.js
Line 520 in 68516f7
vs
dd-trace-js/packages/dd-trace/src/plugins/util/web.js
Line 526 in 68516f7
Additional Notes
Here is where the
RESOURCE_NAMEconst is defined:dd-trace-js/ext/tags.js
Line 6 in 68516f7