Documentation ¶
Overview ¶
Package ocaero supplies a wrapper for the aerospile go client to report metrics with OpenCensus
Example ¶
This example shows how to use ocaero.Wrapper and register views with OpenCensus
var ( aeroClient *aerospike.Client // TODO actually make the client connection ocAeroWrapper = ocaero.Wrap(aeroClient, "my-aero") ) ocaero.RegisterAllViews() data, err := getData(context.Background(), ocAeroWrapper) if err != nil { log.Printf("Unable to query: %s", err.Error()) return } log.Println("Got data:", data) data = data + " updated" err = setData(context.Background(), ocAeroWrapper) if err != nil { log.Printf("Unable to update data: %s", err.Error()) return } log.Println("Updated data")
Output:
Example (CustomTags) ¶
This example shows how to add custom tags to existing ocaero views
var ( aeroClient *aerospike.Client // TODO actually make the client connection ocAeroWrapper = ocaero.Wrap(aeroClient, "my-aero") ) // appVersionTag is a tag represening the current version of the application appVersionTag, _ := tag.NewKey("app_version") // add the tag to the views ocaero.GoAerospikeLatencyView.TagKeys = append( ocaero.GoAerospikeLatencyView.TagKeys, appVersionTag, ) ocaero.GoAerospikeCallsView.TagKeys = append( ocaero.GoAerospikeCallsView.TagKeys, appVersionTag, ) // adding the tag to the application context will make the tag/value // available to any view its been added to ctx, _ := tag.New(context.Background(), tag.Insert( appVersionTag, "v1.0.0", )) ocaero.RegisterAllViews() data, err := getData(ctx, ocAeroWrapper) if err != nil { log.Printf("Unable to query: %s", err.Error()) return } log.Println("Got data:", data) data = data + " updated" err = setData(context.Background(), ocAeroWrapper) if err != nil { log.Printf("Unable to update data: %s", err.Error()) return } log.Println("Updated data")
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
// GoAeroInstanceName is the name of the aerospike instance.
GoAeroInstanceName, _ = tag.NewKey("go_aerospike_instance_name")
// GoAeroMethod is the client method called.
GoAeroMethod = tag.MustNewKey("go_aerospike_method")
// GoAeroStatus identifies the command status
GoAeroStatus = tag.MustNewKey("go_aerospike_status")
DefaultTags = []tag.Key{
GoAeroMethod,
GoAeroStatus,
}
)
The following tags are applied to stats recorded by this package
var ( GoAerospikeLatencyView = &view.View{ Name: "go.aerospike/client/latency", Description: "The distribution of latency of various calls in milliseconds", Measure: MeasureLatencyMs, Aggregation: DefaultMillisecondsDistribution, TagKeys: DefaultTags, } GoAerospikeCallsView = &view.View{ Name: "go.aerospike/client/calls", Description: "The number of various calls of methods", Measure: MeasureLatencyMs, Aggregation: view.Count(), TagKeys: DefaultTags, } DefaultViews = []*view.View{GoAerospikeLatencyView, GoAerospikeCallsView} )
Package ocaero provides some convenience views. You still need to register these views for data to actually be collected. You can use the RegisterAllViews function for this.
var (
DefaultMillisecondsDistribution = view.Distribution(
0.0,
0.001,
0.005,
0.01,
0.05,
0.1,
0.5,
1.0,
1.5,
2.0,
2.5,
5.0,
10.0,
25.0,
50.0,
100.0,
200.0,
400.0,
600.0,
800.0,
1000.0,
1500.0,
2000.0,
2500.0,
5000.0,
10000.0,
20000.0,
40000.0,
100000.0,
200000.0,
500000.0,
)
)
Default distributions used by views in this package
var (
MeasureLatencyMs = stats.Int64("go.aerospike/latency", "The latency of calls in milliseconds", stats.UnitMilliseconds)
)
The following measures are supported for use in custom views.
Functions ¶
func RegisterAllViews ¶
func RegisterAllViews() error
RegisterAllViews registers all the views to enable collection of stats
Types ¶
type PutBinser ¶
type PutBinser interface {
PutBins(ctx context.Context, policy *as.WritePolicy, key *as.Key, bins ...*as.Bin) error
}
PutBinser allows a caller to set bins in Aerospike
type Querier ¶
type Querier interface {
Query(ctx context.Context, policy *as.QueryPolicy, stmt *as.Statement) (*as.Recordset, error)
}
Querier allows a caller to perform an Aerospike query
type Wrapper ¶
Wrapper reports method call latency with OpenCensus
Contexts ¶
Contexts are supplied Wrapper methods but aren't supported by the underlying Aerospike client. Instead they are supplied to the OpenCensus metrics.