diff --git a/pkg/ccl/changefeedccl/changefeed_processors.go b/pkg/ccl/changefeedccl/changefeed_processors.go index b5db679f6a27..e5ca2d1df28a 100644 --- a/pkg/ccl/changefeedccl/changefeed_processors.go +++ b/pkg/ccl/changefeedccl/changefeed_processors.go @@ -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" @@ -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 @@ -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 } diff --git a/pkg/cloud/azure/BUILD.bazel b/pkg/cloud/azure/BUILD.bazel index faf25fd76fde..e6e7077d6caf 100644 --- a/pkg/cloud/azure/BUILD.bazel +++ b/pkg/cloud/azure/BUILD.bazel @@ -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", diff --git a/pkg/cloud/azure/azure_storage.go b/pkg/cloud/azure/azure_storage.go index 55cdb340afaf..544af3e1cadd 100644 --- a/pkg/cloud/azure/azure_storage.go +++ b/pkg/cloud/azure/azure_storage.go @@ -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" @@ -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") } diff --git a/pkg/util/metric/BUILD.bazel b/pkg/util/metric/BUILD.bazel index 36e5b0b2ae2f..50ed4a5f0525 100644 --- a/pkg/util/metric/BUILD.bazel +++ b/pkg/util/metric/BUILD.bazel @@ -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", diff --git a/pkg/util/metric/cloud.go b/pkg/util/metric/cloud.go new file mode 100644 index 000000000000..873ec0a23aee --- /dev/null +++ b/pkg/util/metric/cloud.go @@ -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)