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 Resources to Recordable interface. #570

Closed
wants to merge 11 commits into from

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Feb 9, 2021

This is second part of initial Resource SDK implementation ( #502 ) - to propagate resources to Span exporters through Recordable interface.

TODO -> Modify otlp exporter to export resources. This is dependent on #567 , as the spans need to be grouped on basis on Resources and Instrumentation Library before exporting.

@jsuereth - It doesn't use alternate approach from processor to exporters, as that would need re-work if Resources are later made as mutable / append-only attributes ( as there are some discussion happening on this (and you are already part of that disucssions :) ) : open-telemetry/opentelemetry-specification#1298 ).

Moving to draft, as per comments from Josh.

@lalitb lalitb requested a review from a team February 9, 2021 16:51
@lalitb lalitb changed the title Propagate resource to Span Exporters Add Resources to Recordable interface. Feb 9, 2021
@codecov
Copy link

codecov bot commented Feb 9, 2021

Codecov Report

Merging #570 (321085b) into main (a1dc8bd) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #570   +/-   ##
=======================================
  Coverage   94.40%   94.40%           
=======================================
  Files         200      200           
  Lines        9067     9086   +19     
=======================================
+ Hits         8560     8578   +18     
- Misses        507      508    +1     
Impacted Files Coverage Δ
sdk/include/opentelemetry/sdk/trace/recordable.h 100.00% <ø> (ø)
...de/opentelemetry/ext/zpages/threadsafe_span_data.h 97.18% <100.00%> (+0.16%) ⬆️
ext/test/zpages/tracez_data_aggregator_test.cc 97.34% <100.00%> (-0.01%) ⬇️
ext/test/zpages/tracez_processor_test.cc 98.70% <100.00%> (-0.01%) ⬇️
sdk/include/opentelemetry/sdk/trace/span_data.h 100.00% <100.00%> (ø)
sdk/src/trace/span.cc 89.36% <100.00%> (+0.23%) ⬆️
sdk/src/trace/tracer.cc 74.28% <100.00%> (ø)
sdk/test/trace/tracer_test.cc 100.00% <100.00%> (ø)
sdk/src/logs/batch_log_processor.cc 93.82% <0.00%> (-1.24%) ⬇️

{
attribute->mutable_value()->set_bool_value(nostd::get<bool>(value));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove blank line.

Copy link
Contributor

@jsuereth jsuereth left a comment

Choose a reason for hiding this comment

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

IIUC, rather than passing resource to exporter, we're copying all the labels across spans and assuming they all share the same set?

This code was a bit harder to follow. WDYT about one of the following:

  1. Keep the Resource bundled into that type instead of using the name "resource attribtues"
  2. Modify MakeRecordable interfaces to take in a resource
  3. I'm happy to take a stab at an interface for sending resource from the TracerProvider. (Specifically I'd add a setResource on Processor that is called when a processor is added to the TracerProvider).

auto resource = rec->GetResources();
if (resource.attributes_size())
{
// TODO
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this ready for review?

* @return the resource of this span
*/
const std::unordered_map<std::string, opentelemetry::sdk::common::OwnedAttributeValue>
&GetResources() const noexcept
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't this return a Resource object?

@@ -213,6 +223,14 @@ class SpanData final : public Recordable
span_kind_ = span_kind;
}

void SetResourceAttribute(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand what this method is intended to do and where it is in the spec.

Fro what I gather, this is basically copying all the resource-attributes onto the span. Can we instead just grab a reference to the resource?

@lalitb
Copy link
Member Author

lalitb commented Feb 10, 2021

IIUC, rather than passing resource to exporter, we're copying all the labels across spans and assuming they all share the same set?

This code was a bit harder to follow. WDYT about one of the following:

  1. Keep the Resource bundled into that type instead of using the name "resource attribtues"
  2. Modify MakeRecordable interfaces to take in a resource
  3. I'm happy to take a stab at an interface for sending resource from the TracerProvider. (Specifically I'd add a setResource on Processor that is called when a processor is added to the TracerProvider).

Thanks @jsuereth for your comments. I will prefer option 3 unless Resource is made append-only/mutable in spec. Will like to go with option 2 if that happens. Would wait for more suggestions before doing changes accordingly.

@jsuereth
Copy link
Contributor

@lalitb Sounds like a plan. I'll get something to you as soon as I can (this week, likely)

@jsuereth
Copy link
Contributor

Ok #575 is ready for comment/comparison.

@lalitb
Copy link
Member Author

lalitb commented Mar 1, 2021

closing as we are looking into alternate options of implementation ref: #580 , #591

@lalitb lalitb closed this Mar 1, 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.

3 participants