-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
762 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
load("//bazel:otel_cc_benchmark.bzl", "otel_cc_benchmark") | ||
|
||
cc_test( | ||
name = "noop_sync_instrument_test", | ||
srcs = [ | ||
"noop_sync_instrument_test.cc", | ||
], | ||
tags = [ | ||
"metrics", | ||
"test", | ||
], | ||
deps = [ | ||
"//api", | ||
"@com_google_googletest//:gtest_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "meter_provider_test", | ||
srcs = [ | ||
"meter_provider_test.cc", | ||
], | ||
tags = [ | ||
"metrics", | ||
"test", | ||
], | ||
deps = [ | ||
"//api", | ||
"@com_google_googletest//:gtest_main", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
sdk/include/opentelemetry/sdk/metrics/exemplar/always_sample_filter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/sdk/metrics/exemplar/filter.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
|
||
class AlwaysSampleFilter final : public ExemplarFilter | ||
{ | ||
public: | ||
static nostd::shared_ptr<ExemplarFilter> GetAlwaysSampleFilter() | ||
{ | ||
static nostd::shared_ptr<ExemplarFilter> alwaysSampleFilter{new AlwaysSampleFilter{}}; | ||
return alwaysSampleFilter; | ||
} | ||
|
||
bool ShouldSampleMeasurement(long value, | ||
const MetricAttributes &attributes, | ||
const opentelemetry::context::Context &context) noexcept override | ||
{ | ||
return true; | ||
} | ||
|
||
bool ShouldSampleMeasurement(double value, | ||
const MetricAttributes &attributes, | ||
const opentelemetry::context::Context &context) noexcept override | ||
{ | ||
return true; | ||
} | ||
|
||
private: | ||
explicit AlwaysSampleFilter() = default; | ||
}; | ||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
#ifndef ENABLE_METRICS_PREVIEW | ||
# include "opentelemetry/common/timestamp.h" | ||
# include "opentelemetry/context/context.h" | ||
# include "opentelemetry/sdk/common/attribute_utils.h" | ||
|
||
OPENTELEMETRY_BEGIN_NAMESPACE | ||
namespace sdk | ||
{ | ||
namespace metrics | ||
{ | ||
using MetricAttributes = opentelemetry::sdk::common::OrderedAttributeMap; | ||
/** | ||
* A sample input measurement. | ||
* | ||
* Exemplars also hold information about the environment when the measurement was recorded, for | ||
* example the span and trace ID of the active span when the exemplar was recorded. | ||
*/ | ||
class ExemplarData | ||
{ | ||
public: | ||
/** | ||
* The set of key/value pairs that were filtered out by the aggregator, but recorded alongside the | ||
* original measurement. Only key/value pairs that were filtered out by the aggregator should be | ||
* included | ||
*/ | ||
MetricAttributes GetFilteredAttributes(); | ||
|
||
/** Returns the timestamp in nanos when measurement was collected. */ | ||
opentelemetry::common::SystemTimestamp GetEpochNanos(); | ||
|
||
/** | ||
* Returns the SpanContext associated with this exemplar. If the exemplar was not recorded | ||
* inside a sampled trace, the Context will be invalid. | ||
*/ | ||
opentelemetry::context::Context GetSpanContext(); | ||
}; | ||
|
||
} // namespace metrics | ||
} // namespace sdk | ||
OPENTELEMETRY_END_NAMESPACE | ||
#endif |
Oops, something went wrong.