Skip to content

Commit

Permalink
Rename data member
Browse files Browse the repository at this point in the history
Rename a data member to make it explicit that it's atomic i.e.
concurrent-safe.
  • Loading branch information
kislaykishore committed Feb 13, 2025
1 parent 0030fed commit 570a168
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions common/otel_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ type otelMetrics struct {
fsOpsErrorCount metric.Int64Counter
fsOpsLatency metric.Float64Histogram

gcsReadCount metric.Int64Counter
gcsReadBytesCountInt *atomic.Int64
gcsReaderCount metric.Int64Counter
gcsRequestCount metric.Int64Counter
gcsRequestLatency metric.Float64Histogram
gcsDownloadBytesCount metric.Int64Counter
gcsReadCount metric.Int64Counter
gcsReadBytesCountAtomic *atomic.Int64
gcsReaderCount metric.Int64Counter
gcsRequestCount metric.Int64Counter
gcsRequestLatency metric.Float64Histogram
gcsDownloadBytesCount metric.Int64Counter

fileCacheReadCount metric.Int64Counter
fileCacheReadBytesCount metric.Int64Counter
fileCacheReadLatency metric.Float64Histogram
}

func (o *otelMetrics) GCSReadBytesCount(_ context.Context, inc int64) {
o.gcsReadBytesCountInt.Add(inc)
o.gcsReadBytesCountAtomic.Add(inc)
}

func (o *otelMetrics) GCSReaderCount(ctx context.Context, inc int64, attrs []MetricAttr) {
Expand Down Expand Up @@ -107,12 +107,12 @@ func NewOTelMetrics() (MetricHandle, error) {
metric.WithDescription("The cumulative number of bytes downloaded from GCS along with type - Sequential/Random"),
metric.WithUnit("By"))

var gcsReadBytesCountInt atomic.Int64
var gcsReadBytesCountAtomic atomic.Int64
_, err6 := gcsMeter.Int64ObservableCounter("gcs/read_bytes_count",
metric.WithDescription("The cumulative number of bytes read from GCS objects."),
metric.WithUnit("By"),
metric.WithInt64Callback(func(_ context.Context, obsrv metric.Int64Observer) error {
obsrv.Observe(gcsReadBytesCountInt.Load())
obsrv.Observe(gcsReadBytesCountAtomic.Load())
return nil
}))
gcsReaderCount, err7 := gcsMeter.Int64Counter("gcs/reader_count", metric.WithDescription("The cumulative number of GCS object readers opened or closed."))
Expand All @@ -138,7 +138,7 @@ func NewOTelMetrics() (MetricHandle, error) {
fsOpsErrorCount: fsOpsErrorCount,
fsOpsLatency: fsOpsLatency,
gcsReadCount: gcsReadCount,
gcsReadBytesCountInt: &gcsReadBytesCountInt,
gcsReadBytesCountAtomic: &gcsReadBytesCountAtomic,
gcsReaderCount: gcsReaderCount,
gcsRequestCount: gcsRequestCount,
gcsRequestLatency: gcsRequestLatency,
Expand Down

0 comments on commit 570a168

Please sign in to comment.