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 trace sdk builder 1393 #1471

Merged
merged 21 commits into from
Jul 15, 2022

Conversation

marcalff
Copy link
Member

@marcalff marcalff commented Jun 30, 2022

(Last edit 2022-07-12)

Fixes #1393
Fixes #1473

Changes

Implement Trace SDK builders, to avoid exposing SDK details to the application.
This is needed to deploy opentelemetry-cpp as a shared library.

Fixed memory ownership of InMemorySpanExporter in examples.

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

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

@codecov
Copy link

codecov bot commented Jun 30, 2022

Codecov Report

Merging #1471 (40217d5) into main (c224633) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1471   +/-   ##
=======================================
  Coverage   84.73%   84.73%           
=======================================
  Files         155      155           
  Lines        4787     4787           
=======================================
  Hits         4056     4056           
  Misses        731      731           

Use std::unique_ptr instead of nostd::unique_ptr
Continued, implemented:
- JaegerExporterFactory,
- InMemorySpanExporterFactory,
- RandomIdGeneratorFactory.
@marcalff
Copy link
Member Author

marcalff commented Jul 1, 2022

(Last edit 2022-07-08)

This PR is now ready for review.

Remaining tasks:

  • run again all examples locally

Reviewers:

  • Please start by reading docs/cpp-sdk-factory-design.md
  • Please check the Bazel BUILD files in particular (I never used Bazel)
  • To discuss: std versus nostd

Regards,
-- Marc

@marcalff marcalff marked this pull request as ready for review July 1, 2022 17:53
@marcalff marcalff requested a review from a team July 1, 2022 17:53
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.

Very nicely done. Thanks for the PR. Looks good with few (very) minor comments. Hope it would be fine to merge @owent 's async changes first :)

docs/cpp-sdk-factory-design.md Outdated Show resolved Hide resolved
examples/batch/main.cc Outdated Show resolved Hide resolved
exporters/memory/CMakeLists.txt Outdated Show resolved Hide resolved
sdk/src/trace/tracer_provider_factory.cc Show resolved Hide resolved
Implemented code review comments:
- reworded docs/cpp-sdk-factory-design.md,
- re organized includes,
- added TracerContextFactory.

Also:
- renamed Build() methods to Create(),
  for consistency with HttpClientFactory::Create(),
- added doxygen comments,
- added CHANGELOG entry.
@marcalff
Copy link
Member Author

marcalff commented Jul 8, 2022

Very nicely done. Thanks for the PR. Looks good with few (very) minor comments. Hope it would be fine to merge @owent 's async changes first :)

Thanks.

The async changes have priority, I will deal with any merge conflict, these should be trivial to resolve anyway.

One remaining point to discuss, that I am not sure of, is whether Factory classes should use:

  • std::shared_ptr
  • nostd::shared_ptr
    because this is part of the application owner / SDK interface.

@lalitb , @owent , @ThomsonTan , @esigo any input ?

@owent
Copy link
Member

owent commented Jul 8, 2022

Very nicely done. Thanks for the PR. Looks good with few (very) minor comments. Hope it would be fine to merge @owent 's async changes first :)

Thanks.

The async changes have priority, I will deal with any merge conflict, these should be trivial to resolve anyway.

One remaining point to discuss, that I am not sure of, is whether Factory classes should use:

  • std::shared_ptr
  • nostd::shared_ptr
    because this is part of the application owner / SDK interface.

@lalitb , @owent , @ThomsonTan , @esigo any input ?

Or std::unique_ptr so users can convert it to any implementation of shared_ptr?

Conflicts:
	CHANGELOG.md
	exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h
Implement code review comments:
- Factory methods should return a unique_ptr.
- Used TracerContextFactory in examples.
@marcalff
Copy link
Member Author

marcalff commented Jul 9, 2022

Or std::unique_ptr so users can convert it to any implementation of shared_ptr?

Thanks, good point: a factory method should return a unique_ptr anyway.
Fixed.

@lalitb
Copy link
Member

lalitb commented Jul 9, 2022

@owent Can you please review/approve it once you have time? Thanks :)

@owent
Copy link
Member

owent commented Jul 10, 2022

@owent Can you please review/approve it once you have time? Thanks :)

Sorry for something else in company take my bandwidth. I will review this it in 2 or 3 days.

@lalitb
Copy link
Member

lalitb commented Jul 10, 2022

@owent Can you please review/approve it once you have time? Thanks :)

Sorry for something else in company take my bandwidth. I will review this it in 2 or 3 days.

Thanks. That should be fine :)

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.

Could you please add a standalone unit test for OTLP exporters and ES exporters which only include factory headers and do not depend headers of protobuf? I think it's helpful to keep factory heads clean in the future.

@owent owent mentioned this pull request Jul 11, 2022
10 tasks
Implement code review comments:
- avoid copy of resource parameters (used const reference)
- added unit tests to verify build sanity
- moved JsonBytesMappingKind and HttpRequestContentType
  to their own header, to avoid the dependency
  on protobuf from otlp_http_client.h
@marcalff
Copy link
Member Author

marcalff commented Jul 12, 2022

Could you please add a standalone unit test for OTLP exporters and ES exporters which only include factory headers and do not depend headers of protobuf? I think it's helpful to keep factory heads clean in the future.

Good idea, agreed.

For the ES Log exporter, this will be done with the fix for issue #1486, as this change scope is for traces only.

Added a unit test for the OTLP GRPC exporter factory, which was clean.

Added a unit test for the OTLP HTTP exporter factory, which was broken.

Fixed my moving some declarations from otlp_http_client.h to new file otlp_http.h,
to avoid transitive includes on protobuf caused by otlp_http_client.h

While at it, also made sure the OTLP HTTP exporter does not expose nlohmann/json.

Thanks for the review.

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

@marcalff
Copy link
Member Author

@lalitb, @ThomsonTan Do not merge yet.

It turns out the library name for the in memory exporter is visible externally after all,
in cmake/opentelemetry-cpp-config.cmake.in

opentelemetry-cpp::in_memory_span_exporter - Imported target of opentelemetry-cpp::in_memory_span_exporter

Reverting un needed changes in exporter/memory/CMakeLists.txt, will notify when ready to merge.

CMake cleanup.

Reverted the renaming of library opentelemetry_exporter_in_memory to
opentelemetry_exporter_memory_trace.

The name opentelemetry_exporter_in_memory is used externally,
in cmake/opentelemetry-cpp-config.cmake.in
@marcalff
Copy link
Member Author

@lalitb, @ThomsonTan Do not merge yet.

It turns out the library name for the in memory exporter is visible externally after all, in cmake/opentelemetry-cpp-config.cmake.in

opentelemetry-cpp::in_memory_span_exporter - Imported target of opentelemetry-cpp::in_memory_span_exporter

Reverting un needed changes in exporter/memory/CMakeLists.txt, will notify when ready to merge.

@lalitb @ThomsonTan @owent
Now resolved, sorry for the last minute changes.

Ok to merge for my part.

@lalitb lalitb merged commit e708de5 into open-telemetry:main Jul 15, 2022
yxue pushed a commit to yxue/opentelemetry-cpp that referenced this pull request Dec 5, 2022
@marcalff marcalff deleted the fix_trace_sdk_builder_1393 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
4 participants