Skip to content

Commit eecf89f

Browse files
committed
Fix formatting
1 parent bd8cb23 commit eecf89f

File tree

9 files changed

+99
-121
lines changed

9 files changed

+99
-121
lines changed

api/include/opentelemetry/metrics/noop.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,20 @@ class NoopGauge : public Gauge<T>
7777
{
7878
public:
7979
NoopGauge(nostd::string_view /* name */,
80-
nostd::string_view /* description */,
81-
nostd::string_view /* unit */) noexcept
80+
nostd::string_view /* description */,
81+
nostd::string_view /* unit */) noexcept
8282
{}
8383
~NoopGauge() override = default;
8484
void Record(T /* value */) noexcept override {}
8585
void Record(T /* value */, const context::Context & /* context */) noexcept override {}
8686
void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
8787
void Record(T /* value */,
88-
const common::KeyValueIterable & /* attributes */,
89-
const context::Context & /* context */) noexcept override
88+
const common::KeyValueIterable & /* attributes */,
89+
const context::Context & /* context */) noexcept override
9090
{}
9191
};
9292
#endif
9393

94-
9594
class NoopObservableInstrument : public ObservableInstrument
9695
{
9796
public:
@@ -162,18 +161,16 @@ class NoopMeter final : public Meter
162161
}
163162

164163
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
165-
nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(
166-
nostd::string_view name,
167-
nostd::string_view description = "",
168-
nostd::string_view unit = "") noexcept override
164+
nostd::unique_ptr<Gauge<int64_t>> CreateInt64Gauge(nostd::string_view name,
165+
nostd::string_view description = "",
166+
nostd::string_view unit = "") noexcept override
169167
{
170168
return nostd::unique_ptr<Gauge<int64_t>>{new NoopGauge<int64_t>(name, description, unit)};
171169
}
172170

173-
nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(
174-
nostd::string_view name,
175-
nostd::string_view description = "",
176-
nostd::string_view unit = "") noexcept override
171+
nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(nostd::string_view name,
172+
nostd::string_view description = "",
173+
nostd::string_view unit = "") noexcept override
177174
{
178175
return nostd::unique_ptr<Gauge<double>>{new NoopGauge<double>(name, description, unit)};
179176
}

api/include/opentelemetry/metrics/sync_instruments.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ class Gauge : public SynchronousInstrument
286286
* @param context The explicit context to associate with this measurement.
287287
*/
288288
virtual void Record(T value,
289-
const common::KeyValueIterable &attributes,
290-
const context::Context &context) noexcept = 0;
289+
const common::KeyValueIterable &attributes,
290+
const context::Context &context) noexcept = 0;
291291

292292
template <class U,
293293
nostd::enable_if_t<common::detail::is_key_value_iterable<U>::value> * = nullptr>
@@ -304,21 +304,22 @@ class Gauge : public SynchronousInstrument
304304
}
305305

306306
void Record(T value,
307-
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
308-
attributes) noexcept
307+
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
308+
attributes) noexcept
309309
{
310310
this->Record(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
311-
attributes.begin(), attributes.end()});
311+
attributes.begin(), attributes.end()});
312312
}
313313

314-
void Record(T value,
315-
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
316-
const context::Context &context) noexcept
314+
void Record(
315+
T value,
316+
std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>> attributes,
317+
const context::Context &context) noexcept
317318
{
318319
this->Record(value,
319-
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
320-
attributes.begin(), attributes.end()},
321-
context);
320+
nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
321+
attributes.begin(), attributes.end()},
322+
context);
322323
}
323324
};
324325
#endif

examples/common/metrics_foo_library/foo_library.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ void foo_library::histogram_example(const std::string &name)
106106
histogram_counter->Record(val, labelkv, context);
107107
std::this_thread::sleep_for(std::chrono::milliseconds(250));
108108
}
109-
110-
111109
}
112110

113111
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
@@ -120,7 +118,7 @@ void foo_library::gauge_example(const std::string &name)
120118
auto context = opentelemetry::context::Context{};
121119
for (uint32_t i = 0; i < 20; ++i)
122120
{
123-
int64_t val = (rand() % 100) + 100;
121+
int64_t val = (rand() % 100) + 100;
124122
std::map<std::string, std::string> labels = get_random_attr();
125123
auto labelkv = opentelemetry::common::KeyValueIterableView<decltype(labels)>{labels};
126124
gauge->Record(val, labelkv, context);

sdk/include/opentelemetry/sdk/metrics/meter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Meter final : public opentelemetry::metrics::Meter
8585
nostd::string_view name,
8686
nostd::string_view description = "",
8787
nostd::string_view unit = "") noexcept override;
88-
#endif
88+
#endif
8989

9090
nostd::shared_ptr<opentelemetry::metrics::ObservableInstrument> CreateInt64ObservableGauge(
9191
nostd::string_view name,

sdk/include/opentelemetry/sdk/metrics/sync_instruments.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ class LongGauge : public Synchronous, public opentelemetry::metrics::Gauge<int64
106106
{
107107
public:
108108
LongGauge(const InstrumentDescriptor &instrument_descriptor,
109-
std::unique_ptr<SyncWritableMetricStorage> storage);
109+
std::unique_ptr<SyncWritableMetricStorage> storage);
110110

111111
void Record(int64_t value,
112-
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
112+
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
113113
void Record(int64_t value,
114-
const opentelemetry::common::KeyValueIterable &attributes,
115-
const opentelemetry::context::Context &context) noexcept override;
114+
const opentelemetry::common::KeyValueIterable &attributes,
115+
const opentelemetry::context::Context &context) noexcept override;
116116

117117
void Record(int64_t value) noexcept override;
118118
void Record(int64_t value, const opentelemetry::context::Context &context) noexcept override;
@@ -122,13 +122,13 @@ class DoubleGauge : public Synchronous, public opentelemetry::metrics::Gauge<dou
122122
{
123123
public:
124124
DoubleGauge(const InstrumentDescriptor &instrument_descriptor,
125-
std::unique_ptr<SyncWritableMetricStorage> storage);
125+
std::unique_ptr<SyncWritableMetricStorage> storage);
126126

127127
void Record(double value,
128-
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
128+
const opentelemetry::common::KeyValueIterable &attributes) noexcept override;
129129
void Record(double value,
130-
const opentelemetry::common::KeyValueIterable &attributes,
131-
const opentelemetry::context::Context &context) noexcept override;
130+
const opentelemetry::common::KeyValueIterable &attributes,
131+
const opentelemetry::context::Context &context) noexcept override;
132132

133133
void Record(double value) noexcept override;
134134
void Record(double value, const opentelemetry::context::Context &context) noexcept override;

sdk/src/metrics/meter.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ opentelemetry::nostd::unique_ptr<metrics::Gauge<int64_t>> Meter::CreateInt64Gaug
202202
}
203203
InstrumentDescriptor instrument_descriptor = {
204204
std::string{name.data(), name.size()}, std::string{description.data(), description.size()},
205-
std::string{unit.data(), unit.size()}, InstrumentType::kGauge,
206-
InstrumentValueType::kLong};
205+
std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kLong};
207206
auto storage = RegisterSyncMetricStorage(instrument_descriptor);
208207
return opentelemetry::nostd::unique_ptr<metrics::Gauge<int64_t>>{
209208
new LongGauge(instrument_descriptor, std::move(storage))};
@@ -224,8 +223,7 @@ opentelemetry::nostd::unique_ptr<metrics::Gauge<double>> Meter::CreateDoubleGaug
224223
}
225224
InstrumentDescriptor instrument_descriptor = {
226225
std::string{name.data(), name.size()}, std::string{description.data(), description.size()},
227-
std::string{unit.data(), unit.size()}, InstrumentType::kGauge,
228-
InstrumentValueType::kDouble};
226+
std::string{unit.data(), unit.size()}, InstrumentType::kGauge, InstrumentValueType::kDouble};
229227
auto storage = RegisterSyncMetricStorage(instrument_descriptor);
230228
return opentelemetry::nostd::unique_ptr<metrics::Gauge<double>>{
231229
new DoubleGauge(instrument_descriptor, std::move(storage))};

sdk/src/metrics/sync_instruments.cc

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -294,40 +294,37 @@ void DoubleUpDownCounter::Add(double value, const opentelemetry::context::Contex
294294

295295
#if OPENTELEMETRY_ABI_VERSION_NO >= 2
296296
LongGauge::LongGauge(const InstrumentDescriptor &instrument_descriptor,
297-
std::unique_ptr<SyncWritableMetricStorage> storage)
297+
std::unique_ptr<SyncWritableMetricStorage> storage)
298298
: Synchronous(instrument_descriptor, std::move(storage))
299299
{
300300
if (!storage_)
301301
{
302-
OTEL_INTERNAL_LOG_ERROR(
303-
"[LongGauge::LongGauge] - Error constructing LongGauge."
304-
<< "The metric storage is invalid for " << instrument_descriptor.name_);
302+
OTEL_INTERNAL_LOG_ERROR("[LongGauge::LongGauge] - Error constructing LongGauge."
303+
<< "The metric storage is invalid for " << instrument_descriptor.name_);
305304
}
306305
}
307306

308307
void LongGauge::Record(int64_t value,
309-
const opentelemetry::common::KeyValueIterable &attributes) noexcept
308+
const opentelemetry::common::KeyValueIterable &attributes) noexcept
310309
{
311310
auto context = opentelemetry::context::Context{};
312311
if (!storage_)
313312
{
314-
OTEL_INTERNAL_LOG_WARN(
315-
"[LongGauge::Record(V,A)] Value not recorded - invalid storage for: "
316-
<< instrument_descriptor_.name_);
313+
OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A)] Value not recorded - invalid storage for: "
314+
<< instrument_descriptor_.name_);
317315
return;
318316
}
319317
return storage_->RecordLong(value, attributes, context);
320318
}
321319

322320
void LongGauge::Record(int64_t value,
323-
const opentelemetry::common::KeyValueIterable &attributes,
324-
const opentelemetry::context::Context &context) noexcept
321+
const opentelemetry::common::KeyValueIterable &attributes,
322+
const opentelemetry::context::Context &context) noexcept
325323
{
326324
if (!storage_)
327325
{
328-
OTEL_INTERNAL_LOG_WARN(
329-
"[LongGauge::Record(V,A,C)] Value not recorded - invalid storage for: "
330-
<< instrument_descriptor_.name_);
326+
OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,A,C)] Value not recorded - invalid storage for: "
327+
<< instrument_descriptor_.name_);
331328
return;
332329
}
333330
return storage_->RecordLong(value, attributes, context);
@@ -349,48 +346,44 @@ void LongGauge::Record(int64_t value, const opentelemetry::context::Context &con
349346
{
350347
if (!storage_)
351348
{
352-
OTEL_INTERNAL_LOG_WARN(
353-
"[LongGauge::Record(V,C)] Value not recorded - invalid storage for: "
354-
<< instrument_descriptor_.name_);
349+
OTEL_INTERNAL_LOG_WARN("[LongGauge::Record(V,C)] Value not recorded - invalid storage for: "
350+
<< instrument_descriptor_.name_);
355351
return;
356352
}
357353
return storage_->RecordLong(value, context);
358354
}
359355

360356
DoubleGauge::DoubleGauge(const InstrumentDescriptor &instrument_descriptor,
361-
std::unique_ptr<SyncWritableMetricStorage> storage)
357+
std::unique_ptr<SyncWritableMetricStorage> storage)
362358
: Synchronous(instrument_descriptor, std::move(storage))
363359
{
364360
if (!storage_)
365361
{
366-
OTEL_INTERNAL_LOG_ERROR(
367-
"[DoubleGauge::DoubleGauge] - Error constructing DoubleUpDownCounter."
368-
<< "The metric storage is invalid for " << instrument_descriptor.name_);
362+
OTEL_INTERNAL_LOG_ERROR("[DoubleGauge::DoubleGauge] - Error constructing DoubleUpDownCounter."
363+
<< "The metric storage is invalid for " << instrument_descriptor.name_);
369364
}
370365
}
371366

372367
void DoubleGauge::Record(double value,
373-
const opentelemetry::common::KeyValueIterable &attributes) noexcept
368+
const opentelemetry::common::KeyValueIterable &attributes) noexcept
374369
{
375370
if (!storage_)
376371
{
377-
OTEL_INTERNAL_LOG_WARN(
378-
"[DoubleGauge::Record(V,A)] Value not recorded - invalid storage for: "
379-
<< instrument_descriptor_.name_);
372+
OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A)] Value not recorded - invalid storage for: "
373+
<< instrument_descriptor_.name_);
380374
}
381375
auto context = opentelemetry::context::Context{};
382376
return storage_->RecordDouble(value, attributes, context);
383377
}
384378

385379
void DoubleGauge::Record(double value,
386-
const opentelemetry::common::KeyValueIterable &attributes,
387-
const opentelemetry::context::Context &context) noexcept
380+
const opentelemetry::common::KeyValueIterable &attributes,
381+
const opentelemetry::context::Context &context) noexcept
388382
{
389383
if (!storage_)
390384
{
391-
OTEL_INTERNAL_LOG_WARN(
392-
"[DoubleGauge::Record(V,A,C)] Value not recorded - invalid storage for: "
393-
<< instrument_descriptor_.name_);
385+
OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,A,C)] Value not recorded - invalid storage for: "
386+
<< instrument_descriptor_.name_);
394387
return;
395388
}
396389
return storage_->RecordDouble(value, attributes, context);
@@ -400,9 +393,8 @@ void DoubleGauge::Record(double value) noexcept
400393
{
401394
if (!storage_)
402395
{
403-
OTEL_INTERNAL_LOG_WARN(
404-
"[DoubleGauge::Record(V)] Value not recorded - invalid storage for: "
405-
<< instrument_descriptor_.name_);
396+
OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V)] Value not recorded - invalid storage for: "
397+
<< instrument_descriptor_.name_);
406398
return;
407399
}
408400
auto context = opentelemetry::context::Context{};
@@ -413,9 +405,8 @@ void DoubleGauge::Record(double value, const opentelemetry::context::Context &co
413405
{
414406
if (!storage_)
415407
{
416-
OTEL_INTERNAL_LOG_WARN(
417-
"[DoubleGauge::Record(V,C)] Value not recorded - invalid storage for: "
418-
<< instrument_descriptor_.name_);
408+
OTEL_INTERNAL_LOG_WARN("[DoubleGauge::Record(V,C)] Value not recorded - invalid storage for: "
409+
<< instrument_descriptor_.name_);
419410
return;
420411
}
421412
return storage_->RecordDouble(value, context);

sdk/test/metrics/sync_instruments_test.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,40 +109,37 @@ TEST(SyncInstruments, DoubleUpDownCounter)
109109
TEST(SyncInstruments, LongGauge)
110110
{
111111
InstrumentDescriptor instrument_descriptor = {"long_gauge", "description", "1",
112-
InstrumentType::kGauge,
113-
InstrumentValueType::kLong};
112+
InstrumentType::kGauge, InstrumentValueType::kLong};
114113
std::unique_ptr<SyncWritableMetricStorage> metric_storage(new SyncMultiMetricStorage());
115114
LongGauge gauge(instrument_descriptor, std::move(metric_storage));
116115
gauge.Record(10);
117116
gauge.Record(10, opentelemetry::context::Context{});
118117

118+
gauge.Record(10, opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}),
119+
opentelemetry::context::Context{});
119120
gauge.Record(10,
120-
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}),
121-
opentelemetry::context::Context{});
122-
gauge.Record(10,
123-
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}));
121+
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}));
124122
gauge.Record(10, opentelemetry::common::KeyValueIterableView<M>({}),
125-
opentelemetry::context::Context{});
123+
opentelemetry::context::Context{});
126124
gauge.Record(10, opentelemetry::common::KeyValueIterableView<M>({}));
127125
}
128126

129127
TEST(SyncInstruments, DoubleGauge)
130128
{
131-
InstrumentDescriptor instrument_descriptor = {"double_gauge", "description", "1",
132-
InstrumentType::kGauge,
133-
InstrumentValueType::kDouble};
129+
InstrumentDescriptor instrument_descriptor = {
130+
"double_gauge", "description", "1", InstrumentType::kGauge, InstrumentValueType::kDouble};
134131
std::unique_ptr<SyncWritableMetricStorage> metric_storage(new SyncMultiMetricStorage());
135132
DoubleGauge gauge(instrument_descriptor, std::move(metric_storage));
136133
gauge.Record(10.10);
137134
gauge.Record(10.10, opentelemetry::context::Context{});
138135

139136
gauge.Record(10.10,
140-
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}),
141-
opentelemetry::context::Context{});
137+
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}),
138+
opentelemetry::context::Context{});
142139
gauge.Record(10.10,
143-
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}));
140+
opentelemetry::common::KeyValueIterableView<M>({{"abc", "123"}, {"xyz", "456"}}));
144141
gauge.Record(10.10, opentelemetry::common::KeyValueIterableView<M>({}),
145-
opentelemetry::context::Context{});
142+
opentelemetry::context::Context{});
146143
gauge.Record(10.10, opentelemetry::common::KeyValueIterableView<M>({}));
147144
}
148145
#endif

0 commit comments

Comments
 (0)