-
Notifications
You must be signed in to change notification settings - Fork 501
[SDK] Base2 exponential histogram aggregation #3346
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
Merged
lalitb
merged 63 commits into
open-telemetry:main
from
ethandmd:expo-histo-aggregation-4
Apr 25, 2025
Merged
Changes from 32 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
b62565f
add base2 expo histo aggregation
euroelessar 338cce4
add base2 expo histo, test, benchmark
ethandmd b03d915
add prom, otlp exporter and example
felipesantosk 423e92d
add ostream exporter and example
ethandmd a9737bf
update vscode launch
felipesantosk b2dee01
run tools/format.sh
ethandmd 0f54022
Merge branch 'main' into expo-histo-aggregation-4
ethandmd 250de89
add grpc exporter target switch for unix sockets
ethandmd 4376128
Added ConvertExponentialHistogramMetric unit test
felipesantosk 4408d33
Update the osstream_metric_test with ExponentialHistogram
felipesantosk 21e1d34
update CHANGELOG.md
ethandmd 4397886
markdown lint
ethandmd 9b9d8c1
Comment non-used function add missing includes
felipesantosk db95400
Merge branch 'main' into expo-histo-aggregation-4
ThomsonTan 775688a
add metrics dependency to otlp exporters test build
ethandmd b2d7a02
run format
ethandmd bc96a2f
Merge branch 'main' into expo-histo-aggregation-4
ethandmd 712e538
remove unused function definition
ethandmd 531ac16
Added empty line in the end of a test file and removed comments
felipesantosk 43c0e00
Merge branch 'main' into expo-histo-aggregation-4
lalitb 9146925
Fix windows build errors
felipesantosk ea3190d
fix iwyu warnings
ethandmd 0fc7071
add comment to trigger pr update
ethandmd 8f2130c
fix additional iwyu warnings
ethandmd de04603
Fix iwyu warning
felipesantosk 8cf15c4
Fix include order in base2_exponential_histogram_aggregation.h
felipesantosk f98d198
Merge branch 'main' into expo-histo-aggregation-4
ThomsonTan 66c5a6b
Merge branch 'main' into expo-histo-aggregation-4
ethandmd 84c09d1
Add kcumulative and kdelta aggregation temporality test with collect …
ethandmd b9e5df6
add prelim bucketing checks
ethandmd e4daa7b
Tested the exp2 constructor with point data
felipesantosk c7ca650
Fix missing include in sync histogram test
felipesantosk 81ea997
move diff and merge to use union of all buckets approach
ethandmd 055d331
make get a const method
ethandmd e5e7b20
update base2 expo hiso diff test
ethandmd 556eb89
add base2 expo histo test with sync storage collect
ethandmd dc5d956
Merge branch 'expo-histo-aggregation-4' of http://github.com/ethandmd…
ethandmd e69e73c
uncomment examples
ethandmd ca542f7
format
ethandmd 9040c38
use static_cast
ethandmd a7a1234
fix comments
ethandmd 53e025e
update changelog
ethandmd 293e2dd
Fix comments and errors in the pipeline
felipesantosk 9adcfac
Merge branch 'main' into expo-histo-aggregation-4
lalitb f917c08
Merge branch 'main' into expo-histo-aggregation-4
ethandmd f184cec
Update sdk/src/metrics/aggregation/base2_exponential_histogram_aggreg…
ethandmd 50ca1c0
remove unused code
ethandmd ab5441e
set max_buckets minimum to 2
ethandmd 42a904e
Revert otlp grpc client changes
ethandmd 5641bbd
[wip] make buckets unique ptr
ethandmd e550710
Merge branch 'main' into expo-histo-aggregation-4
ThomsonTan 20ba935
refactor unique_ptr for buckets with deep copies
ethandmd ea50726
merge
ethandmd 6468765
format
ethandmd 2bfd9da
update otlp serialization test with unique ptr
ethandmd 262425e
Merge branch 'main' into expo-histo-aggregation-4
lalitb 71855a9
format
ethandmd b1f54d4
Small pipeline fixes
felipesantosk 1d96b3e
iwyu fix
ethandmd 17c94ca
remove boundary and format
ethandmd d4cbcbc
Merge branch 'main' into expo-histo-aggregation-4
ethandmd ffbd2fd
Merge branch 'main' into expo-histo-aggregation-4
felipesantosk beb9227
Merge branch 'main' into expo-histo-aggregation-4
lalitb 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 hidden or 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 |
|---|---|---|
| @@ -1,24 +1,33 @@ | ||
| { | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": "Debug on Windows", | ||
| "type": "cppvsdbg", | ||
| "request": "launch", | ||
| "program": "${workspaceFolder}/build/<path-to-bin-file>", | ||
| "args": [], | ||
| "stopAtEntry": false, | ||
| "cwd": "${workspaceFolder}", | ||
| "environment": [], | ||
| "externalConsole": false | ||
| }, | ||
| { | ||
| "name": "Debug on Linux", | ||
| "type": "gdb", | ||
| "request": "launch", | ||
| "target": "${workspaceFolder}/bazel-bin/<path to the bin file>", | ||
| "cwd": "${workspaceRoot}", | ||
| "valuesFormatting": "parseText" | ||
| } | ||
| { | ||
| "name": "(ctest) Launch", | ||
| "type": "cppdbg", | ||
| "cwd": "${cmake.testWorkingDirectory}", | ||
| "request": "launch", | ||
| "program": "${cmake.testProgram}", | ||
| "args": [ "${cmake.testArgs}" ], | ||
| // other options... | ||
| }, | ||
| { | ||
| "name": "Debug on Windows", | ||
| "type": "cppvsdbg", | ||
| "request": "launch", | ||
| "program": "${workspaceFolder}/build/<path-to-bin-file>", | ||
| "args": [], | ||
| "stopAtEntry": false, | ||
| "cwd": "${workspaceFolder}", | ||
| "environment": [], | ||
| "externalConsole": false | ||
| }, | ||
| { | ||
| "name": "Debug on Linux", | ||
| "type": "gdb", | ||
| "request": "launch", | ||
| "target": "${workspaceFolder}/bazel-bin/<path to the bin file>", | ||
| "cwd": "${workspaceRoot}", | ||
| "valuesFormatting": "parseText" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "grpcpp/grpcpp.h" | ||
| #include "opentelemetry/exporters/otlp/otlp_grpc_exporter.h" | ||
|
|
||
| #include "opentelemetry/exporters/otlp/otlp_grpc_metric_exporter_factory.h" | ||
| #include "opentelemetry/metrics/provider.h" | ||
| #include "opentelemetry/sdk/metrics/aggregation/default_aggregation.h" | ||
|
|
@@ -11,6 +14,9 @@ | |
| #include "opentelemetry/sdk/metrics/meter_provider.h" | ||
| #include "opentelemetry/sdk/metrics/meter_provider_factory.h" | ||
| #include "opentelemetry/sdk/metrics/provider.h" | ||
| #include "opentelemetry/sdk/metrics/view/instrument_selector_factory.h" | ||
| #include "opentelemetry/sdk/metrics/view/meter_selector_factory.h" | ||
| #include "opentelemetry/sdk/metrics/view/view_factory.h" | ||
|
|
||
| #include <memory> | ||
| #include <thread> | ||
|
|
@@ -31,7 +37,7 @@ namespace | |
|
|
||
| otlp_exporter::OtlpGrpcMetricExporterOptions exporter_options; | ||
|
|
||
| void InitMetrics() | ||
| void InitMetrics(std::string &name) | ||
| { | ||
| auto exporter = otlp_exporter::OtlpGrpcMetricExporterFactory::Create(exporter_options); | ||
|
|
||
|
|
@@ -49,10 +55,39 @@ void InitMetrics() | |
| auto context = metric_sdk::MeterContextFactory::Create(); | ||
| context->AddMetricReader(std::move(reader)); | ||
|
|
||
| auto u_provider = metric_sdk::MeterProviderFactory::Create(std::move(context)); | ||
| std::shared_ptr<opentelemetry::metrics::MeterProvider> provider(std::move(u_provider)); | ||
| auto provider = metric_sdk::MeterProviderFactory::Create(std::move(context)); | ||
|
|
||
| // histogram view | ||
| std::string histogram_name = name + "_histogram"; | ||
| std::string unit = "unit"; | ||
|
|
||
| auto histogram_instrument_selector = metric_sdk::InstrumentSelectorFactory::Create( | ||
| metric_sdk::InstrumentType::kHistogram, histogram_name, unit); | ||
|
|
||
| auto histogram_meter_selector = metric_sdk::MeterSelectorFactory::Create(name, version, schema); | ||
|
|
||
| auto histogram_aggregation_config = | ||
| std::unique_ptr<metric_sdk::Base2ExponentialHistogramAggregationConfig>( | ||
| new metric_sdk::Base2ExponentialHistogramAggregationConfig); | ||
|
|
||
| histogram_aggregation_config->max_scale_ = 3; | ||
|
|
||
| // histogram_aggregation_config->boundaries_ = std::vector<double>{ | ||
|
||
| // 0.0, 50.0, 100.0, 250.0, 500.0, 750.0, 1000.0, 2500.0, 5000.0, 10000.0, 20000.0}; | ||
|
|
||
| std::shared_ptr<metric_sdk::AggregationConfig> aggregation_config( | ||
| std::move(histogram_aggregation_config)); | ||
|
|
||
| metric_sdk::Provider::SetMeterProvider(provider); | ||
| auto histogram_view = metric_sdk::ViewFactory::Create( | ||
| name, "description", unit, metric_sdk::AggregationType::kBase2ExponentialHistogram, | ||
| aggregation_config); | ||
|
|
||
| provider->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), | ||
| std::move(histogram_view)); | ||
|
|
||
| std::shared_ptr<opentelemetry::metrics::MeterProvider> api_provider(std::move(provider)); | ||
|
|
||
| metric_sdk::Provider::SetMeterProvider(api_provider); | ||
| } | ||
|
|
||
| void CleanupMetrics() | ||
|
|
@@ -78,10 +113,17 @@ int main(int argc, char *argv[]) | |
| } | ||
| } | ||
| } | ||
| std::cout << "Using endpoint: " << exporter_options.endpoint << std::endl; | ||
| std::cout << "Using example type: " << example_type << std::endl; | ||
| std::cout << "Using cacert path: " << exporter_options.ssl_credentials_cacert_path << std::endl; | ||
| std::cout << "Using ssl credentials: " << exporter_options.use_ssl_credentials << std::endl; | ||
|
|
||
| // Removing this line will leave the default noop MetricProvider in place. | ||
| InitMetrics(); | ||
|
|
||
| std::string name{"otlp_grpc_metric_example"}; | ||
|
|
||
| InitMetrics(name); | ||
|
|
||
| if (example_type == "counter") | ||
| { | ||
| foo_library::counter_example(name); | ||
|
|
@@ -94,6 +136,10 @@ int main(int argc, char *argv[]) | |
| { | ||
| foo_library::histogram_example(name); | ||
| } | ||
| else if (example_type == "exponential_histogram") | ||
| { | ||
| foo_library::histogram_exp_example(name); | ||
| } | ||
| #if OPENTELEMETRY_ABI_VERSION_NO >= 2 | ||
| else if (example_type == "gauge") | ||
| { | ||
|
|
@@ -102,15 +148,15 @@ int main(int argc, char *argv[]) | |
| #endif | ||
| else | ||
| { | ||
| std::thread counter_example{&foo_library::counter_example, name}; | ||
| std::thread observable_counter_example{&foo_library::observable_counter_example, name}; | ||
| // std::thread counter_example{&foo_library::counter_example, name}; | ||
ethandmd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // std::thread observable_counter_example{&foo_library::observable_counter_example, name}; | ||
| std::thread histogram_example{&foo_library::histogram_example, name}; | ||
| #if OPENTELEMETRY_ABI_VERSION_NO >= 2 | ||
| std::thread gauge_example{&foo_library::gauge_example, name}; | ||
| #endif | ||
|
|
||
| counter_example.join(); | ||
| observable_counter_example.join(); | ||
| // counter_example.join(); | ||
ethandmd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // observable_counter_example.join(); | ||
| histogram_example.join(); | ||
| #if OPENTELEMETRY_ABI_VERSION_NO >= 2 | ||
| gauge_example.join(); | ||
|
|
||
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.