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: ensure attributes are spec compliant #1488

Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Sep 2, 2020

Fixes #1340

  • Attribute values may be number, string, boolean, or a homogeneous array of number, string, or boolean
  • Attribute keys must not be empty strings
  • Setting an attribute which is already set overwrites it
  • Setting an attribute to null (or undefined) deletes it
  • Null values in arrays are allowed and preserved because they convey meaning

@codecov
Copy link

codecov bot commented Sep 2, 2020

Codecov Report

Merging #1488 into master will decrease coverage by 0.04%.
The diff coverage is 94.44%.

@@            Coverage Diff             @@
##           master    #1488      +/-   ##
==========================================
- Coverage   93.16%   93.11%   -0.05%     
==========================================
  Files         152      155       +3     
  Lines        4580     4811     +231     
  Branches      931      971      +40     
==========================================
+ Hits         4267     4480     +213     
- Misses        313      331      +18     
Impacted Files Coverage Δ
packages/opentelemetry-tracing/src/Span.ts 98.14% <81.81%> (-1.86%) ⬇️
...ckages/opentelemetry-core/src/common/attributes.ts 97.29% <97.29%> (ø)
...ackages/opentelemetry-shim-opentracing/src/shim.ts 87.70% <100.00%> (-0.30%) ⬇️
packages/opentelemetry-tracing/src/Tracer.ts 100.00% <100.00%> (ø)
.../opentelemetry-exporter-collector/src/transform.ts 86.81% <0.00%> (-9.90%) ⬇️
...emetry-core/src/platform/node/RandomIdGenerator.ts 87.50% <0.00%> (-6.25%) ⬇️
...ry-plugin-xml-http-request/src/enums/EventNames.ts 100.00% <0.00%> (ø)
...s/opentelemetry-plugin-xml-http-request/src/xhr.ts 97.23% <0.00%> (ø)

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

can you please improve the test coverage, the coverage for added file attributes.ts shows no tests

@Flarna
Copy link
Member

Flarna commented Sep 9, 2020

Not sure if it is relevant but the attributes given to Tracer#startSpan() are passed to shouldSample before they get validated.

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm, I hope you can add tests to added code (attributes.ts ) - what codecov is showing before merging that.

@dyladan dyladan force-pushed the spec-compliant-attributes branch from 0f6ecdf to 86c71e1 Compare September 9, 2020 14:56
@dyladan
Copy link
Member Author

dyladan commented Sep 9, 2020

Not sure if it is relevant but the attributes given to Tracer#startSpan() are passed to shouldSample before they get validated.

Fixed

lgtm, I hope you can add tests to added code (attributes.ts ) - what codecov is showing before merging that.

Fixed

@Flarna
Copy link
Member

Flarna commented Sep 9, 2020

Attributes directly passed to startTrace() are now checked twice but I assume the overhead is negligible compared to all the rest done by the tracer.

@dyladan
Copy link
Member Author

dyladan commented Sep 9, 2020

Attributes directly passed to startTrace() are now checked twice but I assume the overhead is negligible compared to all the rest done by the tracer.

We could remove the check from the Span constructor, but then we would be trusting the input is validated by tracer and user hasn't done something like new Span().

Another option would be to remove the validation in the Tracer and make sure the samplers are resilient to untrusted input, but then we need to do that in every sampler. And users can plug in custom samplers that might assume data is valid.

@dyladan dyladan closed this Sep 21, 2020
@dyladan dyladan reopened this Sep 21, 2020
@dyladan dyladan merged commit be9d552 into open-telemetry:master Sep 21, 2020
@dyladan dyladan deleted the spec-compliant-attributes branch September 21, 2020 21:13
dyladan added a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
dyladan added a commit to dyladan/opentelemetry-js that referenced this pull request Sep 9, 2022
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 2023
…en-telemetry#1488)

Co-authored-by: Haddas Bronfman <85441461+haddasbronfman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure our attribute implementations are spec compliant
5 participants