<commit_before>// Copyright 2018 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

// +build go1.8

// Sample opencensus_spanner_quickstart contains a sample application that
// uses Google Spanner Go client, and reports metrics
// and traces for the outgoing requests.
package main

import (
	"log"

	"cloud.google.com/go/spanner"
	ss "go.opencensus.io/exporter/stats/stackdriver"
	ts "go.opencensus.io/exporter/trace/stackdriver"
	"go.opencensus.io/stats"
	"go.opencensus.io/trace"
	"golang.org/x/net/context"
)

func main() {
	ctx := context.Background()

	// Enable OpenCensus exporters to export traces and metrics
	// to Stackdriver Monitoring and Tracing.
	// Exporters use Application Default Credentials to authenticate.
	// See https://developers.google.com/identity/protocols/application-default-credentials
	// for more details.
	statsExporter, err := ss.NewExporter(ss.Options{ProjectID: "your-project-id"})
	if err != nil {
		log.Fatal(err)
	}
	traceExporter, err := ts.NewExporter(ts.Options{ProjectID: "your-project-id"})
	if err != nil {
		log.Fatal(err)
	}
	stats.RegisterExporter(statsExporter)
	trace.RegisterExporter(traceExporter)

	// This database must exist.
	databaseName := "projects/your-project-id/instances/your-instance-id/databases/your-database-id"

	client, err := spanner.NewClient(ctx, databaseName)
	if err != nil {
		log.Fatalf("Failed to create client %v", err)
	}
	defer client.Close()

	_, err = client.Apply(ctx, []*spanner.Mutation{
		spanner.Insert("Users",
			[]string{"name", "email"},
			[]interface{}{"alice", "<EMAIL>"})})
	if err != nil {
		log.Printf("Failed to insert: %v", err)
	}

	// Make sure data is uploaded before program finishes.
	statsExporter.Flush()
	traceExporter.Flush()
}<commit_msg>opencensus: update to composite stackdriver exporters (#377)<commit_after>// Copyright 2018 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.

// +build go1.8

// Sample opencensus_spanner_quickstart contains a sample application that
// uses Google Spanner Go client, and reports metrics
// and traces for the outgoing requests.
package main

import (
	"log"

	"cloud.google.com/go/spanner"
	"go.opencensus.io/exporter/stackdriver"
	"go.opencensus.io/stats"
	"go.opencensus.io/trace"
	"golang.org/x/net/context"
)

func main() {
	ctx := context.Background()

	// Enable OpenCensus exporters to export traces and metrics
	// to Stackdriver Monitoring and Tracing.
	// Exporters use Application Default Credentials to authenticate.
	// See https://developers.google.com/identity/protocols/application-default-credentials
	// for more details.
	exporter, err := stackdriver.NewExporter(stackdriver.Options{
		ProjectID: "your-project-id",
	})
	if err != nil {
		log.Fatal(err)
	}
	stats.RegisterExporter(exporter)
	trace.RegisterExporter(exporter)

	// This database must exist.
	databaseName := "projects/your-project-id/instances/your-instance-id/databases/your-database-id"

	client, err := spanner.NewClient(ctx, databaseName)
	if err != nil {
		log.Fatalf("Failed to create client %v", err)
	}
	defer client.Close()

	_, err = client.Apply(ctx, []*spanner.Mutation{
		spanner.Insert("Users",
			[]string{"name", "email"},
			[]interface{}{"alice", "<EMAIL>"})})
	if err != nil {
		log.Printf("Failed to insert: %v", err)
	}

	// Make sure data is uploaded before program finishes.
	exporter.Flush()
}
{'fraction_non_alphanumeric': 0.13157894736842105, 'fraction_numerical': 0.005376344086021506, 'mean_word_length': 4.130624092888244, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3513940', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1138, 'n_words': 309}