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

Fix log sdk builder (#1486) #1524

Merged
merged 10 commits into from
Aug 2, 2022

Conversation

marcalff
Copy link
Member

@marcalff marcalff commented Jul 28, 2022

Fixes #1486

Changes

Implement builders for log SDK.

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed (no API change)

@marcalff marcalff requested a review from a team July 28, 2022 07:45
@codecov
Copy link

codecov bot commented Jul 28, 2022

Codecov Report

Merging #1524 (5724cea) into main (3af512e) will increase coverage by 0.07%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1524      +/-   ##
==========================================
+ Coverage   84.59%   84.65%   +0.07%     
==========================================
  Files         156      156              
  Lines        4794     4794              
==========================================
+ Hits         4055     4058       +3     
+ Misses        739      736       -3     
Impacted Files Coverage Δ
ext/src/http/client/curl/http_client_curl.cc 81.07% <0.00%> (+1.14%) ⬆️

Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

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

Just want to discuss, do we need a standalone factor for every processor?Or it's more simple to use just one factory to create different type of process and all return std::unique_ptr<LogProcessor>?

@lalitb
Copy link
Member

lalitb commented Jul 28, 2022

Just want to discuss, do we need a standalone factor for every processor?Or it's more simple to use just one factory to create different type of process and all return std::unique_ptr<LogProcessor>?

I don't have strong preference for either approach - both looks good.

Implemented code review comments.

Fixed typo (processor -> processors)
in TracerContextFactory
@marcalff
Copy link
Member Author

marcalff commented Jul 29, 2022

Just want to discuss, do we need a standalone factor for every processor?Or it's more simple to use just one factory to create different type of process and all return std::unique_ptr<LogProcessor>?

@owent , @lalitb Good question, as it is another possible design.

Assuming something like:

class LogProcessorFactory
{
  static std::unique_ptr<LogProcessor> CreateSimpleLogProcessor(...);
  static std::unique_ptr<LogProcessor> CreateMultiLogProcessor(...);
  static std::unique_ptr<LogProcessor> CreateBatchLogProcessor(...);
};

there is only one class, with builders for each flavor of log processor.

This design works here for log processor, but does not for other cases.

For example applying the same pattern to trace exporters, it leads to:

  • a class TraceExporterFactory
  • that depends on the Jaeger exporter
  • that depends on the OStream exporter
  • that depends on the OTLP HTTP exporter
  • that depends on the OTLP GRPC exporter

Because of this class, there is no longer a way to link only a few exporters the application owner wants in the final binary.

Instead, every exporter has to be linked in the final application, which is not good.

So, to avoid confusion for the user of this code, the design here sticks to always the same pattern,
which is easy to remember, and also works well with libraries dependencies:

To get a instance of class XXX, call XXXFactory::Create()

The XXXFactory class is provided in the same library as class XXX, which makes it possible to use XXX but not YYY.

Copy link
Member

@owent owent left a comment

Choose a reason for hiding this comment

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

LGTM, Could you please also add a standalone unit test so that we can ensure factory headers of OTLP exporters do not include any protobuf header?

@lalitb
Copy link
Member

lalitb commented Aug 1, 2022

So, to avoid confusion for the user of this code, the design here sticks to always the same pattern,
which is easy to remember, and also works well with libraries dependencies:
To get a instance of class XXX, call XXXFactory::Create()

Agree, the current approach looks good.

Implemented code review comments,
added unit tests.
@marcalff
Copy link
Member Author

marcalff commented Aug 1, 2022

LGTM, Could you please also add a standalone unit test so that we can ensure factory headers of OTLP exporters do not include any protobuf header?

Indeed, I should have known from traces.

Thanks, unit test added.

@lalitb
Copy link
Member

lalitb commented Aug 1, 2022

LGTM, Could you please also add a standalone unit test so that we can ensure factory headers of OTLP exporters do not include any protobuf header?

@owent - Can you approve the changes if the recent unit tests look good? Thanks.

Copy link
Member

@owent owent 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 70fd2dc into open-telemetry:main Aug 2, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
@marcalff marcalff deleted the fix_log_sdk_builder_1486 branch July 4, 2023 07:13
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.

[Logs SDK] Provide builders to avoid exposing SDK internals
3 participants