observability

package
v0.21.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package observability provides tools for working with open census.

Index

Constants

View Source
const (
	MetricRoot = "en-verification-server"
)

Variables

View Source
var (
	BuildIDTagKey  = tag.MustNewKey("build_id")
	BuildTagTagKey = tag.MustNewKey("build_tag")

	KnativeServiceTagKey       = tag.MustNewKey("k_service")
	KnativeRevisionTagKey      = tag.MustNewKey("k_revision")
	KnativeConfigurationTagKey = tag.MustNewKey("k_configuration")

	RealmTagKey = tag.MustNewKey("realm")

	// ResultTagKey contains a free format text describing the result of the
	// request. Preferably ALL CAPS WITH UNDERSCORE.
	// OK indicating a successful request.
	// You can losely base this string on
	// https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
	// but feel free to use any text as long as it's easy to filter.
	ResultTagKey = tag.MustNewKey("result")
)
View Source
var (
	// BlameNone indicate no API failure
	BlameNone = tag.Upsert(blameTagKey, "NONE")

	// BlameClient indicate the client is at fault (e.g. invalid request)
	BlameClient = tag.Upsert(blameTagKey, "CLIENT")

	// BlameServer indicate the server is at fault
	BlameServer = tag.Upsert(blameTagKey, "SERVER")

	// BlameExternal indicate some third party is at fault
	BlameExternal = tag.Upsert(blameTagKey, "EXTERNAL")

	// BlameUnknown can be used for everything else
	BlameUnknown = tag.Upsert(blameTagKey, "UNKNOWN")
)

Functions

func APITagKeys added in v0.12.0

func APITagKeys() []tag.Key

APITagKeys return a slice of tag.Key with common tag keys + additional API specific tag keys.

func CommonTagKeys added in v0.11.0

func CommonTagKeys() []tag.Key

CommonTagKeys returns the slice of common tag keys that should used in all views.

func RecordLatency added in v0.16.0

func RecordLatency(ctx context.Context, start time.Time, m *stats.Float64Measure, mutators ...*tag.Mutator)

RecordLatency calculate and record the latency. Usage example:

func foo() {
	 defer RecordLatency(&ctx, time.Now(), metric, tag1, tag2)
  // remaining of the function body.
}

func ResultError added in v0.13.0

func ResultError(result string) tag.Mutator

ResultError add a tag with the given string as the result.

func ResultNotOK added in v0.14.0

func ResultNotOK() tag.Mutator

ResultNotOK add a tag indicating the API call is a failure.

func ResultOK added in v0.13.0

func ResultOK() tag.Mutator

ResultOK add a tag indicating the API call is a success.

func WithBuildInfo added in v0.11.0

func WithBuildInfo(octx context.Context) context.Context

WithBuildInfo creates a new context with the build and revision info attached to the observability context.

func WithRealmID added in v0.11.0

func WithRealmID(octx context.Context, realmID uint64) context.Context

WithRealmID creates a new context with the realm id attached to the observability context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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