1// Copyright 2017 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package spanner 16 17import ( 18 "context" 19 20 "go.opencensus.io/stats" 21 "go.opencensus.io/stats/view" 22) 23 24const statsPrefix = "cloud.google.com/go/spanner/" 25 26func recordStat(ctx context.Context, m *stats.Int64Measure, n int64) { 27 stats.Record(ctx, m.M(n)) 28} 29 30var ( 31 // OpenSessionCount is a measure of the number of sessions currently opened. 32 // It is EXPERIMENTAL and subject to change or removal without notice. 33 OpenSessionCount = stats.Int64(statsPrefix+"open_session_count", "Number of sessions currently opened", 34 stats.UnitDimensionless) 35 36 // OpenSessionCountView is a view of the last value of OpenSessionCount. 37 // It is EXPERIMENTAL and subject to change or removal without notice. 38 OpenSessionCountView = &view.View{ 39 Name: OpenSessionCount.Name(), 40 Description: OpenSessionCount.Description(), 41 Measure: OpenSessionCount, 42 Aggregation: view.LastValue(), 43 } 44) 45