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

[SDK] support for the new OTel log API #2123

Merged
merged 20 commits into from
May 6, 2023

Conversation

ThomsonTan
Copy link
Contributor

@ThomsonTan ThomsonTan commented Apr 27, 2023

Fixes #2122

Changes

Please provide a brief description of the changes here.

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

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #2123 (04e6dcd) into main (b4ff53d) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2123   +/-   ##
=======================================
  Coverage   87.19%   87.19%           
=======================================
  Files         166      166           
  Lines        4784     4784           
=======================================
  Hits         4171     4171           
  Misses        613      613           

};

template <>
struct LogRecordSetterTrait<int64_t>
Copy link
Member

@owent owent Apr 28, 2023

Choose a reason for hiding this comment

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

Is it conflicted with Body?Log body can also be converted from int64_t implicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks for the catch. Seems the template part of filling logging record requires each parameter to be in different type, and the any type on body make it conflict with other parameters. Do you have any suggestion for this problem?

Copy link
Member

Choose a reason for hiding this comment

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

I have no idea for this problem by now, and I only avoided to specialize templates for these types before.
Maybe we can add a unit test to check the mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the passing of int64_t to SDK, instead, a temporary EventId struct will be constructed which should fix the issue.

For unittest, do you mean to cover all the variant types of body field?

Copy link
Member

@owent owent May 3, 2023

Choose a reason for hiding this comment

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

Yes, use EmitLogRecord to cover all the variant types of body field.
Maybe we can also add it in another PR later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, I added an integration test to cover if the EventId passed to the user-facing API is passed correctly to the SDK.

https:/ThomsonTan/opentelemetry-cpp/blob/otel_cpp_log_sdk_impl/exporters/ostream/test/ostream_log_test.cc#L465

@ThomsonTan ThomsonTan marked this pull request as ready for review April 29, 2023 00:09
@ThomsonTan ThomsonTan requested a review from a team April 29, 2023 00:09
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. Thanks

api/include/opentelemetry/logs/event_id.h Show resolved Hide resolved
* @param id the event Id to set
* @param name the event name to set
*/
void SetEventId(int64_t /* id */, nostd::string_view /* name */) noexcept override
Copy link
Member

@owent owent May 3, 2023

Choose a reason for hiding this comment

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

Sorry but did I miss anything? I can find any specification about event id in OTLP, should we add it just like semantic convention for event attributes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the idea is adding it as attribute to OTLP recordable, mark it as TODO for now.

@ThomsonTan
Copy link
Contributor Author

@owent please let me know if there is any comments I missed.

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.

Sorry for the delay, LGTM.

@ThomsonTan ThomsonTan merged commit 80f3018 into open-telemetry:main May 6, 2023
@ThomsonTan ThomsonTan deleted the otel_cpp_log_sdk_impl branch May 6, 2023 04:22
@marcalff marcalff changed the title SDK support for the new OTel log API [SDK] support for the new OTel log API May 23, 2023
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.

Support new user-facing log API in SDK
3 participants