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

Improvement for OTLP example #447

Merged
merged 2 commits into from
Dec 17, 2020
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
2 changes: 1 addition & 1 deletion examples/otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ service:
exporters: [zipkin]
```

Note that the OTLP exporter connects to the Collector at `localhost:55680` by default.
Note that the OTLP exporter connects to the Collector at `localhost:55680` by default. This can be changed with first argument from command-line, for example: `./example_otlp gateway.docker.internal:55680`.

Once you have the Collector running, see [CONTRIBUTING.md](../../CONTRIBUTING.md) for instructions on building and running the example.
9 changes: 7 additions & 2 deletions examples/otlp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ namespace otlp = opentelemetry::exporter::otlp;

namespace
{
opentelemetry::exporter::otlp::OtlpExporterOptions opts;
void InitTracer()
{
// Create OTLP exporter instance
auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new otlp::OtlpExporter);
auto exporter = std::unique_ptr<sdktrace::SpanExporter>(new otlp::OtlpExporter(opts));

auto processor = std::shared_ptr<sdktrace::SpanProcessor>(
new sdktrace::SimpleSpanProcessor(std::move(exporter)));
Expand All @@ -25,8 +26,12 @@ void InitTracer()
}
} // namespace

int main()
int main(int argc, char *argv[])
{
if (argc > 1)
{
opts.endpoint = argv[1];
}
// Removing this line will leave the default noop TracerProvider in place.
InitTracer();

Expand Down