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

Fix validity calculation for trace/span ID #2145

Merged
merged 5 commits into from
Sep 29, 2021

Conversation

mariojonke
Copy link
Contributor

@mariojonke mariojonke commented Sep 24, 2021

Description

This PR addresses the following issues for calculating the validity when creating a SpanContext:

  • validity calculation for trace ID was off by one, so the maximum value for the trace ID (2^128 -1) was actually considered invalid.
  • span IDs were not checked if they exceed the maximum allowed value of 2^64 - 1.
  • negative values for trace and span IDs were considered valid although they are actually outside the valid range of values due to how python handles signed numbers.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

adds additional unit tests

Does This PR Require a Contrib Repo Change?

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added

* fixes trace ID validation which was off by one and considered the max
  trace ID (0xffff...ffff) value as invalid.
* adds check to also validate a span ID for its max value
* adds checks that trace and span ID must not be negative
@mariojonke mariojonke requested a review from a team as a code owner September 24, 2021 09:09
Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

nice catch

@lzchen lzchen enabled auto-merge (squash) September 28, 2021 16:49
@lzchen lzchen merged commit b59e914 into open-telemetry:main Sep 29, 2021
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

5 participants