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

Instrument obsreport.receiver metrics with otel go #6222

Merged
merged 21 commits into from
Oct 12, 2022

Conversation

paivagustavo
Copy link
Member

@paivagustavo paivagustavo commented Oct 3, 2022

Description: Instruments existing obsreport.Receiver metrics with otel-go, side-by-side with the existing opencensus metrics.

This uses the same UseOtelForInternalMetricsfeatureGateID feature gate, adding a UseOtelForMetrics() method on the obsreportconfig that should be used by components of the collector core to check what sdk should be used for instrumentation.

Link to tracking Issue: part of #816

Testing: Manual tests comparing the current exported metrics and the metrics from the otel-go sdk after enabling the feature gate --feature-gates=telemetry.useOtelForInternalMetrics

@codecov
Copy link

codecov bot commented Oct 3, 2022

Codecov Report

Base: 92.48% // Head: 92.04% // Decreases project coverage by -0.44% ⚠️

Coverage data is based on head (a5320de) compared to base (aa78209).
Patch coverage: 49.61% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6222      +/-   ##
==========================================
- Coverage   92.48%   92.04%   -0.45%     
==========================================
  Files         218      218              
  Lines       13124    13218      +94     
==========================================
+ Hits        12138    12166      +28     
- Misses        769      832      +63     
- Partials      217      220       +3     
Impacted Files Coverage Δ
obsreport/obsreport.go 100.00% <ø> (ø)
obsreport/obsreport_receiver.go 63.58% <37.00%> (-36.42%) ⬇️
internal/obsreportconfig/obsreportconfig.go 96.90% <90.00%> (-3.10%) ⬇️
service/telemetry.go 89.02% <100.00%> (-0.58%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

We need this #5939, which is to not break the metrics names at this time. We will at one point later revisit all names.

internal/obsreportconfig/obsmetrics/obs_receiver.go Outdated Show resolved Hide resolved
internal/obsreportconfig/obsmetrics/obs_receiver.go Outdated Show resolved Hide resolved
obsreport/obsreport_receiver.go Outdated Show resolved Hide resolved
obsreport/views.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

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

Just one thought, otherwise looks great!

obsreport/obsreport_receiver.go Show resolved Hide resolved
@paivagustavo
Copy link
Member Author

paivagustavo commented Oct 3, 2022

We need this #5939, which is to not break the metrics names at this time. We will at one point later revisit all names.

@bogdandrutu this pr actually fixes the name inconsistencies by wrapping the prometheus.Registry, this might be easier than trying add otelcol_ prefix to all metrics (including contrib metrics):

prometheus.WrapRegistererWithPrefix("otelcol_", prometheus.WrapRegistererWith(promLabels, registry))

If we still wants to move on with #5939, I can create a copy of obsmetrics.ReceiverPrefix, so this won't make otelcol_otelcol_ metrics and fix this after that get merged.

internal/obsreportconfig/obsmetrics/obsmetrics.go Outdated Show resolved Hide resolved
obsreport/obsreport.go Outdated Show resolved Hide resolved
obsreport/obsreport_receiver.go Show resolved Hide resolved
service/telemetry.go Outdated Show resolved Hide resolved
@paivagustavo paivagustavo force-pushed the gustavo/otel-go-metrics branch from 3bf3ebd to 32f6ad5 Compare October 4, 2022 16:16
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

This looks sane to me, a review from @Aneurysm9 would be helpful though.

component/telemetry.go Outdated Show resolved Hide resolved
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Current PR exposes new temporary public APIs because the OC bridge is not ready and we cannot really start the proper migration to otel.

I am not OK doing that.

@paivagustavo
Copy link
Member Author

@bogdandrutu are you concerned about having this public TelemetrySettings.UseOtelForMetrics? Would it be better if we get rid of that and just started to record values to both sdks at the same time? Something like this:

rec.recordWithOtel(receiverCtx, dataType, numAccepted, numRefused)
rec.recordWithOC(receiverCtx, dataType, numAccepted, numRefused)

I'm trying to understand what other paths we might have other than just waiting for the bridge to get ready.

@bogdandrutu
Copy link
Member

@paivagustavo to give you alternatives, I need to understand the goal :)

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Just a couple of questions

internal/obsreportconfig/obsreportconfig.go Outdated Show resolved Hide resolved
obsreport/obsreport_receiver.go Outdated Show resolved Hide resolved
obsreport/obsreport_receiver.go Show resolved Hide resolved
service/telemetry.go Outdated Show resolved Hide resolved
internal/obsreportconfig/obsreportconfig.go Outdated Show resolved Hide resolved
obsreport/obsreport_receiver.go Show resolved Hide resolved
obsreport/obsreport_receiver.go Outdated Show resolved Hide resolved
@paivagustavo
Copy link
Member Author

Thanks for the reviews @bogdandrutu @codeboten @Aneurysm9, I think I've addressed all the comments at this point and it should be ready to be reviewed again.

Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments 👍🏻

Comment on lines +112 to +115
handleError := func(metricName string, err error) {
if err != nil {
rec.logger.Warn("failed to create otel instrument", zap.Error(err), zap.String("metric", metricName))
}
Copy link
Member

Choose a reason for hiding this comment

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

We need to return the error to the caller instead of logging. It should not be done in this PR, but we need to file an issue for this.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Just for my sanity, please create a separate PR for the version updates, maybe also include the 1.11 updates as well.

@bogdandrutu bogdandrutu merged commit a9f41a2 into open-telemetry:main Oct 12, 2022
bogdandrutu added a commit that referenced this pull request Oct 13, 2022
* upgrade otel go to latest version v1.11.0/v0.32.3/v0.36.3 (#6293)

* [chore] move service pipeline id validation to main config Validate (#6281)

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

* Instrument obsreport.receiver metrics with otel go (#6222)

* Instrument obs_receiver with otel go

* add changelog entry

* remove views configuration

* move otel-go metrics to obsreport

* add UseOtelForMetrics to TelemetrySettings; extract otel sdk initialization changes to another pr; remove public InstrumentWithOtel from obsreport;

* default UseOtelForMetrics to false

* remove duplicate oc registry initialization

* move `UseOtelForMetrics` to the internal package `obsreportconfig`

* address comments

* only register view if featuregate is disabled

* prefix meter name with `receiver/`

* change meter scope name

* upgrade otel metric sdk

* run make gotidy

* update changelog

* revert: otel go version upgrade

* revert: x/sys upgrades

* [chore] add chloggen for changelog (#6062)

This change updates the changelog process in this repo to match the process in the contrib repo.

* Fix support for new line in config URI location

Signed-off-by: Bogdan <bogdandrutu@gmail.com>

Signed-off-by: Bogdan <bogdandrutu@gmail.com>
Co-authored-by: Gustavo Paiva <gustavo@lightstep.com>
Co-authored-by: Alex Boten <aboten@lightstep.com>
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.

7 participants