Skip to content

Conversation

tiffanny29631
Copy link
Contributor

@tiffanny29631 tiffanny29631 commented Sep 22, 2025

The migration replaces OpenCensus libraries with OpenTelemetry SDK while preserving:

  • Metric names, type and descriptions
  • Recording patterns
  • Pipeline architecture and data flow
  • Sidecar configurations
  • Export destinations (Prometheus, Cloud Monitoring, Cloud Monarch)

Key Changes

1. Library Dependencies

Before (OpenCensus):

import (
    "go.opencensus.io/stats"
    "go.opencensus.io/stats/view"
    "go.opencensus.io/tag"
    "contrib.go.opencensus.io/exporter/ocagent"
)

After (OpenTelemetry):

import (
    "go.opentelemetry.io/otel"
    "go.opentelemetry.io/otel/metric"
    "go.opentelemetry.io/otel/attribute"
    "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
    "go.opentelemetry.io/otel/sdk/metric"
    "go.opentelemetry.io/otel/sdk/resource"
)

2. Metric Instrument Types

OpenCensus OpenTelemetry Description
stats.Int64 metric.Int64Counter Counter metrics
stats.Int64 metric.Int64Gauge Gauge metrics
stats.Float64 metric.Float64Histogram Histogram metrics

3. Recording Patterns

Before (OpenCensus):

stats.Record(ctx, measurement)

After (OpenTelemetry):

instrument.Record(ctx, value, metric.WithAttributes(attrs...))

4. Tag/Attribute System

Before (OpenCensus):

tagCtx, _ := tag.New(ctx, tag.Upsert(KeyStatus, "success"))

After (OpenTelemetry):

attrs := []attribute.KeyValue{
    attribute.String("status", "success"),
}

5. Exporter Configuration

Before (OpenCensus):

oce, err := ocagent.NewExporter(ocagent.WithInsecure())

After (OpenTelemetry):

exporter, err := otlpmetricgrpc.New(
    context.Background(),
    otlpmetricgrpc.WithInsecure(),
    otlpmetricgrpc.WithEndpoint("otel-collector:4317"),
)

Copy link

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from tiffanny29631. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tiffanny29631 tiffanny29631 force-pushed the oc-migration branch 2 times, most recently from aa7bce5 to 6703484 Compare September 22, 2025 19:03
@tiffanny29631 tiffanny29631 force-pushed the oc-migration branch 2 times, most recently from c080533 to 61c5271 Compare September 22, 2025 22:50
@tiffanny29631
Copy link
Contributor Author

/test all

@tiffanny29631 tiffanny29631 force-pushed the oc-migration branch 3 times, most recently from d32a487 to 7dfe3c9 Compare October 7, 2025 20:32
@tiffanny29631
Copy link
Contributor Author

/test all

Change is meant to be transparent to user.

Using OTel SDK for metric composing in: kmetrics, core metrics, resource
group metrics;

Using otlp receiver in otel-agent and otel-collector;

Configured deployment for new ports and component;

Refactor metric composing and recording;

Metric prefix remain the same to minimize breaking change.

Tests updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant