Skip to content
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

feat: add experimental otlp metrics exporter #1551

Merged
merged 26 commits into from
Mar 7, 2024

Conversation

xuan-cao-swi
Copy link
Contributor

Follow-up PR for #1545 (move experimental feature into separate gem)

Description

Added otlp metrics exporter that works with otlp collector through http protocol.

Most code copied from (trace) exporter (with test as well) with the assumption of same ssl, http etc. configuration. The major change is the proto decode. If the log exporter also use the similar configuration, having a utility file can help DRY.

Quick demo

require 'opentelemetry/sdk'
require 'opentelemetry-metrics-sdk' # need to install this from building the metrics_sdk and metrics_api folder
require 'opentelemetry/exporter/otlp'

OpenTelemetry::SDK.configure

otlp_metric_exporter = OpenTelemetry::Exporter::OTLP::MetricsExporter.new

OpenTelemetry.meter_provider.add_metric_reader(otlp_metric_exporter)

meter = OpenTelemetry.meter_provider.meter("SAMPLE_METER_NAME")

histogram = meter.create_histogram('histogram', unit: 'smidgen', description: 'desscription')

histogram.record(123, attributes: {'foo' => 'bar'})

OpenTelemetry.meter_provider.metric_readers.each(&:pull)
OpenTelemetry.meter_provider.shutdown

Testing failed but it will success once the #1532 is merged.

@kaylareopelle
Copy link
Contributor

The jaeger CI failure is now fixed on main.

Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

This is awesome, Xuan! The exporter worked great with a local OTLP collector.

Initially, I had some issues with New Relic's OTLP endpoint. Adding the aggregation_temporality attribute to the protobuf payload resolved the problem. I have a few suggestions below that add aggregation_temporality to the exporter. They're accompanied by #1554. That PR adds aggregation_temporality to MetricData so that it can be accessed using metrics.aggregation_temporality.

exporter/otlp-metrics/CHANGELOG.md Outdated Show resolved Hide resolved
exporter/otlp-metrics/Appraisals Outdated Show resolved Hide resolved
exporter/otlp-metrics/README.md Outdated Show resolved Hide resolved
exporter/otlp-metrics/README.md Outdated Show resolved Hide resolved
exporter/otlp-metrics/test/test_helper.rb Outdated Show resolved Hide resolved
exporter/otlp-metrics/test/test_helper.rb Show resolved Hide resolved
xuan-cao-swi and others added 12 commits December 19, 2023 11:55
Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
…exporter.rb

Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
…_exporter_test.rb

Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
…_exporter_test.rb

Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
…exporter.rb

Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com>
@xuan-cao-swi
Copy link
Contributor Author

@kaylareopelle Thanks for the review, I have added the change based on aggregation_temporality, also added the gem test to ci.yml.

Comment on lines 32 to 33
spec.add_dependency 'opentelemetry-metrics-api'
spec.add_dependency 'opentelemetry-metrics-sdk'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably should remove these dependencies?

Since there is no metrics-related gem in rubygems, user who install this and use it will fail.

User who want to use it should create the metrics gem by themselves, and require metrics gem first, and then this metrics exporter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the dependencies and included instruction in README that install these two dependencies.

Copy link
Member

@mwear mwear left a comment

Choose a reason for hiding this comment

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

If there are no objections, I'll merge this at EOD. Thanks @xuan-cao-swi.

@mwear mwear merged commit 94832be into open-telemetry:main Mar 7, 2024
58 checks passed
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.

4 participants