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

Add SpanContext (and TraceState) to Recordable #667

Merged
merged 3 commits into from
Apr 13, 2021

Conversation

eyjohn
Copy link
Contributor

@eyjohn eyjohn commented Apr 9, 2021

Fixes #661

Changes

  • Updated Recordable interface to take a span context and parent span id
    rather than just the trace/span ids.
  • Updated SpanData to new interface and added new getters for accessing
    SpanContext
  • Updated ThreadsafeSpanData with the same
  • Updated tests for both (and made consistent)
  • Updated OStreamSpanExporter to print tracestate and tests

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been updated
  • Changes in public API reviewed

@eyjohn eyjohn requested a review from a team April 9, 2021 11:57
@eyjohn eyjohn force-pushed the 661/add_trace_state_to_recordable branch from 67b0b80 to ca5887c Compare April 9, 2021 12:05
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially considered using kv_properties for trace state, during which I hit redeclarations due to this being missing

@@ -110,20 +120,18 @@ class ThreadsafeSpanData final : public opentelemetry::sdk::trace::Recordable
* Get the attributes for this span
* @return the attributes for this span
*/
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>
GetAttributes() const noexcept
std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue> GetAttributes()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we have to copy for thread safety, the copy doesn't need to be const

void AddEvent(nostd::string_view name,
core::SystemTimestamp timestamp,
const opentelemetry::common::KeyValueIterable &attributes) noexcept override
void AddEvent(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to make consistent with ThreadsafeSpanData and avoid having to explicitly have to reference .opentelemetry::sdk::trace::Recordable::AddEvent

@eyjohn eyjohn changed the title Add SpanContext (and TraceState) to Recordable WIP Add SpanContext (and TraceState) to Recordable Apr 9, 2021
@eyjohn
Copy link
Contributor Author

eyjohn commented Apr 9, 2021

WIP till I make CI happy

@codecov
Copy link

codecov bot commented Apr 9, 2021

Codecov Report

Merging #667 (bb10044) into main (3ce3e76) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #667      +/-   ##
==========================================
+ Coverage   94.65%   94.67%   +0.02%     
==========================================
  Files         204      204              
  Lines        9387     9416      +29     
==========================================
+ Hits         8885     8915      +30     
+ Misses        502      501       -1     
Impacted Files Coverage Δ
api/include/opentelemetry/common/kv_properties.h 98.80% <ø> (ø)
sdk/include/opentelemetry/sdk/trace/recordable.h 100.00% <ø> (ø)
exporters/ostream/src/span_exporter.cc 89.74% <100.00%> (+0.13%) ⬆️
exporters/ostream/test/ostream_span_test.cc 100.00% <100.00%> (ø)
...de/opentelemetry/ext/zpages/threadsafe_span_data.h 97.26% <100.00%> (+0.07%) ⬆️
ext/test/zpages/threadsafe_span_data_test.cc 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/trace/span_data.h 100.00% <100.00%> (ø)
sdk/src/trace/span.cc 89.58% <100.00%> (+0.10%) ⬆️
sdk/test/trace/span_data_test.cc 100.00% <100.00%> (ø)
sdk/src/logs/batch_log_processor.cc 95.00% <0.00%> (+1.25%) ⬆️

- Updated Recordable interface to take a span context and parent span id
rather than just the trace/span ids.
- Updated SpanData to new interface and added new getters for accessing
SpanContext
- Updated ThreadsafeSpanData with the same
- Updated tests for both (and made consistent)
- Updated OStreamSpanExporter to print tracestate and tests
- Added SetIdentity to otlp::Recordable (with tracestate)
- Added SetIdentity to Zipkin (without tracestate support)
- Fixed minor formatting issue
@eyjohn eyjohn force-pushed the 661/add_trace_state_to_recordable branch from 7126da9 to b79031a Compare April 10, 2021 09:03
@eyjohn eyjohn changed the title WIP Add SpanContext (and TraceState) to Recordable Add SpanContext (and TraceState) to Recordable Apr 10, 2021
Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM

@lalitb lalitb merged commit aeb8230 into open-telemetry:main Apr 13, 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.

Add TraceState to recordable interface
3 participants