File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
main/java/com/uber/m3/tally
test/java/com/uber/m3/tally Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 2323import com .uber .m3 .util .ImmutableMap ;
2424
2525import javax .annotation .Nullable ;
26+ import java .util .ArrayList ;
2627import java .util .Collection ;
2728import java .util .Map ;
2829import java .util .Optional ;
@@ -172,7 +173,11 @@ String fullyQualifiedName(String name) {
172173 public Snapshot snapshot () {
173174 Snapshot snap = new SnapshotImpl ();
174175
175- for (ScopeImpl subscope : registry .subscopes .values ()) {
176+ ArrayList <ScopeImpl > scopes = new ArrayList <>();
177+ scopes .add (this );
178+ scopes .addAll (registry .subscopes .values ());
179+
180+ for (ScopeImpl subscope : scopes ) {
176181 ImmutableMap <String , String > tags = new ImmutableMap .Builder <String , String >()
177182 .putAll (this .tags )
178183 .putAll (subscope .tags )
Original file line number Diff line number Diff line change @@ -47,19 +47,27 @@ public void testCreate() {
4747
4848 testScope .tagged (tags ).counter ("counter" ).inc (1 );
4949
50+ testScope .counter ("untagged_counter" ).inc (1 );
51+
5052 Snapshot snapshot = testScope .snapshot ();
5153 assertNotNull (snapshot );
5254
5355 Map <ScopeKey , CounterSnapshot > counters = snapshot .counters ();
5456 assertNotNull (counters );
55- assertEquals (1 , counters .size ());
57+ assertEquals (2 , counters .size ());
5658
5759 CounterSnapshot counterSnapshot = counters .get (new ScopeKey ("counter" , tags ));
5860 assertNotNull (counterSnapshot );
5961
6062 assertEquals ("counter" , counterSnapshot .name ());
6163 assertEquals (tags , counterSnapshot .tags ());
6264 assertEquals (1 , counterSnapshot .value ());
65+
66+ counterSnapshot = counters .get (new ScopeKey ("untagged_counter" , ImmutableMap .EMPTY ));
67+ assertNotNull (counterSnapshot );
68+ assertEquals ("untagged_counter" , counterSnapshot .name ());
69+ assertEquals (ImmutableMap .EMPTY , counterSnapshot .tags ());
70+ assertEquals (1 , counterSnapshot .value ());
6371 }
6472
6573 @ Test
You can’t perform that action at this time.
0 commit comments