-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metrics exemplar round 1 #1264
Merged
Merged
metrics exemplar round 1 #1264
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fa52139
metrics examplar
esigo f8b4b2c
CI branch
esigo d715cf6
Merge branch 'main' into metrics-examplar
esigo 60fedc8
Merge branch 'main' into metrics-examplar
esigo d41d5bd
format
esigo 4dbf6e1
fix CI
esigo c515b57
fix CI
esigo c8d6f40
Merge branch 'main' into metrics-examplar
esigo bda900d
comments
esigo e3349c8
sync_instrument bazel
esigo 1e5a47d
comments
esigo 76db5a7
Merge branch 'main' into metrics-examplar
esigo 5ba7f15
fix CI
esigo 2d1bd93
Merge branch 'metrics-examplar' of https://github.com/esigo/opentelem…
esigo f607830
Merge branch 'main' into metrics-examplar
lalitb 8f6d0a3
Merge branch 'main' into metrics-examplar
esigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make
context
optional, and use default runtime context if not provided.or just
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, added these four: