Skip to content

Commit

Permalink
Fix spell error and optimize the example of multi_processor
Browse files Browse the repository at this point in the history
Signed-off-by: owent <admin@owent.net>
  • Loading branch information
owent committed Apr 7, 2022
1 parent 2fd7abd commit acd96cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CI tests can be run on docker by invoking the script `./ci/run_docker.sh
* `bazel.legacy.test`: build bazel targets and run tests for the targets meant
to work with older compilers.
* `bazel.noexcept`: build bazel targets and run tests with exceptions disabled.
* `bazel.noriit`: build bazel targets and run tests with runtime type
* `bazel.nortti`: build bazel targets and run tests with runtime type
identification disabled.
* `bazel.asan`: build bazel targets and run tests with AddressSanitizer.
* `bazel.tsan`: build bazel targets and run tests with ThreadSanitizer.
Expand Down
12 changes: 6 additions & 6 deletions examples/multi_processor/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ namespace trace_api = opentelemetry::trace;
namespace trace_sdk = opentelemetry::sdk::trace;
namespace nostd = opentelemetry::nostd;

InMemorySpanExporter *memory_span_exporter;

namespace
{
void initTracer()
InMemorySpanExporter *initTracer()
{
auto exporter1 = std::unique_ptr<trace_sdk::SpanExporter>(
new opentelemetry::exporter::trace::OStreamSpanExporter);
auto processor1 = std::unique_ptr<trace_sdk::SpanProcessor>(
new trace_sdk::SimpleSpanProcessor(std::move(exporter1)));

auto exporter2 = std::unique_ptr<trace_sdk::SpanExporter>(new InMemorySpanExporter());
InMemorySpanExporter *memory_span_exporter = new InMemorySpanExporter();
auto exporter2 = std::unique_ptr<trace_sdk::SpanExporter>(memory_span_exporter);

// fetch the exporter for dumping data later
memory_span_exporter = static_cast<InMemorySpanExporter *>(exporter2.get());

auto processor2 = std::unique_ptr<trace_sdk::SpanProcessor>(
new trace_sdk::SimpleSpanProcessor(std::move(exporter2)));
Expand All @@ -44,6 +42,8 @@ void initTracer()
provider->AddProcessor(std::move(processor2));
// Set the global trace provider
trace_api::Provider::SetTracerProvider(std::move(provider));

return memory_span_exporter;
}

void dumpSpans(std::vector<std::unique_ptr<trace_sdk::SpanData>> &spans)
Expand Down Expand Up @@ -81,7 +81,7 @@ void dumpSpans(std::vector<std::unique_ptr<trace_sdk::SpanData>> &spans)
int main()
{
// Removing this line will leave the default noop TracerProvider in place.
initTracer();
InMemorySpanExporter *memory_span_exporter = initTracer();

foo_library();
auto memory_spans = memory_span_exporter->GetData()->GetSpans();
Expand Down

0 comments on commit acd96cd

Please sign in to comment.