Skip to content

chore(metrics): add benchmark for metrics#2106

Open
xuan-cao-swi wants to merge 3 commits intoopen-telemetry:mainfrom
xuan-cao-swi:metrics_sdk_benchmark
Open

chore(metrics): add benchmark for metrics#2106
xuan-cao-swi wants to merge 3 commits intoopen-telemetry:mainfrom
xuan-cao-swi:metrics_sdk_benchmark

Conversation

@xuan-cao-swi
Copy link
Copy Markdown
Contributor

Description

Inspired by api/benchmarks, and use native benchmark-ips instead of benchmark-ipsa

@xuan-cao-swi xuan-cao-swi changed the title chore(metrics_sdk): add benchmark for metrics chore(metrics): add benchmark for metrics Apr 22, 2026
spec.add_dependency 'opentelemetry-api', '~> 1.0'

spec.add_development_dependency 'benchmark-ipsa', '~> 0.2.0'
spec.add_development_dependency 'benchmark-ips', '~> 2.14.0'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not be added to the gemfile instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with either put here or in gemfile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would it move to the Gemfile?

Comment thread metrics_api/benchmarks/README.md
Comment thread metrics_api/benchmarks/bench_helper.rb Outdated
Ex = OpenTelemetry::SDK::Metrics::Exemplar
Export = OpenTelemetry::SDK::Metrics::Export

ATTRS_MEDIUM = { 'http.method' => 'GET', 'http.status_code' => 200, 'http.route' => '/api/users' }.freeze
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used in attributes_bench.rb (where ATTRS_NONE, ATTRS_SMALL, and ATTRS_LARGE are defined). Should this move there, too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to helper

Comment on lines +9 to +17
def counter_with(exemplar_filter:, exemplar_reservoir: nil)
meter = build_sdk_meter(exemplar_filter: exemplar_filter)
meter.create_counter('bench.exemplar.counter', exemplar_reservoir: exemplar_reservoir)
end

def histogram_with(exemplar_filter:, exemplar_reservoir: nil)
meter = build_sdk_meter(exemplar_filter: exemplar_filter)
meter.create_histogram('bench.exemplar.histogram', exemplar_reservoir: exemplar_reservoir)
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like counter_with and histogram_with are identical here in exemplar_filter_bench.rb and in exemplar_reservoir_bench.rb. Could these move to the bench_helper?

(I also notice that histogram_with isn't used in this benchmark.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment thread metrics_api/benchmarks/README.md Outdated
Comment thread metrics_api/benchmarks/exemplar_reservoir_bench.rb
Copy link
Copy Markdown
Member

@robbkidd robbkidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants