blob: d022e5c23f287af894e06f56a8d098e2030be103 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#include "opentelemetry/sdk/trace/simple_processor.h"
#include "opentelemetry/sdk/trace/tracer_provider.h"
#include "opentelemetry/trace/provider.h"
// Using an exporter that simply dumps span data to stdout.
#ifdef BAZEL_BUILD
# include "examples/common/foo_library/foo_library.h"
#else
# include "foo_library/foo_library.h"
#endif
#include "opentelemetry/exporters/ostream/span_exporter.h"
namespace trace_api = opentelemetry::trace;
namespace trace_sdk = opentelemetry::sdk::trace;
namespace nostd = opentelemetry::nostd;
namespace
{
void initTracer()
{
auto exporter = std::unique_ptr<trace_sdk::SpanExporter>(
new opentelemetry::exporter::trace::OStreamSpanExporter);
auto processor = std::unique_ptr<trace_sdk::SpanProcessor>(
new trace_sdk::SimpleSpanProcessor(std::move(exporter)));
auto provider = nostd::shared_ptr<trace_api::TracerProvider>(
new trace_sdk::TracerProvider(std::move(processor)));
// Set the global trace provider
trace_api::Provider::SetTracerProvider(provider);
}
} // namespace
int main()
{
// Removing this line will leave the default noop TracerProvider in place.
initTracer();
foo_library();
}
|