From df7b1517eaeca959302ff3547b84a77aba26ae84 Mon Sep 17 00:00:00 2001 From: brawndou <112038567+brawndou@users.noreply.github.com> Date: Thu, 25 Jan 2024 11:35:49 -0800 Subject: [PATCH] Backport #221 and #222 to master branch (#243) * [bug] Ensure that parent scopes do not return closed subscopes (#221) * TestScope: don't prune from registry when closed (#222) * TestScope: don't prune from registry when closed (#222) * lint fix * move comment * update go.mod and go.sum * add license header --------- Co-authored-by: Matt Way --- generate.go | 23 +++++++++++++++++++++-- scope.go | 4 +++- scope_registry_external_test.go | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/generate.go b/generate.go index 43d2efd5..30192d7c 100644 --- a/generate.go +++ b/generate.go @@ -1,7 +1,26 @@ +// Copyright (c) 2024 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + package tally import ( + //go:generate mockgen -package tallymock -destination tallymock/stats_reporter.go -imports github.com/uber-go/tally github.com/uber-go/tally StatsReporter _ "github.com/golang/mock/mockgen/model" ) - -//go:generate mockgen -package tallymock -destination tallymock/stats_reporter.go -imports github.com/uber-go/tally github.com/uber-go/tally StatsReporter diff --git a/scope.go b/scope.go index d61b05ff..733cd4ea 100644 --- a/scope.go +++ b/scope.go @@ -104,9 +104,11 @@ type ScopeOptions struct { Separator string DefaultBuckets Buckets SanitizeOptions *SanitizeOptions - registryShardCount uint OmitCardinalityMetrics bool CardinalityMetricsTags map[string]string + + testScope bool + registryShardCount uint } // NewRootScope creates a new root Scope with a set of options and diff --git a/scope_registry_external_test.go b/scope_registry_external_test.go index ea945bd5..97943737 100644 --- a/scope_registry_external_test.go +++ b/scope_registry_external_test.go @@ -113,7 +113,8 @@ func TestNoDefunctSubscopes(t *testing.T) { MinTimes(1) root, _ := tally.NewRootScope(tally.ScopeOptions{ - Reporter: mockreporter, + Reporter: mockreporter, + OmitCardinalityMetrics: true, }, time.Millisecond) subscope := root.Tagged(tags)