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 #1545

Closed

Conversation

xuan-cao-swi
Copy link
Contributor

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.

@xuan-cao-swi xuan-cao-swi changed the title Otlp metrics exporter feat: otlp metrics exporter Nov 23, 2023
@xuan-cao-swi xuan-cao-swi changed the title feat: otlp metrics exporter feat: add experimental otlp metrics exporter Nov 23, 2023
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.

Hi @xuan-cao-swi! Awesome progress on this! Thanks for putting it together. I’m still testing some of the functionality and may have other feedback soon.



In the meantime, I have a structural concern I'd like to discuss with you and the other reviewers.

It seems like the opentelemetry-ruby project prefers to put experimental code into separate gems, like with metrics_api and metrics_sdk. With that in mind, I put the draft OTLP logs exporter in a separate gem.

My suggestion is to move the OTLP metrics exporter to a separate gem to keep experimental code separate from the code folks use in their production environments.

However, this is my current opinion, and the maintainers/approvers may have something else in mind.
I hope this starts a discussion about the right path to take that can also apply to logs.

As you mentioned in the PR description, there's a ton of duplication in the logs OTLP exporter code. Eventually, I believe we will want to do a lot to DRY things up between the three signals, but at the moment, my gut tells me to keep signal exporters separate until they are stable.

@xuan-cao-swi
Copy link
Contributor Author

Hi @kaylareopelle, thanks for the suggestions, I totally agree that experimental code in separate gem, and combine them in the future if needed. I will create another PR.

@xuan-cao-swi
Copy link
Contributor Author

Closed, follow-up pr in #1551

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.

2 participants