Skip to content

Commit

Permalink
fix errors in SDK documentation (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored Feb 9, 2022
1 parent 44795b6 commit e1c8557
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions docs/public/sdk/GettingStarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ The OpenTelemetry C++ SDK allow for creation of Resources and for associating th
auto resource_attributes = opentelemetry::sdk::resource::ResourceAttributes
{
{"service.name": "shoppingcart"},
{"service.instance.id": "instance-12"}
{"service.name", "shoppingcart"},
{"service.instance.id", "instance-12"}
};
auto resource = opentelemetry::sdk::resource::Resource::Create(resource_attributes);
auto received_attributes = resource.GetAttributes();
Expand Down Expand Up @@ -136,18 +136,21 @@ OpenTelemetry C++ SDK offers four samplers out of the box:
.. code:: cpp
//AlwaysOnSampler
opentelemetry::sdk::trace::AlwaysOnSampler always_on_sampler;
auto always_on_sampler = std::unique_ptr<sdktrace::AlwaysOnSampler>
(new sdktrace::AlwaysOnSampler);
//AlwaysOffSampler
opentelemetry::sdk::trace::AlwaysOffSampler always_off_sampler;
auto always_off_sampler = std::unique_ptr<sdktrace::AlwaysOffSampler>
(new sdktrace::AlwaysOffSampler);
//ParentBasedSampler
opentelemetry::sdk::trace::ParentBasedSampler sampler_off(std::make_shared<AlwaysOffSampler>());
auto parent_based_sampler = std::unique_ptr<sdktrace::ParentBasedSampler>
(new sdktrace::ParentBasedSampler);
//TraceIdRatioBasedSampler - Sample 50% generated spans
double ratio = 0.5;
opentelemetry::sdk::trace::TraceIdRatioBasedSampler s(ratio);
auto always_off_sampler = std::unique_ptr<sdktrace::TraceIdRatioBasedSampler>
(new sdktrace::TraceIdRatioBasedSampler(ratio));
TracerContext
^^^^^^^^^^^^^
Expand All @@ -172,11 +175,12 @@ There are two different mechanisms to create TraceProvider instance
.. code:: cpp
// Created using `TracerContext` instance
auto tracer_provider = sdktrace::TracerProvider(tracer_context);
auto tracer_provider = nostd::shared_ptr<sdktrace::TracerProvider>
(new sdktrace::TracerProvider(tracer_context));
// Create using SDK configurations as parameter
auto tracer_provider =
sdktrace::TracerProvider(std::move(simple_processor), resource, std::move(always_on_sampler));
auto tracer_provider = nostd::shared_ptr<sdktrace::TracerProvider>
(std::move(simple_processor), resource, std::move(always_on_sampler));
// set the global tracer TraceProvider
opentelemetry::trace::Provider::SetTracerProvider(tracer_provider);
Expand Down

1 comment on commit e1c8557

@github-actions
Copy link

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp api Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: e1c8557 Previous: 44795b6 Ratio
BM_SpinLockThrashing/1/process_time/real_time 0.4438584524102019 ms/iter 0.11017736514664923 ms/iter 4.03
BM_ProcYieldSpinLockThrashing/1/process_time/real_time 0.45503040708868625 ms/iter 0.1948637032658799 ms/iter 2.34
BM_NaiveSpinLockThrashing/1/process_time/real_time 0.5566352426749954 ms/iter 0.1104881010752629 ms/iter 5.04
BM_ThreadYieldSpinLockThrashing/1/process_time/real_time 26.73490047454834 ms/iter 6.40150633725253 ms/iter 4.18
BM_ThreadYieldSpinLockThrashing/2/process_time/real_time 51.793416341145836 ms/iter 25.6960391998291 ms/iter 2.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.