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

[EXAMPLES] Use logs API instead of logs bridge API in the example #2494

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/common/logs_foo_library/foo_library.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void foo_library()
auto scoped_span = trace::Scope(get_tracer()->StartSpan("foo_library"));
auto ctx = span->GetContext();
auto logger = get_logger();
logger->EmitLogRecord(opentelemetry::logs::Severity::kDebug, "body", ctx.trace_id(),
ctx.span_id(), ctx.trace_flags(),
opentelemetry::common::SystemTimestamp(std::chrono::system_clock::now()));

logger->Debug("body", ctx.trace_id(), ctx.span_id(), ctx.trace_flags());
}
12 changes: 6 additions & 6 deletions examples/logs_simple/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

# Simple Logs Example

In this example, the application in `main.cc` initializes an
`OStreamLogRecordExporter` instance and registers a logger
provider, as well as initializes a `StdoutSpanExporter` instance and registers a
tracer provider from the [OpenTelemetry
tracer provider from the [OpenTelemetry C++
SDK](https://github.com/open-telemetry/opentelemetry-cpp).

The application then calls a `logs_foo_library` which has been instrumented
using the [OpenTelemetry
API](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/api).
Resulting logs and traces are directed to stdout.
The application then calls into
[`logs_foo_library`](https://github.com/open-telemetry/opentelemetry-cpp/blob/main/examples/common/logs_foo_library/foo_library.cc)
which has been instrumented using the [OpenTelemetry Logs
API](../../api/include/opentelemetry/logs/logger.h). Resulting logs and traces
are directed to stdout.

See [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and
running the example.