Skip to content

Fix TraceState to adhere to specs - #1502

Merged
lzchen merged 46 commits into
open-telemetry:masterfrom
srikanthccv:trace-state-fix
Jan 20, 2021
Merged

Fix TraceState to adhere to specs#1502
lzchen merged 46 commits into
open-telemetry:masterfrom
srikanthccv:trace-state-fix

Conversation

@srikanthccv

@srikanthccv srikanthccv commented Dec 24, 2020

Copy link
Copy Markdown
Member

Description

Fixes #1487

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • tox -e test-core-api
  • tox -e test-core-sdk

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
  • Documentation has been updated

@srikanthccv
srikanthccv requested review from a team, aabmass and hectorhdzg and removed request for a team December 24, 2020 09:22
Comment thread opentelemetry-api/src/opentelemetry/trace/span.py Outdated
@srikanthccv
srikanthccv marked this pull request as ready for review December 24, 2020 10:35

@aabmass aabmass left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, just a few nits

Comment thread opentelemetry-api/src/opentelemetry/trace/span.py Outdated
Comment thread opentelemetry-api/src/opentelemetry/trace/span.py Outdated
A string that adheres to the w3c tracestate
header format.
"""
return ",".join(key + "=" + value for key, value in self._dict.items())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Im not super familiar with the tracestate spec; do we need some escaping in the values here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From W3C Trace Context spec

The value is an opaque string containing up to 256 printable ASCII characters (i.e., the range 0x20 to 0x7E) except comma (,) and (=).

If I understand it correctly we don't need to do any escaping as this header will be ASCII only which is totally fine with HTTP Headers.

Comment thread opentelemetry-api/src/opentelemetry/trace/span.py Outdated
# empty members are valid, but no need to process further.
if not member:
continue
match = _MEMBER_PATTERN.fullmatch(member)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have util like _is_valid_pair(), why not have a is_valid_member()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

All the mutation operations on trace state should validate the key/value. The member would be in format of key=value. If we go with is_valid_member() we will have construct member from key/value params. If we stick with is_valid_pair we need to split the member from header to give pair. Either way would be fine.

Comment on lines +11 to +14
_DELIMITER_PATTERN,
_MEMBER_PATTERN,
_TRACECONTEXT_MAXIMUM_TRACESTATE_KEYS,
_is_valid_pair,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These imports shouldn't be named with underscore prefixes right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think these are for internal use and should have leading underscore. Ideally users should only rely on TraceState and inject/extract API.

@lzchen

lzchen commented Jan 19, 2021

Copy link
Copy Markdown
Contributor

@lonewolf3739
Can you fix merge conflicts?

@srikanthccv

Copy link
Copy Markdown
Member Author

@lonewolf3739
Can you fix merge conflicts?

Done.

@lzchen
lzchen merged commit 1d39f7f into open-telemetry:master Jan 20, 2021
@srikanthccv
srikanthccv deleted the trace-state-fix branch September 24, 2021 08:41
@ocelotl ocelotl mentioned this pull request Jul 1, 2026
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.

Fix TraceState to adhere to specs

3 participants