Skip to content

Commit

Permalink
cloud/azure: use account name for metrics
Browse files Browse the repository at this point in the history
Release note: none
  • Loading branch information
benbardin committed Oct 25, 2024
1 parent dd0f061 commit 4b3f0f0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/ccl/changefeedccl/changefeed_processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/util/cancelchecker"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/logcrash"
"github.com/cockroachdb/cockroach/pkg/util/metric"
"github.com/cockroachdb/cockroach/pkg/util/mon"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/cockroach/pkg/util/span"
Expand All @@ -49,10 +49,6 @@ import (
"google.golang.org/grpc/status"
)

const EnableCloudBillingAccountingEnvVar = "COCKROACH_ENABLE_CLOUD_BILLING_ACCOUNTING"

var EnableCloudBillingAccounting = envutil.EnvOrDefaultBool(EnableCloudBillingAccountingEnvVar, false)

type changeAggregator struct {
execinfra.ProcessorBase

Expand Down Expand Up @@ -1376,7 +1372,7 @@ func (cf *changeFrontier) runUsageMetricReporting(ctx context.Context) {
}

// If cloud billing accounting is not enabled via an env var, don't do this work.
if !EnableCloudBillingAccounting {
if !metric.EnableCloudBillingAccounting {
return
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/azure/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go_library(
"//pkg/util/envutil",
"//pkg/util/ioctx",
"//pkg/util/log",
"//pkg/util/metric",
"//pkg/util/timeutil",
"//pkg/util/tracing",
"@com_github_azure_azure_sdk_for_go_sdk_azcore//:azcore",
Expand Down
11 changes: 10 additions & 1 deletion pkg/cloud/azure/azure_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/util/ioctx"
"github.com/cockroachdb/cockroach/pkg/util/metric"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
Expand Down Expand Up @@ -221,7 +222,15 @@ func makeAzureStorage(
}

options := args.ExternalStorageOptions()
t, err := cloud.MakeHTTPClient(args.Settings, args.MetricsRecorder, "azure", dest.AzureConfig.Container, options.ClientName)
bucket := dest.AzureConfig.Container
if metric.EnableCloudBillingAccounting {
// Azure is special in that its bucket names are not unique. So for
// the moment, Cloud needs to track Account Name, since it is in fact
// unique. We may eventually choose bucket names derived from the
// account name to ensure uniqueness and bypass this hack.
bucket = dest.AzureConfig.AccountName
}
t, err := cloud.MakeHTTPClient(args.Settings, args.MetricsRecorder, "azure", bucket, options.ClientName)
if err != nil {
return nil, errors.Wrap(err, "azure: unable to create transport")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/util/metric/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "metric",
srcs = [
"cloud.go",
"doc.go",
"graphite_exporter.go",
"hdrhistogram.go",
Expand Down
11 changes: 11 additions & 0 deletions pkg/util/metric/cloud.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2024 The Cockroach Authors.
//
// Use of this software is governed by the CockroachDB Software License
// included in the /LICENSE file.
package metric

import "github.com/cockroachdb/cockroach/pkg/util/envutil"

const EnableCloudBillingAccountingEnvVar = "COCKROACH_ENABLE_CLOUD_BILLING_ACCOUNTING"

var EnableCloudBillingAccounting = envutil.EnvOrDefaultBool(EnableCloudBillingAccountingEnvVar, false)

0 comments on commit 4b3f0f0

Please sign in to comment.