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

remove X-B3-ParentSpanId for B3 propagator as per OpenTelemetry Specification #2237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add support for Python 3.10
([#2207](https://github.com/open-telemetry/opentelemetry-python/pull/2207))
- remove `X-B3-ParentSpanId` for B3 propagator as per OpenTelemetry specification
([#2237](https://github.com/open-telemetry/opentelemetry-python/pull/2237))

## [1.6.2-0.25b2](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.6.2-0.25b2) - 2021-10-19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class B3MultiFormat(TextMapPropagator):
SINGLE_HEADER_KEY = "b3"
TRACE_ID_KEY = "x-b3-traceid"
SPAN_ID_KEY = "x-b3-spanid"
PARENT_SPAN_ID_KEY = "x-b3-parentspanid"
SAMPLED_KEY = "x-b3-sampled"
FLAGS_KEY = "x-b3-flags"
_SAMPLE_PROPAGATE_VALUES = set(["1", "True", "true", "d"])
Expand Down Expand Up @@ -149,21 +148,13 @@ def inject(
setter.set(
carrier, self.SPAN_ID_KEY, format_span_id(span_context.span_id)
)
span_parent = getattr(span, "parent", None)
if span_parent is not None:
setter.set(
carrier,
self.PARENT_SPAN_ID_KEY,
format_span_id(span_parent.span_id),
)
setter.set(carrier, self.SAMPLED_KEY, "1" if sampled else "0")

@property
def fields(self) -> typing.Set[str]:
return {
self.TRACE_ID_KEY,
self.SPAN_ID_KEY,
self.PARENT_SPAN_ID_KEY,
self.SAMPLED_KEY,
}

Expand Down Expand Up @@ -195,10 +186,6 @@ def inject(
"1" if sampled else "0",
]

span_parent = getattr(span, "parent", None)
if span_parent:
fields.append(format_span_id(span_parent.span_id))
JamesJHPark marked this conversation as resolved.
Show resolved Hide resolved

setter.set(carrier, self.SINGLE_HEADER_KEY, "-".join(fields))

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_extract_single_header(benchmark):
benchmark(
FORMAT.extract,
{
FORMAT.SINGLE_HEADER_KEY: "bdb5b63237ed38aea578af665aa5aa60-c32d953d73ad2251-1-11fd79a30b0896cd285b396ae102dd76"
FORMAT.SINGLE_HEADER_KEY: "bdb5b63237ed38aea578af665aa5aa60-c32d953d73ad2251-1"
},
)

Expand All @@ -36,7 +36,6 @@ def test_inject_empty_context(benchmark):
{
FORMAT.TRACE_ID_KEY: "bdb5b63237ed38aea578af665aa5aa60",
FORMAT.SPAN_ID_KEY: "00000000000000000c32d953d73ad225",
FORMAT.PARENT_SPAN_ID_KEY: "11fd79a30b0896cd285b396ae102dd76",
FORMAT.SAMPLED_KEY: "1",
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ def setUpClass(cls):
cls.serialized_span_id = trace_api.format_span_id(
generator.generate_span_id()
)
cls.serialized_parent_id = trace_api.format_span_id(
generator.generate_span_id()
)

def setUp(self) -> None:
tracer_provider = trace.TracerProvider()
Expand Down Expand Up @@ -103,7 +100,6 @@ def test_extract_multi_header(self):
context = {
propagator.TRACE_ID_KEY: self.serialized_trace_id,
propagator.SPAN_ID_KEY: self.serialized_span_id,
propagator.PARENT_SPAN_ID_KEY: self.serialized_parent_id,
propagator.SAMPLED_KEY: "1",
}
child, parent, _ = self.get_child_parent_new_carrier(context)
Expand Down Expand Up @@ -142,7 +138,7 @@ def test_extract_single_header(self):

child, parent, _ = self.get_child_parent_new_carrier(
{
propagator.SINGLE_HEADER_KEY: f"{self.serialized_trace_id}-{self.serialized_span_id}-1-{self.serialized_parent_id}"
propagator.SINGLE_HEADER_KEY: f"{self.serialized_trace_id}-{self.serialized_span_id}-1"
}
)

Expand Down