Skip to content

Commit 74c9e34

Browse files
committed
Add documentation for updated code
1 parent e2c22df commit 74c9e34

File tree

5 files changed

+56
-6
lines changed

5 files changed

+56
-6
lines changed

sdk/include/opentelemetry/sdk/metrics/meter_config.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,42 @@ namespace sdk
1010
{
1111
namespace metrics
1212
{
13+
/**
14+
* MeterConfig defines various configurable aspects of a Meter's behavior.
15+
* This class should not be used directly to configure a Meter's behavior, instead a
16+
* ScopeConfigurator should be used to compute the desired MeterConfig which can then be used to
17+
* configure a Meter.
18+
*/
1319
class MeterConfig
1420
{
1521
public:
1622
bool operator==(const MeterConfig &other) const noexcept;
1723

24+
/**
25+
* Returns if the Meter is enabled or disabled. Meters are enabled by default.
26+
* @return a boolean indicating if the Meter is enabled. Defaults to true.
27+
*/
1828
bool IsEnabled() const noexcept;
1929

30+
/**
31+
* Returns a MeterConfig that represents a disabled Meter. A disabled meter behaves like a
32+
* no-op meter.
33+
* @return a static constant MeterConfig that represents a disabled meter.
34+
*/
2035
static MeterConfig Disabled();
2136

37+
/**
38+
* Returns a MeterConfig that represents an enabled Meter.
39+
* @return a static constant MeterConfig that represents an enabled meter.
40+
*/
2241
static MeterConfig Enabled();
2342

43+
/**
44+
* Returns a MeterConfig that represents a Meter configured with the default behavior.
45+
* The default behavior is guided by the OpenTelemetry specification.
46+
* @return a static constant MeterConfig that represents a meter configured with default
47+
* behavior.
48+
*/
2449
static MeterConfig Default();
2550

2651
private:
@@ -31,4 +56,4 @@ class MeterConfig
3156
};
3257
} // namespace metrics
3358
} // namespace sdk
34-
OPENTELEMETRY_END_NAMESPACE
59+
OPENTELEMETRY_END_NAMESPACE

sdk/include/opentelemetry/sdk/metrics/meter_context.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,20 @@ class MeterContext : public std::enable_shared_from_this<MeterContext>
7575
*/
7676
ViewRegistry *GetViewRegistry() const noexcept;
7777

78+
/**
79+
* Obtain the ScopeConfigurator with this meter context.
80+
* @return The ScopeConfigurator for this meter context.
81+
*/
7882
const instrumentationscope::ScopeConfigurator<MeterConfig> &GetMeterConfigurator() const noexcept;
7983

8084
/**
81-
* NOTE - INTERNAL method, can change in future.
85+
* NOTE - INTERNAL method, can change in the future.
8286
* Process callback for each meter in thread-safe manner
8387
*/
8488
bool ForEachMeter(nostd::function_ref<bool(std::shared_ptr<Meter> &meter)> callback) noexcept;
8589

8690
/**
87-
* NOTE - INTERNAL method, can change in future.
91+
* NOTE - INTERNAL method, can change in the future.
8892
* Get the configured meters.
8993
* This method is NOT thread safe, and only called through MeterProvider
9094
*

sdk/include/opentelemetry/sdk/metrics/meter_context_factory.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,35 @@ class OPENTELEMETRY_EXPORT MeterContextFactory
2323
{
2424
public:
2525
/**
26-
* Create a MeterContext.
26+
* Create a MeterContext with valid defaults.
27+
* @return A unique pointer to the created MeterContext object.
2728
*/
2829
static std::unique_ptr<MeterContext> Create();
2930

31+
/**
32+
* Create a MeterContext with specified views.
33+
* @param views ViewRegistry containing OpenTelemetry views registered with this meter context.
34+
*/
3035
static std::unique_ptr<MeterContext> Create(std::unique_ptr<ViewRegistry> views);
3136

37+
/**
38+
* Create a MeterContext with specified views and resource.
39+
* @param views ViewRegistry containing OpenTelemetry views registered with this meter context.
40+
* @param resource The OpenTelemetry resource associated with this meter context.
41+
* @return A unique pointer to the created MeterContext object.
42+
*/
3243
static std::unique_ptr<MeterContext> Create(
3344
std::unique_ptr<ViewRegistry> views,
3445
const opentelemetry::sdk::resource::Resource &resource);
3546

47+
/**
48+
* Create a MeterContext with specified views, resource and meter scope configurator.
49+
* @param views ViewRegistry containing OpenTelemetry views registered with this meter context.
50+
* @param resource The OpenTelemetry resource associated with this meter context.
51+
* @param meter_configurator A scope configurator defining the behavior of a meter associated with
52+
* this meter context.
53+
* @return A unique pointer to the created MeterContext object.
54+
*/
3655
static std::unique_ptr<MeterContext> Create(
3756
std::unique_ptr<ViewRegistry> views,
3857
const opentelemetry::sdk::resource::Resource &resource,

sdk/include/opentelemetry/sdk/metrics/meter_provider.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ class OPENTELEMETRY_EXPORT MeterProvider final : public opentelemetry::metrics::
3737
{
3838
public:
3939
/**
40-
* Initialize a new meter provider
40+
* Initialize a new meter provider.
4141
* @param views The views for this meter provider
4242
* @param resource The resources for this meter provider.
43+
* @param meter_configurator Provides access to a function that computes the MeterConfig for
44+
* Meters provided by this MeterProvider.
4345
*/
4446
MeterProvider(
4547
std::unique_ptr<ViewRegistry> views = std::unique_ptr<ViewRegistry>(new ViewRegistry()),

sdk/src/metrics/meter_config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ MeterConfig MeterConfig::Default()
3838

3939
} // namespace metrics
4040
} // namespace sdk
41-
OPENTELEMETRY_END_NAMESPACE
41+
OPENTELEMETRY_END_NAMESPACE

0 commit comments

Comments
 (0)