• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016-17, OpenCensus Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.opencensus.stats;
18 
19 import java.util.Set;
20 import javax.annotation.Nullable;
21 
22 /**
23  * Provides facilities to register {@link View}s for collecting stats and retrieving stats data as a
24  * {@link ViewData}.
25  *
26  * @since 0.8
27  */
28 public abstract class ViewManager {
29   /**
30    * Pull model for stats. Registers a {@link View} that will collect data to be accessed via {@link
31    * #getView(View.Name)}.
32    *
33    * @param view the {@code View} to be registered.
34    * @since 0.8
35    */
registerView(View view)36   public abstract void registerView(View view);
37 
38   /**
39    * Returns the current stats data, {@link ViewData}, associated with the given view name.
40    *
41    * <p>Returns {@code null} if the {@code View} is not registered.
42    *
43    * @param view the name of {@code View} for the current stats.
44    * @return {@code ViewData} for the {@code View}, or {@code null} if the {@code View} is not
45    *     registered.
46    * @since 0.8
47    */
48   @Nullable
getView(View.Name view)49   public abstract ViewData getView(View.Name view);
50 
51   /**
52    * Returns all registered views that should be exported.
53    *
54    * <p>This method should be used by any stats exporter that automatically exports data for views
55    * registered with the {@link ViewManager}.
56    *
57    * @return all registered views that should be exported.
58    * @since 0.9
59    */
getAllExportedViews()60   public abstract Set<View> getAllExportedViews();
61 }
62