2020import com .google .api .core .InternalApi ;
2121import com .google .api .gax .tracing .SpanName ;
2222import io .opencensus .stats .Stats ;
23+ import io .opencensus .stats .View ;
24+ import io .opencensus .tags .TagKey ;
2325import java .util .ArrayList ;
26+ import java .util .HashMap ;
2427import java .util .List ;
2528import java .util .Map ;
2629import java .util .stream .Collectors ;
3134 */
3235@ InternalApi ("For internal use only" )
3336public class StatsWrapper {
34-
3537 public static StatsRecorderWrapper createRecorder (
3638 OperationType operationType , SpanName spanName , Map <String , String > statsAttributes ) {
3739 return new StatsRecorderWrapper (
@@ -49,4 +51,19 @@ public static List<String> getOperationLatencyViewTagValueStrings() {
4951 .map (x -> x .asString ())
5052 .collect (Collectors .toCollection (ArrayList ::new ));
5153 }
54+
55+ // A workaround to run ITBuiltinViewConstantsTest as integration test. Integration test runs after
56+ // the packaging step. Opencensus classes will be relocated when they are packaged but the
57+ // integration test files will not be. So the integration tests can't reference any transitive
58+ // dependencies that have been relocated.
59+ static Map <String , List <String >> getViewToTagMap () {
60+ Map <String , List <String >> map = new HashMap <>();
61+ for (View view : BuiltinViews .BIGTABLE_BUILTIN_VIEWS ) {
62+ List <TagKey > tagKeys = view .getColumns ();
63+ map .put (
64+ view .getName ().asString (),
65+ tagKeys .stream ().map (tagKey -> tagKey .getName ()).collect (Collectors .toList ()));
66+ }
67+ return map ;
68+ }
5269}
0 commit comments