Skip to content

[Logs SDK] Log Appender for spdlog#357

Merged
marcalff merged 14 commits intoopen-telemetry:mainfrom
chusitoo:spdlog_sink
Feb 8, 2024
Merged

[Logs SDK] Log Appender for spdlog#357
marcalff merged 14 commits intoopen-telemetry:mainfrom
chusitoo:spdlog_sink

Conversation

@chusitoo
Copy link
Copy Markdown
Contributor

Implemented as described in open-telemetry/opentelemetry-cpp#2046:

  • Sink implemented in spdlog::sinks namespace for commonality with existing sinks.
  • Minimal examples provided to demonstrate the setup required.
  • Basic unit testing.
  • Tried using the same flags as those used in otel-cpp for configuring cmake project.
  • Add clang format file to help keep the style in line with otel-cpp repo.

@chusitoo chusitoo marked this pull request as ready for review December 28, 2023 01:30
@chusitoo chusitoo requested a review from a team December 28, 2023 01:30
using namespace opentelemetry::trace::SemanticConventions;

log_record->SetSeverity(levelToSeverity(msg.level));
log_record->SetBody(opentelemetry::nostd::string_view(msg.payload.data()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This should either use string_view(msg.payload.data(), msg.payload.size()) or string_view(msg.payload.c_str()) to avoid out-of-bounds access?

Copy link
Copy Markdown
Contributor Author

@chusitoo chusitoo Jan 3, 2024

Choose a reason for hiding this comment

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

Makes sense, thanks! Good catch.

RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Probably also makes sense to export the target itself so that it's easier to use this library in another cmake-based project, smth like

  install(
    EXPORT "${PROJECT_NAME}-target"
    FILE "${PROJECT_NAME}-target.cmake"
    NAMESPACE "${PROJECT_NAME}::"
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

?

Ideally also a config (see e.g. https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html#creating-a-package-configuration-file) for easier discoverability / reuse?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's reasonable, I'll have a look. I was seeing it as a Makefile-based build only.

Copy link
Copy Markdown
Member

@marcalff marcalff left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

instrumentation:spdlog Spdlog log appender

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants