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

[OTel C++] Add APIs to enable/disable metrics #36183

Closed
wants to merge 3 commits into from

Conversation

yashykt
Copy link
Member

@yashykt yashykt commented Mar 27, 2024

No description provided.

@yashykt yashykt added the release notes: yes Indicates if PR needs to be in release notes label Mar 27, 2024
@yashykt yashykt changed the title [OTel C++] Add ability to enable/disable metrics [OTel C++] Add APIs to enable/disable metrics Mar 27, 2024
OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::EnableMetric(
absl::string_view metric_name) {
metrics_.emplace(metric_name);
OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::EnableMetrics(
Copy link
Member

Choose a reason for hiding this comment

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

Not directly related to this PR, but what's stopping us from eliminating OpenTelemetryPluginBuilderImpl at this point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, OpenTelemetryPluginBuilderImpl has the following additional methods -

  1. SetTargetSelector - This will go away after my next PR to add channel scope filter.
  2. SetServerSelector - This is unused at the moment and can be removed.
  3. TestOnlyEnabledMetrics - Used for testing to see which metrics are enabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

so, yeah, really it can be removed

Copy link
Member

Choose a reason for hiding this comment

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

Okay, please remove it as a follow-up PR.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't there some benefits with the Pimpl idiom used here? e.g. if we change the implementation details of the OpenTelemetryPluginBuilderImpl, the users of the OpenTelemetryPluginBuilder API do not need to recompile their code (as long as the API does not change).

https://en.cppreference.com/w/cpp/language/pimpl

Copy link
Member

Choose a reason for hiding this comment

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

We don't promise ABI compatibility between versions, so that's not something our users can count on anyway.

test/cpp/ext/otel/otel_plugin_test.cc Outdated Show resolved Hide resolved
Copy link
Member

@yijiem yijiem left a comment

Choose a reason for hiding this comment

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

Thanks Yash!

// Methods to manipulate which instruments are enabled in the OpenTelemetry
// Stats Plugin.
OpenTelemetryPluginBuilder& EnableMetrics(
const std::vector<absl::string_view>& metric_names);
Copy link
Member

Choose a reason for hiding this comment

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

absl::Span<> might be another choice? It would allow the API to take more types of input (e.g. C-style array, initializer list) without constructing a vector.

OpenTelemetryPluginBuilder& EnableMetrics(
      absl::Span<const absl::string_view> metric_names);

Copy link
Member Author

Choose a reason for hiding this comment

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

Suggestion taken, thanks!

OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::EnableMetric(
absl::string_view metric_name) {
metrics_.emplace(metric_name);
OpenTelemetryPluginBuilderImpl& OpenTelemetryPluginBuilderImpl::EnableMetrics(
Copy link
Member

Choose a reason for hiding this comment

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

Okay, please remove it as a follow-up PR.

@ctiller ctiller closed this in 1312ff0 Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants