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

Change tracing to use Resource.to_json() #2784

Merged
merged 18 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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 @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.12.0rc1-0.31b0...HEAD)

- Change tracing to use `Resource.to_json()`
([#2784](https://github.com/open-telemetry/opentelemetry-python/pull/2784))
- Add min/max fields to Histogram
([#2759](https://github.com/open-telemetry/opentelemetry-python/pull/2759))
- `opentelemetry-exporter-otlp-proto-http` Add support for OTLP/HTTP log exporter
Expand Down
7 changes: 6 additions & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def to_json(self, indent=4):
f_span["attributes"] = self._format_attributes(self._attributes)
f_span["events"] = self._format_events(self._events)
f_span["links"] = self._format_links(self._links)
f_span["resource"] = self._format_attributes(self._resource.attributes)
f_span["resource"] = self._format_resource(self._resource)
jeremydvoss marked this conversation as resolved.
Show resolved Hide resolved

return json.dumps(f_span, indent=indent)

Expand Down Expand Up @@ -533,6 +533,11 @@ def _format_links(links):
f_links.append(f_link)
return f_links

@staticmethod
def _format_resource(resource):
resource_json_obj = json.loads(resource.to_json())
return {k: v for k, v in resource_json_obj.items() if v}
jeremydvoss marked this conversation as resolved.
Show resolved Hide resolved


class SpanLimits:
"""The limits that should be enforce on recorded data such as events, links, attributes etc.
Expand Down