-
Notifications
You must be signed in to change notification settings - Fork 684
feat(exporter): Adopt opentelemetry #1210
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
base: master
Are you sure you want to change the base?
feat(exporter): Adopt opentelemetry #1210
Conversation
- Migrate pkg/util/metrics/helpers.go from OpenCensus tags to OTel attributes - Migrate pkg/util/metrics/metric_int64.go to use OTel metric SDK - Migrate pkg/util/metrics/metric_float64.go to use OTel metric SDK - Add pkg/util/metrics/provider.go for global MeterProvider management - Update prometheusexporter to use OTel Prometheus exporter - Update stackdriver exporter to use GCP OTel metric exporter - Remove OpenCensus dependencies from go.mod - Add OpenTelemetry SDK and exporter dependencies Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MartinForReal The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…usMetrics The OpenTelemetry Prometheus exporter exports additional metric types like SUMMARY (e.g., go_gc_duration_seconds) that were not handled by the parser. Instead of returning an error for unsupported types, we now skip them since NPD only cares about its own COUNTER and GAUGE metrics. Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
The issue was that metrics were being created during package init() before the meter provider was set up with the Prometheus exporter. Changes: 1. Modified provider.go to use lazy initialization and allow SetupMeterProvider() to be called explicitly after all readers are added 2. Changed problemmetrics to use lazy initialization via an interface, deferring metric creation until first use 3. Reordered main initialization: exporters are now set up first, then SetupMeterProvider() is called, then problem daemons are initialized This ensures that when metrics are created, the meter provider already has all the configured readers/exporters attached. Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
…s, WithoutScopeInfo OpenTelemetry's Prometheus exporter adds suffixes by default: - "_ratio" suffix for gauges with unit "1" - "_total" suffix for counters - "otel_scope_*" labels to all metrics These changes broke backward compatibility with existing metric names. Adding these options preserves the original metric names: - problem_gauge (not problem_gauge_ratio) - problem_counter (not problem_counter_total) Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
…cated options Replace deprecated prometheus.WithoutUnits() and prometheus.WithoutCounterSuffixes() with prometheus.WithTranslationStrategy(otlptranslator.UnderscoreEscapingWithoutSuffixes) as recommended by the linter. The UnderscoreEscapingWithoutSuffixes strategy: - Translates metric/label name characters to underscores (standard Prometheus behavior) - Does NOT append suffixes like "_total" for counters or "_ratio" for gauges This maintains the same behavior while using the non-deprecated API. Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
Run go mod tidy to properly declare github.com/prometheus/otlptranslator as a direct dependency since we now use it directly in prometheus_exporter.go with WithTranslationStrategy(). Co-authored-by: MartinForReal <5207478+MartinForReal@users.noreply.github.com>
|
/assign @yujuhong |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Replaces OpenCensus with OpenTelemetry for metrics instrumentation. OpenCensus has been deprecated and merged into OpenTelemetry, which is now the CNCF standard for observability.
Which issue(s) this PR fixes:
fixes: #1008
Fixes the need to migrate from deprecated OpenCensus to OpenTelemetry.
Special notes for your reviewer:
Changes
Metrics Package (
pkg/util/metrics/)go.opencensus.io/tag→go.opentelemetry.io/otel/attributego.opencensus.io/stats→go.opentelemetry.io/otel/metricSDKprovider.gofor global MeterProvider managementExporters
go.opentelemetry.io/otel/exporters/prometheusinstead of OpenCensus contrib exportergithub.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metricinstead of OpenCensus contrib exporterDependencies
go.opencensus.io,contrib.go.opencensus.io/*go.opentelemetry.io/otel/sdk/metric,go.opentelemetry.io/otel/exporters/prometheusAPI Unchanged
The wrapper API remains identical:
Internally,
LastValueaggregation maps to OTel gauges,Summaps to OTel counters.Does this PR introduce a user-facing change?