/*
         * Create a Session from client
         */

        public static Session StartSession(Spanner.SpannerClient client)
        {
            CreateSessionRequest createSessionRequest = new CreateSessionRequest();

            createSessionRequest.Database = _DATABASE;
            return(client.CreateSession(createSessionRequest));
        }
        public void CreateSessionWithReusedChannel()
        {
            for (int i = 0; i < DefaultMaxChannelsPerTarget * 2; i++)
            {
                Session session;
                session = client.CreateSession(
                    new CreateSessionRequest {
                    Database = DatabaseUrl
                });

                Assert.IsNotNull(session);
                Assert.AreEqual(1, invoker.GetChannelRefsForTest().Count);

                client.DeleteSession(new DeleteSessionRequest {
                    Name = session.Name
                });
            }
        }
        /*
         * Probes to test session related grpc call from Spanner stub.
         *
         * Includes tests against CreateSession, GetSession, ListSessions, and
         * DeleteSession of Spanner stub.
         *
         * Args:
         *  stub: An object of SpannerStub.
         *  metrics: A list of metrics.
         *
         */

        public static void sessionManagement(Spanner.SpannerClient client, ref Dictionary <string, long> metrics)
        {
            long latency;
            CreateSessionRequest createSessionRequest = new CreateSessionRequest();

            createSessionRequest.Database = _DATABASE;
            //Create Session test
            //Create
            stopwatch.Start();
            Session session = client.CreateSession(createSessionRequest);

            stopwatch.Stop();
            latency = stopwatch.ElapsedMilliseconds;
            metrics.Add("create_session_latency_ms", latency);

            //Get Session
            GetSessionRequest getSessionRequest = new GetSessionRequest();

            getSessionRequest.Name = session.Name;
            stopwatch.Start();
            client.GetSession(getSessionRequest);
            stopwatch.Stop();
            latency = stopwatch.ElapsedMilliseconds;
            metrics.Add("get_session_latency_ms", latency);

            //List Session
            ListSessionsRequest listSessionsRequest = new ListSessionsRequest();

            listSessionsRequest.Database = _DATABASE;
            stopwatch.Start();
            client.ListSessions(listSessionsRequest);
            stopwatch.Stop();
            latency = stopwatch.ElapsedMilliseconds;
            metrics.Add("list_sessions_latency_ms", latency);

            //Delete Session
            DeleteSessionRequest deleteSessionRequest = new DeleteSessionRequest();

            deleteSessionRequest.Name = session.Name;
            stopwatch.Start();
            client.DeleteSession(deleteSessionRequest);
            stopwatch.Stop();
            latency = stopwatch.ElapsedMilliseconds;
            metrics.Add("delete_session_latency_ms", latency);
        }