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

chore: require value in setAttribute #1851

Merged
merged 8 commits into from
Jan 30, 2021

Conversation

mwear
Copy link
Member

@mwear mwear commented Jan 20, 2021

Which problem is this PR solving?

Short description of the changes

  • This PR makes the value required in Span#setAttribute and updates several call sites where potentially undefined values were being passed in.

@mwear mwear added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 20, 2021
@codecov
Copy link

codecov bot commented Jan 20, 2021

Codecov Report

Merging #1851 (98637bd) into main (f4e7115) will increase coverage by 0.37%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1851      +/-   ##
==========================================
+ Coverage   92.35%   92.72%   +0.37%     
==========================================
  Files         157      174      +17     
  Lines        5104     6038     +934     
  Branches     1085     1283     +198     
==========================================
+ Hits         4714     5599     +885     
- Misses        390      439      +49     
Impacted Files Coverage Δ
...s/opentelemetry-instrumentation-fetch/src/fetch.ts 99.23% <100.00%> (ø)
...emetry-instrumentation-xml-http-request/src/xhr.ts 96.82% <100.00%> (ø)
packages/opentelemetry-web/src/utils.ts 94.66% <100.00%> (ø)
...ry-exporter-collector/src/CollectorExporterBase.ts 92.45% <0.00%> (ø)
...kages/opentelemetry-web/src/StackContextManager.ts 97.05% <0.00%> (ø)
...ry-context-zone-peer-dep/src/ZoneContextManager.ts 85.18% <0.00%> (ø)
...ages/opentelemetry-exporter-collector/src/types.ts 100.00% <0.00%> (ø)
...lemetry-exporter-collector/src/transformMetrics.ts 95.00% <0.00%> (ø)
... and 10 more

Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

I agree with @Flarna that != will catch more cases than !== without overly complicating the code, but this is a matter of preference. Since null/undefined are technically undefined behavior it might not matter that much.

packages/opentelemetry-instrumentation-fetch/src/fetch.ts Outdated Show resolved Hide resolved
Base automatically changed from master to main January 25, 2021 19:26
@dyladan dyladan added API enhancement New feature or request labels Jan 26, 2021
@@ -112,7 +112,9 @@ export class FetchInstrumentation extends InstrumentationBase<
): void {
const parsedUrl = web.parseUrl(response.url);
span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, response.status);
span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, response.statusText);
if (response.statusText != undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: !== undefined

Copy link
Member

Choose a reason for hiding this comment

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

I think we may end up stuck in a loop #1851 (comment)

@vmarchaud vmarchaud merged commit 072e38c into open-telemetry:main Jan 30, 2021
dyladan pushed a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
Co-authored-by: Gerhard Stöbich <deb2001-github@yahoo.de>
Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
dyladan pushed a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
Co-authored-by: Gerhard Stöbich <deb2001-github@yahoo.de>
Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setAttribute value should be required
6 participants