srunner

package module
v0.0.0-...-8b1a3a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 15 Imported by: 0

README

srunner

Spanner Runner

test

gcloud emulators spanner start --host-port localhost:9050
export SPANNER_EMULATOR_HOST="localhost:9050" 

go test ./...

k8s

gcloud config set PROJECT_ID
kubectl apply -f k8s/metalapps-namespace.yaml
kubectl create serviceaccount metalapps-default \
    --namespace metalapps
gcloud iam service-accounts add-iam-policy-binding metalapps@GSA_PROJECT.iam.gserviceaccount.com \
    --role roles/iam.workloadIdentityUser \
    --member "serviceAccount:PROJECT_ID.svc.id.goog[metalapps/metalapps-default]"
kubectl annotate serviceaccount metalapps-default \
    --namespace metalapps \
    iam.gke.io/gcp-service-account=metalapps@GSA_PROJECT.iam.gserviceaccount.com
kubectl apply -f k8s/srunner-configmap.yaml

Documentation

Index

Constants

View Source
const (
	MetricsKindOK      = "OK"
	MetricsKindNG      = "NG"
	MetricsKindTimeout = "TIMEOUT"
)
View Source
const (
	// OCReportInterval is the interval for OpenCensus to send stats data to
	// Stackdriver Monitoring via its exporter.
	// NOTE: this value should not be no less than 1 minute. Detailes are in the doc.
	// https://cloud.google.com/monitoring/custom-metrics/creating-metrics#writing-ts
	OCReportInterval = 60 * time.Second

	// Measure namess for respecitive OpenCensus Measure
	LogSize       = "logsize"
	RedisStatus   = "redis-status"
	SpannerStatus = "spanner-status"

	// Units are used to define Measures of OpenCensus.
	ByteSizeUnit = "byte"
	CountUnit    = "count"

	// ResouceNamespace is used for the exporter to have resource labels.
	ResourceNamespace = "sinmetal"
)

Variables

View Source
var (
	// KeySource is the key for label in "generic_node",
	KeySource, _ = tag.NewKey("source")

	KeyKind, _ = tag.NewKey("kind")

	// Measure variables
	MLogSize            = stats.Int64(LogSize, "logSize", ByteSizeUnit)
	MRedisStatusCount   = stats.Int64(RedisStatus, "redis status", CountUnit)
	MSpannerStatusCount = stats.Int64(SpannerStatus, "spanner status", CountUnit)

	RedisStatusCountView = &view.View{
		Name:        RedisStatus,
		Description: "redis status count",
		TagKeys:     []tag.Key{KeySource},
		Measure:     MRedisStatusCount,
		Aggregation: view.Count(),
	}

	SpannerStatusCountView = &view.View{
		Name:        SpannerStatus,
		Description: "spanner status count",
		TagKeys:     []tag.Key{KeySource, KeyKind},
		Measure:     MSpannerStatusCount,
		Aggregation: view.Count(),
	}

	LogSizeView = &view.View{
		Name:        LogSize,
		Measure:     MLogSize,
		TagKeys:     []tag.Key{KeySource},
		Description: "log size",
		Aggregation: view.Sum(),
	}

	LogSizeViews = []*view.View{
		LogSizeView,
	}

	StatusViews = []*view.View{
		RedisStatusCountView,
		SpannerStatusCountView,
	}
)

Functions

func CountSpannerStatus

func CountSpannerStatus(ctx context.Context, id string, kind string) error

func ExtractServerTimingValue

func ExtractServerTimingValue(md metadata.MD) (int64, bool)

func GFEMetricsStreamClientInterceptor

func GFEMetricsStreamClientInterceptor() grpc.StreamClientInterceptor

GFEMetricsStreamClientInterceptor is server-timing をログ出力する https://medium.com/google-cloud/use-gfe-server-timing-header-in-cloud-spanner-debugging-d7d891a50642

func GFEMetricsUnaryClientInterceptor

func GFEMetricsUnaryClientInterceptor() grpc.UnaryClientInterceptor

GFEMetricsUnaryClientInterceptor is server-timing をログ出力する https://medium.com/google-cloud/use-gfe-server-timing-header-in-cloud-spanner-debugging-d7d891a50642

func GetMetricType

func GetMetricType(v *view.View) string

func InitExporter

func InitExporter(project string, location string, namespace string, node string, labels *stackdriver.Labels) *stackdriver.Exporter

func InitOpenCensusStats

func InitOpenCensusStats(exporter *stackdriver.Exporter) error

Types

type AppRunnner

type AppRunnner struct {
	// contains filtered or unexported fields
}

func NewAppRunner

func NewAppRunner(ctx context.Context, ratePerSec int, parallelism int) *AppRunnner

func (*AppRunnner) Run

func (ar *AppRunnner) Run(ctx context.Context, funcName string, runnner Runnner)

Run is 並行実行を行う

type GenericNodeMonitoredResource

type GenericNodeMonitoredResource struct {
	Location    string
	NamespaceId string
	NodeId      string
}

func NewGenericNodeMonitoredResource

func NewGenericNodeMonitoredResource(location, namespace, node string) *GenericNodeMonitoredResource

func (*GenericNodeMonitoredResource) MonitoredResource

func (mr *GenericNodeMonitoredResource) MonitoredResource() (string, map[string]string)

type Runnner

type Runnner interface {
	Run(ctx context.Context) error
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL