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

Add ability to choose what instrumentations are enabled #958

Merged
merged 11 commits into from
Jun 25, 2024

Conversation

grcevski
Copy link
Contributor

@grcevski grcevski commented Jun 21, 2024

This PR adds support for choosing what instrumentations should be enabled for traces, metrics, prometheus metrics. The users can define a subset from all available instrumentations for each export category. For example, all instrumentations can be enabled for traces, but only HTTP and SQL for metrics.

TODO:

  • Tests
  • Integration tests
  • Docs

@grcevski grcevski requested review from mariomac and marctc as code owners June 21, 2024 20:13
@grcevski grcevski changed the title Add ability to choose what instrumentations are enabled WIP: Add ability to choose what instrumentations are enabled Jun 21, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2024

Codecov Report

Attention: Patch coverage is 95.41284% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.02%. Comparing base (e95a7d4) to head (d4628af).

Files Patch % Lines
pkg/internal/export/otel/metrics.go 86.02% 10 Missing and 9 partials ⚠️
pkg/internal/export/otel/traces.go 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #958      +/-   ##
==========================================
+ Coverage   75.92%   80.02%   +4.10%     
==========================================
  Files         132      133       +1     
  Lines       10378    10522     +144     
==========================================
+ Hits         7879     8420     +541     
+ Misses       1967     1584     -383     
+ Partials      532      518      -14     
Flag Coverage Δ
integration-test 55.91% <76.60%> (?)
k8s-integration-test 58.78% <84.63%> (+0.43%) ⬆️
oats-test 35.93% <31.88%> (+0.12%) ⬆️
unittests 48.53% <80.73%> (+1.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -176,6 +179,8 @@ type metricsReporter struct {
bgCtx context.Context
ctxInfo *global.ContextInfo

is instrumentations.InstrumentationSelection
Copy link
Contributor

Choose a reason for hiding this comment

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

🤓

Copy link
Contributor

@marctc marctc left a comment

Choose a reason for hiding this comment

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

Woulnd't make sense to use Features instead of new field? Features is enabling or disabling group of metrics anyway, so I wonder if this would led to confusion as we another param to disable more metrics.

Perhaps Instrumentations should be a nested property of Features. Maybe in the future we want also disable some metrics from network observability.

@grcevski
Copy link
Contributor Author

Woulnd't make sense to use Features instead of new field? Features is enabling or disabling group of metrics anyway, so I wonder if this would led to confusion as we another param to disable more metrics.

Perhaps Instrumentations should be a nested property of Features. Maybe in the future we want also disable some metrics from network observability.

I think we need another level, which is consistent between metrics and traces. Features is right now only for metrics and what kind of metrics to expose, application, network, spans metrics...

We need to be able to say, I only care about "http", don't pollute my metrics with sql or grpc, those I only want to see in traces. For example, SQL is managed by a cloud provider and you already export metrics from there.

What kinds of instrumentations are captured is a separate dimension, I think we could make it part of features like this:

application_http, application_sql..., but it gets very long and it's not user friendly IMO.

I think we'd want to extend this concept to network and process metrics. Especially in process metrics, you may want to say I only care about "network", don't care about cpu or memory.

@grcevski grcevski changed the title WIP: Add ability to choose what instrumentations are enabled Add ability to choose what instrumentations are enabled Jun 24, 2024
Copy link
Contributor

@mariomac mariomac left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -297,7 +297,7 @@ func (me *procMetricsExporter) Do(in <-chan []*process.Status) {
}

func (me *procMetricsExporter) observeMetric(reporter *procMetrics, s *process.Status) {
me.log.Debug("reporting data for record", "record", s)
// me.log.Debug("reporting data for record", "record", s)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you forget to uncomment it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, these few that I commented out create a lot of log lines under debug, it was hard to see what's going on. I can put them back, but if process metrics are enabled it's really hard to follow the logs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I will remove it in another PR.

@@ -939,6 +957,24 @@ the OpenTelemetry exporter will automatically add the `/v1/traces` path to the U
addition, you can use either the `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` environment variable or the `environment` YAML
property to use exactly the provided URL without any addition.

| YAML | Environment variable | Type | Default |
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this wrongly duplicated or it's a different section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are different sections. We can specify which instrumentations should be enabled in each of the OTel metrics, Prometheus metrics, Traces. The variable names are different, following the similar naming conventions as the other variables.

@grcevski grcevski merged commit 657f710 into grafana:main Jun 25, 2024
8 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