Skip to content

Commit

Permalink
Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
psx95 committed Nov 11, 2024
1 parent 229a93c commit 73df243
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
5 changes: 4 additions & 1 deletion sdk/include/opentelemetry/sdk/trace/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "opentelemetry/sdk/trace/id_generator.h"
#include "opentelemetry/sdk/trace/processor.h"
#include "opentelemetry/sdk/trace/sampler.h"
#include "opentelemetry/sdk/trace/tracer_config.h"
#include "opentelemetry/sdk/trace/tracer_context.h"
#include "opentelemetry/trace/span.h"
#include "opentelemetry/trace/span_context_kv_iterable.h"
Expand All @@ -35,7 +36,8 @@ class Tracer final : public opentelemetry::trace::Tracer,
/** Construct a new Tracer with the given context pipeline. */
explicit Tracer(std::shared_ptr<TracerContext> context,
std::unique_ptr<InstrumentationScope> instrumentation_scope =
InstrumentationScope::Create("")) noexcept;
InstrumentationScope::Create(""),
TracerConfig tracer_config = TracerConfig::Default()) noexcept;

nostd::shared_ptr<opentelemetry::trace::Span> StartSpan(
nostd::string_view name,
Expand Down Expand Up @@ -105,6 +107,7 @@ class Tracer final : public opentelemetry::trace::Tracer,
// tracer-context.
std::shared_ptr<InstrumentationScope> instrumentation_scope_;
std::shared_ptr<TracerContext> context_;
TracerConfig tracer_config_;
};
} // namespace trace
} // namespace sdk
Expand Down
7 changes: 4 additions & 3 deletions sdk/include/opentelemetry/sdk/trace/tracer_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace trace
/**
* TracerConfig defines various configurable aspects of a Tracer's behavior.
*/
class TracerConfig {
class TracerConfig
{
public:
/**
* Returns if the Tracer is enabled or disabled. Tracers are enabled by default.
Expand All @@ -31,6 +32,6 @@ class TracerConfig {
static TracerConfig kDefaultConfig;
static TracerConfig kDisabledConfig;
};
} // namespace trace
} // namespace sdk
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
8 changes: 8 additions & 0 deletions sdk/include/opentelemetry/sdk/trace/tracer_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ class OPENTELEMETRY_EXPORT TracerProvider final : public opentelemetry::trace::T
std::unique_ptr<IdGenerator> id_generator =
std::unique_ptr<IdGenerator>(new RandomIdGenerator())) noexcept;

// explicit TracerProvider(
// std::vector<std::unique_ptr<SpanProcessor>> &&processors,
// const opentelemetry::sdk::resource::Resource &resource =
// opentelemetry::sdk::resource::Resource::Create({}),
// std::unique_ptr<Sampler> sampler = std::unique_ptr<AlwaysOnSampler>(new AlwaysOnSampler),
// std::unique_ptr<IdGenerator> id_generator =
// std::unique_ptr<IdGenerator>(new RandomIdGenerator())) noexcept;

/**
* Initialize a new tracer provider with a specified context
* @param context The owned tracer configuration/pipeline for this provider.
Expand Down
7 changes: 5 additions & 2 deletions sdk/src/trace/tracer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ namespace trace
{

Tracer::Tracer(std::shared_ptr<TracerContext> context,
std::unique_ptr<InstrumentationScope> instrumentation_scope) noexcept
: instrumentation_scope_{std::move(instrumentation_scope)}, context_{std::move(context)}
std::unique_ptr<InstrumentationScope> instrumentation_scope,
TracerConfig tracer_config) noexcept
: instrumentation_scope_{std::move(instrumentation_scope)},
context_{std::move(context)},
tracer_config_(tracer_config)
{}

nostd::shared_ptr<opentelemetry::trace::Span> Tracer::StartSpan(
Expand Down
12 changes: 7 additions & 5 deletions sdk/src/trace/tracer_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ namespace sdk
namespace trace
{

TracerConfig TracerConfig::kDefaultConfig = TracerConfig();
TracerConfig TracerConfig::kDefaultConfig = TracerConfig();
TracerConfig TracerConfig::kDisabledConfig = TracerConfig(true);

TracerConfig TracerConfig::Disabled() {
TracerConfig TracerConfig::Disabled()
{
return kDisabledConfig;
}

TracerConfig TracerConfig::Enabled() {
TracerConfig TracerConfig::Enabled()
{
return kDefaultConfig;
}

Expand All @@ -30,6 +32,6 @@ bool TracerConfig::IsEnabled() const noexcept
{
return !disabled_;
}
}// namespace trace
}// namespace sdk
} // namespace trace
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
4 changes: 1 addition & 3 deletions sdk/src/trace/tracer_provider.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include <algorithm>
#include <chrono>
#include <mutex>
#include <utility>
Expand All @@ -19,7 +18,6 @@
#include "opentelemetry/sdk/trace/tracer.h"
#include "opentelemetry/sdk/trace/tracer_context.h"
#include "opentelemetry/sdk/trace/tracer_provider.h"
#include "opentelemetry/trace/span_id.h"
#include "opentelemetry/trace/tracer.h"
#include "opentelemetry/version.h"

Expand Down Expand Up @@ -60,7 +58,7 @@ TracerProvider::TracerProvider(std::vector<std::unique_ptr<SpanProcessor>> &&pro
TracerProvider::~TracerProvider()
{
// Tracer hold the shared pointer to the context. So we can not use destructor of TracerContext to
// Shutdown and flush all pending recordables when we have more than one tracers.These recordables
// Shutdown and flush all pending recordables when we have more than one tracer.These recordables
// may use the raw pointer of instrumentation_scope_ in Tracer
if (context_)
{
Expand Down

0 comments on commit 73df243

Please sign in to comment.