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

Otlp http log example #1062

Merged
merged 16 commits into from
Nov 17, 2021
Merged

Conversation

esigo
Copy link
Member

@esigo esigo commented Nov 12, 2021

otlp http log example

Changes

Adds otlp http log example
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 Nov 12, 2021

Codecov Report

Merging #1062 (eb4b0a0) into main (3db551f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1062   +/-   ##
=======================================
  Coverage   94.41%   94.41%           
=======================================
  Files         158      158           
  Lines        6077     6077           
=======================================
  Hits         5737     5737           
  Misses        340      340           

@lalitb
Copy link
Member

lalitb commented Nov 13, 2021

/easycla

@esigo esigo changed the title [WIP] Otlp http log example Otlp http log example Nov 13, 2021
@esigo esigo marked this pull request as ready for review November 13, 2021 17:13
@esigo esigo requested a review from a team November 13, 2021 17:13
namespace logs_api = opentelemetry::logs;

namespace sdktrace = opentelemetry::sdk::trace;

Copy link
Member

Choose a reason for hiding this comment

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

nit - use namespace alias as trace_sdk, logs and logs_sdkfor consistency with other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

defines = ["BAZEL_BUILD"],
deps = [
"//api",
"//sdk:headers",
Copy link
Member

Choose a reason for hiding this comment

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

why do we need sdk::headers, I see this included in earlier PRs too so probably I am missing something :)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed for "opentelemetry/sdk/version/version.h".

Copy link
Member

Choose a reason for hiding this comment

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

ok, thanks for letting me know. Not related to this PR, but we may have to revisit this afterward as ideally instrumentation libraries should have no dependency on SDK.

nostd::shared_ptr<logs::Logger> get_logger()
{
auto provider = logs::Provider::GetLoggerProvider();
return provider->GetLogger("foo_library_logger", nostd::span<nostd::string_view>());
Copy link
Member

Choose a reason for hiding this comment

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

return provider->GetLogger("foo_library_logger"); will be much simpler ?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

logger->Log(opentelemetry::logs::Severity::kDebug, "name", "body",
std::map<std::string, std::string>(), std::map<std::string, std::string>(),
ctx.trace_id(), ctx.span_id(), ctx.trace_flags(),
opentelemetry::common::SystemTimestamp());
Copy link
Member

@lalitb lalitb Nov 16, 2021

Choose a reason for hiding this comment

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

Haven't tested it, but we should be able to simplify this by using the initializer-list for resources and attributes ( refer API tests for logger for example):

logger->Log(opentelemetry::logs::Severity::kDebug, "name", "body", {}, {}, ctx.trace_id(), ctx.span_id(), ctx.trace_flags(), opentelemetry::common::SystemTimestamp());

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ThomsonTan ThomsonTan merged commit 97fbdaa into open-telemetry:main Nov 17, 2021
@esigo esigo deleted the otlp-http-log-example branch November 17, 2021 18:05
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