This repository was archived by the owner on Sep 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import time
1615import random
16+ import time
17+
18+ import google .auth
19+
1720from opencensus .stats import aggregation as aggregation_module
18- from opencensus .stats .exporters import stackdriver_exporter as stackdriver
1921from opencensus .stats import measure as measure_module
2022from opencensus .stats import stats as stats_module
2123from opencensus .stats import view as view_module
24+ from opencensus .stats .exporters import stackdriver_exporter as stackdriver
2225from opencensus .tags import tag_key as tag_key_module
2326from opencensus .tags import tag_map as tag_map_module
2427from opencensus .tags import tag_value as tag_value_module
3841view_manager = stats .view_manager
3942stats_recorder = stats .stats_recorder
4043
44+ try :
45+ _ , project_id = google .auth .default ()
46+ except google .auth .exceptions .DefaultCredentialsError :
47+ raise ValueError ("Couldn't find Google Cloud credentials, set the "
48+ "project ID with 'gcloud set project'" )
49+
4150exporter = stackdriver .new_stats_exporter (
42- stackdriver .Options (project_id = "opencenus-node" ))
51+ stackdriver .Options (project_id = project_id ))
4352view_manager .register_exporter (exporter )
4453
4554# Register view.
You can’t perform that action at this time.
0 commit comments