_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q22100 | NewApi | train | func NewApi(runningInKubernetes bool, metricSink *metricsink.MetricSink, historicalSource core.HistoricalSource, disableMetricExport bool) *Api {
gkeMetrics := make(map[string]core.MetricDescriptor)
gkeLabels := make(map[string]core.LabelDescriptor)
for _, val := range core.StandardMetrics {
gkeMetrics[val.Name] =... | go | {
"resource": ""
} |
q22101 | Register | train | func (a *Api) Register(container *restful.Container) {
ws := new(restful.WebService)
ws.Path("/api/v1/metric-export").
Doc("Exports the latest point for all Heapster metrics").
Produces(restful.MIME_JSON)
ws.Route(ws.GET("").
To(a.exportMetrics).
Doc("export the latest data point for all metrics").
Operati... | go | {
"resource": ""
} |
q22102 | NewHawkularSink | train | func NewHawkularSink(u *url.URL) (core.DataSink, error) {
sink := &hawkularSink{
uri: u,
batchSize: 1000,
}
if err := sink.init(); err != nil {
return nil, err
}
metrics := make([]core.MetricDescriptor, 0, len(core.AllMetrics))
for _, metric := range core.AllMetrics {
metrics = append(metrics, metr... | go | {
"resource": ""
} |
q22103 | SaveData | train | func (esSvc *ElasticSearchService) SaveData(date time.Time, typeName string, sinkData []interface{}) error {
if typeName == "" || len(sinkData) == 0 {
return nil
}
indexName := esSvc.Index(date)
// Use the IndexExists service to check if a specified index exists.
exists, err := esSvc.EsClient.IndexExists(index... | go | {
"resource": ""
} |
q22104 | newSink | train | func newSink(c influxdb_common.InfluxdbConfig) core.DataSink {
client, err := influxdb_common.NewClient(c)
if err != nil {
glog.Errorf("issues while creating an InfluxDB sink: %v, will retry on use", err)
}
return &influxdbSink{
client: client, // can be nil
c: c,
conChan: make(chan struct{}, c.Concu... | go | {
"resource": ""
} |
q22105 | ParseRBAC | train | func (self *realKubeFramework) ParseRBAC(filePath string) (*rbacv1.ClusterRoleBinding, error) {
obj, err := self.loadRBACObject(filePath)
if err != nil {
return nil, err
}
rbac, ok := obj.(*rbacv1.ClusterRoleBinding)
if !ok {
return nil, fmt.Errorf("Failed to cast clusterrolebinding: %v", obj)
}
return rbac... | go | {
"resource": ""
} |
q22106 | CreateRBAC | train | func (self *realKubeFramework) CreateRBAC(rbac *rbacv1.ClusterRoleBinding) error {
_, err := self.kubeClient.RbacV1().ClusterRoleBindings().Create(rbac)
return err
} | go | {
"resource": ""
} |
q22107 | ParseServiceAccount | train | func (self *realKubeFramework) ParseServiceAccount(filePath string) (*v1.ServiceAccount, error) {
obj, err := self.loadObject(filePath)
if err != nil {
return nil, err
}
sa, ok := obj.(*v1.ServiceAccount)
if !ok {
return nil, fmt.Errorf("Failed to cast serviceaccount: %v", obj)
}
return sa, nil
} | go | {
"resource": ""
} |
q22108 | CreateServiceAccount | train | func (self *realKubeFramework) CreateServiceAccount(sa *v1.ServiceAccount) error {
_, err := self.kubeClient.CoreV1().ServiceAccounts(sa.Namespace).Create(sa)
return err
} | go | {
"resource": ""
} |
q22109 | SendBatch | train | func (c *HoneycombClient) SendBatch(batch Batch) error {
if len(batch) == 0 {
// Nothing to send
return nil
}
errs := []string{}
for i := 0; i < len(batch); i += maxBatchSize {
offset := i + maxBatchSize
if offset > len(batch) {
offset = len(batch)
}
if err := c.sendBatch(batch[i:offset]); err != ni... | go | {
"resource": ""
} |
q22110 | checkSanitizedMetricName | train | func (sink *influxdbSink) checkSanitizedMetricName(name string) error {
if !metricAllowedChars.MatchString(name) {
return fmt.Errorf("Invalid metric name %q", name)
}
return nil
} | go | {
"resource": ""
} |
q22111 | checkSanitizedMetricLabels | train | func (sink *influxdbSink) checkSanitizedMetricLabels(labels map[string]string) error {
// label names have the same restrictions as metric names, here
for k, v := range labels {
if !metricAllowedChars.MatchString(k) {
return fmt.Errorf("Invalid label name %q", k)
}
// for metric values, we're somewhat more ... | go | {
"resource": ""
} |
q22112 | aggregationFunc | train | func (sink *influxdbSink) aggregationFunc(aggregationName core.AggregationType, fieldName string) string {
switch aggregationName {
case core.AggregationTypeAverage:
return fmt.Sprintf("MEAN(%q)", fieldName)
case core.AggregationTypeMaximum:
return fmt.Sprintf("MAX(%q)", fieldName)
case core.AggregationTypeMini... | go | {
"resource": ""
} |
q22113 | keyToSelector | train | func (sink *influxdbSink) keyToSelector(key core.HistoricalKey) string {
typeSel := fmt.Sprintf("type = '%s'", key.ObjectType)
switch key.ObjectType {
case core.MetricSetTypeNode:
return fmt.Sprintf("%s AND %s = '%s'", typeSel, core.LabelNodename.Key, key.NodeName)
case core.MetricSetTypeSystemContainer:
return... | go | {
"resource": ""
} |
q22114 | labelsToPredicate | train | func (sink *influxdbSink) labelsToPredicate(labels map[string]string) string {
if len(labels) == 0 {
return ""
}
parts := make([]string, 0, len(labels))
for k, v := range labels {
parts = append(parts, fmt.Sprintf("%q = '%s'", k, v))
}
return strings.Join(parts, " AND ")
} | go | {
"resource": ""
} |
q22115 | composeRawQuery | train | func (sink *influxdbSink) composeRawQuery(metricName string, labels map[string]string, metricKeys []core.HistoricalKey, start, end time.Time) string {
seriesName, fieldName := sink.metricToSeriesAndField(metricName)
queries := make([]string, len(metricKeys))
for i, key := range metricKeys {
pred := sink.keyToSele... | go | {
"resource": ""
} |
q22116 | parseRawQueryRow | train | func (sink *influxdbSink) parseRawQueryRow(rawRow influx_models.Row) ([]core.TimestampedMetricValue, error) {
vals := make([]core.TimestampedMetricValue, len(rawRow.Values))
wasInt := make(map[string]bool, 1)
for i, rawVal := range rawRow.Values {
val := core.TimestampedMetricValue{}
if ts, err := time.Parse(ti... | go | {
"resource": ""
} |
q22117 | composeAggregateQuery | train | func (sink *influxdbSink) composeAggregateQuery(metricName string, labels map[string]string, aggregations []core.AggregationType, metricKeys []core.HistoricalKey, start, end time.Time, bucketSize time.Duration) string {
seriesName, fieldName := sink.metricToSeriesAndField(metricName)
var bucketSizeNanoSeconds int64 ... | go | {
"resource": ""
} |
q22118 | parseAggregateQueryRow | train | func (sink *influxdbSink) parseAggregateQueryRow(rawRow influx_models.Row, aggregationLookup map[core.AggregationType]int, bucketSize time.Duration) ([]core.TimestampedAggregationValue, error) {
vals := make([]core.TimestampedAggregationValue, len(rawRow.Values))
wasInt := make(map[string]bool, len(aggregationLookup)... | go | {
"resource": ""
} |
q22119 | setAggregationValueIfPresent | train | func setAggregationValueIfPresent(aggName core.AggregationType, rawVal []interface{}, aggregations *core.AggregationValue, indexLookup map[core.AggregationType]int, wasInt map[string]bool) error {
if fieldIndex, ok := indexLookup[aggName]; ok {
targetValue := &core.MetricValue{}
if err := tryParseMetricValue(strin... | go | {
"resource": ""
} |
q22120 | tryParseMetricValue | train | func tryParseMetricValue(aggName string, rawVal []interface{}, targetValue *core.MetricValue, fieldIndex int, wasInt map[string]bool) error {
// the Influx client decodes numeric fields to json.Number (a string), so we have to deal with that --
// assume, starting off, that values may be either float or int. Try int... | go | {
"resource": ""
} |
q22121 | GetMetricNames | train | func (sink *influxdbSink) GetMetricNames(metricKey core.HistoricalKey) ([]string, error) {
if err := sink.checkSanitizedKey(&metricKey); err != nil {
return nil, err
}
return sink.stringListQuery(fmt.Sprintf("SHOW MEASUREMENTS WHERE %s", sink.keyToSelector(metricKey)), "Unable to list available metrics")
} | go | {
"resource": ""
} |
q22122 | GetNodes | train | func (sink *influxdbSink) GetNodes() ([]string, error) {
return sink.stringListQuery(fmt.Sprintf("SHOW TAG VALUES WITH KEY = %s", core.LabelNodename.Key), "Unable to list all nodes")
} | go | {
"resource": ""
} |
q22123 | GetNamespaces | train | func (sink *influxdbSink) GetNamespaces() ([]string, error) {
return sink.stringListQuery(fmt.Sprintf("SHOW TAG VALUES WITH KEY = %s", core.LabelNamespaceName.Key), "Unable to list all namespaces")
} | go | {
"resource": ""
} |
q22124 | GetPodsFromNamespace | train | func (sink *influxdbSink) GetPodsFromNamespace(namespace string) ([]string, error) {
if !nameAllowedChars.MatchString(namespace) {
return nil, fmt.Errorf("Invalid namespace name %q", namespace)
}
// This is a bit difficult for the influx query language, so we cheat a bit here --
// we just get all series for the ... | go | {
"resource": ""
} |
q22125 | GetSystemContainersFromNode | train | func (sink *influxdbSink) GetSystemContainersFromNode(node string) ([]string, error) {
if !nameAllowedChars.MatchString(node) {
return nil, fmt.Errorf("Invalid node name %q", node)
}
// This is a bit difficult for the influx query language, so we cheat a bit here --
// we just get all series for the uptime measur... | go | {
"resource": ""
} |
q22126 | stringListQueryCol | train | func (sink *influxdbSink) stringListQueryCol(q, colName string, errStr string) ([]string, error) {
sink.RLock()
defer sink.RUnlock()
resp, err := sink.runQuery(q)
if err != nil {
return nil, fmt.Errorf(errStr)
}
if len(resp[0].Series) < 1 {
return nil, fmt.Errorf(errStr)
}
colInd := -1
for i, col := ran... | go | {
"resource": ""
} |
q22127 | stringListQuery | train | func (sink *influxdbSink) stringListQuery(q string, errStr string) ([]string, error) {
sink.RLock()
defer sink.RUnlock()
resp, err := sink.runQuery(q)
if err != nil {
return nil, fmt.Errorf(errStr)
}
if len(resp[0].Series) < 1 {
return nil, fmt.Errorf(errStr)
}
res := make([]string, len(resp[0].Series[0]... | go | {
"resource": ""
} |
q22128 | populateAggregations | train | func populateAggregations(rawRowName string, rawVal []interface{}, val *core.TimestampedAggregationValue, aggregationLookup map[core.AggregationType]int, wasInt map[string]bool) error {
for _, aggregation := range core.MultiTypedAggregations {
if err := setAggregationValueIfPresent(aggregation, rawVal, &val.Aggregat... | go | {
"resource": ""
} |
q22129 | setAggregationValueTypes | train | func setAggregationValueTypes(vals []core.TimestampedAggregationValue, wasInt map[string]bool) {
for _, aggregation := range core.MultiTypedAggregations {
if isInt, ok := wasInt[string(aggregation)]; ok && isInt {
for i := range vals {
val := vals[i].Aggregations[aggregation]
val.ValueType = core.ValueInt... | go | {
"resource": ""
} |
q22130 | register | train | func (sink *gcmSink) register(metrics []core.Metric) error {
sink.Lock()
defer sink.Unlock()
if sink.registered {
return nil
}
for _, metric := range metrics {
metricName := fullMetricName(sink.project, metric.MetricDescriptor.Name)
metricType := fullMetricType(metric.MetricDescriptor.Name)
if _, err := ... | go | {
"resource": ""
} |
q22131 | ExportData | train | func (this *sinkManager) ExportData(data *core.DataBatch) {
var wg sync.WaitGroup
for _, sh := range this.sinkHolders {
wg.Add(1)
go func(sh sinkHolder, wg *sync.WaitGroup) {
defer wg.Done()
glog.V(2).Infof("Pushing data to: %s", sh.sink.Name())
select {
case sh.dataBatchChannel <- data:
glog.V(2)... | go | {
"resource": ""
} |
q22132 | GetAllRawContainers | train | func (self *KubeletClient) GetAllRawContainers(host Host, start, end time.Time) ([]cadvisor.ContainerInfo, error) {
url := self.getUrl(host, "/stats/container/")
return self.getAllContainers(url, start, end)
} | go | {
"resource": ""
} |
q22133 | InstrumentRouteFunc | train | func InstrumentRouteFunc(handlerName string, routeFunc restful.RouteFunction) restful.RouteFunction {
opts := prometheus.SummaryOpts{
Subsystem: "http",
ConstLabels: prometheus.Labels{"handler": handlerName},
}
reqCnt := prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: opts.Subsystem,
Na... | go | {
"resource": ""
} |
q22134 | PodContainerKey | train | func PodContainerKey(namespace, podName, containerName string) string {
return fmt.Sprintf("namespace:%s/pod:%s/container:%s", namespace, podName, containerName)
} | go | {
"resource": ""
} |
q22135 | addNamespaceInfo | train | func (this *NamespaceBasedEnricher) addNamespaceInfo(metricSet *core.MetricSet) {
metricSetType, found := metricSet.Labels[core.LabelMetricSetType.Key]
if !found {
return
}
if metricSetType != core.MetricSetTypePodContainer &&
metricSetType != core.MetricSetTypePod &&
metricSetType != core.MetricSetTypeNamesp... | go | {
"resource": ""
} |
q22136 | availableClusterMetrics | train | func (a *Api) availableClusterMetrics(request *restful.Request, response *restful.Response) {
a.processMetricNamesRequest(core.ClusterKey(), response)
} | go | {
"resource": ""
} |
q22137 | availableNodeMetrics | train | func (a *Api) availableNodeMetrics(request *restful.Request, response *restful.Response) {
a.processMetricNamesRequest(core.NodeKey(request.PathParameter("node-name")), response)
} | go | {
"resource": ""
} |
q22138 | availableNamespaceMetrics | train | func (a *Api) availableNamespaceMetrics(request *restful.Request, response *restful.Response) {
a.processMetricNamesRequest(core.NamespaceKey(request.PathParameter("namespace-name")), response)
} | go | {
"resource": ""
} |
q22139 | parseTimeParam | train | func parseTimeParam(queryParam string, defaultValue time.Time) (time.Time, error) {
if queryParam != "" {
reqStamp, err := time.Parse(time.RFC3339, queryParam)
if err != nil {
return time.Time{}, fmt.Errorf("timestamp argument cannot be parsed: %s", err)
}
return reqStamp, nil
}
return defaultValue, nil
} | go | {
"resource": ""
} |
q22140 | appendEvent | train | func appendEvent(events []riemanngo.Event, sink *RiemannSink, host, name string, value interface{}, labels map[string]string, timestamp int64) []riemanngo.Event {
event := riemanngo.Event{
Time: timestamp,
Service: name,
Host: host,
Description: "",
Attributes: labels,
Metric: value... | go | {
"resource": ""
} |
q22141 | ExportData | train | func (sink *RiemannSink) ExportData(dataBatch *core.DataBatch) {
sink.Lock()
defer sink.Unlock()
if sink.client == nil {
// the client could be nil here, so we reconnect
client, err := riemannCommon.GetRiemannClient(sink.config)
if err != nil {
glog.Warningf("Riemann sink not connected: %v", err)
return... | go | {
"resource": ""
} |
q22142 | availableClusterMetrics | train | func (a *HistoricalApi) availableClusterMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{ObjectType: core.MetricSetTypeCluster}
a.processMetricNamesRequest(key, response)
} | go | {
"resource": ""
} |
q22143 | availableNodeMetrics | train | func (a *HistoricalApi) availableNodeMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeNode,
NodeName: request.PathParameter("node-name"),
}
a.processMetricNamesRequest(key, response)
} | go | {
"resource": ""
} |
q22144 | availableNamespaceMetrics | train | func (a *HistoricalApi) availableNamespaceMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeNamespace,
NamespaceName: request.PathParameter("namespace-name"),
}
a.processMetricNamesRequest(key, response)
} | go | {
"resource": ""
} |
q22145 | availablePodMetrics | train | func (a *HistoricalApi) availablePodMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypePod,
NamespaceName: request.PathParameter("namespace-name"),
PodName: request.PathParameter("pod-name"),
}
a.processMetricNamesRequest(key, respo... | go | {
"resource": ""
} |
q22146 | availablePodContainerMetrics | train | func (a *HistoricalApi) availablePodContainerMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypePodContainer,
NamespaceName: request.PathParameter("namespace-name"),
PodName: request.PathParameter("pod-name"),
ContainerName: request... | go | {
"resource": ""
} |
q22147 | availableFreeContainerMetrics | train | func (a *HistoricalApi) availableFreeContainerMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeSystemContainer,
NodeName: request.PathParameter("node-name"),
ContainerName: request.PathParameter("container-name"),
}
a.processMetric... | go | {
"resource": ""
} |
q22148 | nodeList | train | func (a *HistoricalApi) nodeList(request *restful.Request, response *restful.Response) {
if resp, err := a.historicalSource.GetNodes(); err != nil {
response.WriteError(http.StatusInternalServerError, err)
} else {
response.WriteEntity(resp)
}
} | go | {
"resource": ""
} |
q22149 | namespaceList | train | func (a *HistoricalApi) namespaceList(request *restful.Request, response *restful.Response) {
if resp, err := a.historicalSource.GetNamespaces(); err != nil {
response.WriteError(http.StatusInternalServerError, err)
} else {
response.WriteEntity(resp)
}
} | go | {
"resource": ""
} |
q22150 | namespacePodList | train | func (a *HistoricalApi) namespacePodList(request *restful.Request, response *restful.Response) {
if resp, err := a.historicalSource.GetPodsFromNamespace(request.PathParameter("namespace-name")); err != nil {
response.WriteError(http.StatusInternalServerError, err)
} else {
response.WriteEntity(resp)
}
} | go | {
"resource": ""
} |
q22151 | freeContainerMetrics | train | func (a *HistoricalApi) freeContainerMetrics(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeSystemContainer,
NodeName: request.PathParameter("node-name"),
ContainerName: request.PathParameter("container-name"),
}
a.processMetricRequest(k... | go | {
"resource": ""
} |
q22152 | podListMetrics | train | func (a *HistoricalApi) podListMetrics(request *restful.Request, response *restful.Response) {
start, end, err := getStartEndTimeHistorical(request)
if err != nil {
response.WriteError(http.StatusBadRequest, err)
return
}
keys := []core.HistoricalKey{}
if request.PathParameter("pod-id-list") != "" {
for _, ... | go | {
"resource": ""
} |
q22153 | clusterAggregations | train | func (a *HistoricalApi) clusterAggregations(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{ObjectType: core.MetricSetTypeCluster}
a.processAggregationRequest(key, request, response)
} | go | {
"resource": ""
} |
q22154 | nodeAggregations | train | func (a *HistoricalApi) nodeAggregations(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeNode,
NodeName: request.PathParameter("node-name"),
}
a.processAggregationRequest(key, request, response)
} | go | {
"resource": ""
} |
q22155 | namespaceAggregations | train | func (a *HistoricalApi) namespaceAggregations(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeNamespace,
NamespaceName: request.PathParameter("namespace-name"),
}
a.processAggregationRequest(key, request, response)
} | go | {
"resource": ""
} |
q22156 | podContainerAggregations | train | func (a *HistoricalApi) podContainerAggregations(request *restful.Request, response *restful.Response) {
var key core.HistoricalKey
if request.PathParameter("pod-id") != "" {
key = core.HistoricalKey{
ObjectType: core.MetricSetTypePodContainer,
PodId: request.PathParameter("pod-id"),
ContainerNa... | go | {
"resource": ""
} |
q22157 | freeContainerAggregations | train | func (a *HistoricalApi) freeContainerAggregations(request *restful.Request, response *restful.Response) {
key := core.HistoricalKey{
ObjectType: core.MetricSetTypeSystemContainer,
NodeName: request.PathParameter("node-name"),
ContainerName: request.PathParameter("container-name"),
}
a.processAggregatio... | go | {
"resource": ""
} |
q22158 | podListAggregations | train | func (a *HistoricalApi) podListAggregations(request *restful.Request, response *restful.Response) {
start, end, err := getStartEndTimeHistorical(request)
if err != nil {
response.WriteError(http.StatusBadRequest, err)
return
}
bucketSize, err := getBucketSize(request)
if err != nil {
response.WriteError(http... | go | {
"resource": ""
} |
q22159 | processMetricRequest | train | func (a *HistoricalApi) processMetricRequest(key core.HistoricalKey, request *restful.Request, response *restful.Response) {
start, end, err := getStartEndTimeHistorical(request)
if err != nil {
response.WriteError(http.StatusBadRequest, err)
return
}
labels, err := getLabels(request)
if err != nil {
respons... | go | {
"resource": ""
} |
q22160 | processMetricNamesRequest | train | func (a *HistoricalApi) processMetricNamesRequest(key core.HistoricalKey, response *restful.Response) {
if resp, err := a.historicalSource.GetMetricNames(key); err != nil {
response.WriteError(http.StatusInternalServerError, err)
} else {
response.WriteEntity(resp)
}
} | go | {
"resource": ""
} |
q22161 | getBucketSize | train | func getBucketSize(request *restful.Request) (time.Duration, error) {
rawSize := request.QueryParameter("bucket")
if rawSize == "" {
return 0, nil
}
if len(rawSize) < 2 {
return 0, fmt.Errorf("unable to parse bucket size: %q is too short to be a duration", rawSize)
}
var multiplier time.Duration
var num str... | go | {
"resource": ""
} |
q22162 | getAggregations | train | func getAggregations(request *restful.Request) ([]core.AggregationType, error) {
aggregationsRaw := strings.Split(request.PathParameter("aggregations"), ",")
if len(aggregationsRaw) == 0 {
return nil, fmt.Errorf("No aggregations specified")
}
aggregations := make([]core.AggregationType, len(aggregationsRaw))
f... | go | {
"resource": ""
} |
q22163 | exportMetricValue | train | func exportMetricValue(value *core.MetricValue) *types.MetricValue {
if value == nil {
return nil
}
if value.ValueType == core.ValueInt64 {
return &types.MetricValue{
IntValue: &value.IntValue,
}
} else {
floatVal := float64(value.FloatValue)
return &types.MetricValue{
FloatValue: &floatVal,
}
}... | go | {
"resource": ""
} |
q22164 | extractMetricValue | train | func extractMetricValue(aggregations *core.AggregationValue, aggName core.AggregationType) *types.MetricValue {
if inputVal, ok := aggregations.Aggregations[aggName]; ok {
return exportMetricValue(&inputVal)
} else {
return nil
}
} | go | {
"resource": ""
} |
q22165 | exportTimestampedAggregationValue | train | func exportTimestampedAggregationValue(values []core.TimestampedAggregationValue) types.MetricAggregationResult {
result := types.MetricAggregationResult{
Buckets: make([]types.MetricAggregationBucket, 0, len(values)),
BucketSize: 0,
}
for _, value := range values {
// just use the largest bucket size, sinc... | go | {
"resource": ""
} |
q22166 | decodeSummary | train | func (this *summaryMetricsSource) decodeSummary(summary *stats.Summary) map[string]*MetricSet {
glog.V(9).Infof("Begin summary decode")
result := map[string]*MetricSet{}
labels := map[string]string{
LabelNodename.Key: this.node.NodeName,
LabelHostname.Key: this.node.HostName,
LabelHostID.Key: this.node.Host... | go | {
"resource": ""
} |
q22167 | cloneLabels | train | func (this *summaryMetricsSource) cloneLabels(labels map[string]string) map[string]string {
clone := make(map[string]string, len(labels))
for k, v := range labels {
clone[k] = v
}
return clone
} | go | {
"resource": ""
} |
q22168 | addIntMetric | train | func (this *summaryMetricsSource) addIntMetric(metrics *MetricSet, metric *Metric, value *uint64) {
if value == nil {
glog.V(9).Infof("skipping metric %s because the value was nil", metric.Name)
return
}
val := MetricValue{
ValueType: ValueInt64,
MetricType: metric.Type,
IntValue: int64(*value),
}
met... | go | {
"resource": ""
} |
q22169 | addLabeledIntMetric | train | func (this *summaryMetricsSource) addLabeledIntMetric(metrics *MetricSet, metric *Metric, labels map[string]string, value *uint64) {
if value == nil {
glog.V(9).Infof("skipping labeled metric %s (%v) because the value was nil", metric.Name, labels)
return
}
val := LabeledMetric{
Name: metric.Name,
Labels:... | go | {
"resource": ""
} |
q22170 | getSystemContainerName | train | func (this *summaryMetricsSource) getSystemContainerName(c *stats.ContainerStats) string {
if legacyName, ok := systemNameMap[c.Name]; ok {
return legacyName
}
return c.Name
} | go | {
"resource": ""
} |
q22171 | GetRiemannClient | train | func GetRiemannClient(config RiemannConfig) (riemanngo.Client, error) {
glog.Infof("Connect Riemann client...")
client := riemanngo.NewTcpClient(config.Host)
runtime.SetFinalizer(client, func(c riemanngo.Client) { c.Close() })
// 5 seconds timeout
err := client.Connect(5)
if err != nil {
return nil, err
}
ret... | go | {
"resource": ""
} |
q22172 | SendData | train | func SendData(client riemanngo.Client, events []riemanngo.Event) error {
// do nothing if we are not connected
if client == nil {
glog.Warningf("Riemann sink not connected")
return nil
}
start := time.Now()
_, err := riemanngo.SendEvents(client, &events)
end := time.Now()
if err == nil {
glog.V(4).Infof("E... | go | {
"resource": ""
} |
q22173 | ExportEvents | train | func (this *sinkManager) ExportEvents(data *core.EventBatch) {
var wg sync.WaitGroup
for _, sh := range this.sinkHolders {
wg.Add(1)
go func(sh sinkHolder, wg *sync.WaitGroup) {
defer wg.Done()
glog.V(2).Infof("Pushing events to: %s", sh.sink.Name())
select {
case sh.eventBatchChannel <- data:
glo... | go | {
"resource": ""
} |
q22174 | cache | train | func (h *hawkularSink) cache(md *metrics.MetricDefinition) {
h.pushToCache(md.ID, hashDefinition(md))
} | go | {
"resource": ""
} |
q22175 | pushToCache | train | func (h *hawkularSink) pushToCache(key string, hash uint64) {
h.regLock.Lock()
h.expReg[key] = &expiringItem{
hash: hash,
ttl: h.runId,
}
h.regLock.Unlock()
} | go | {
"resource": ""
} |
q22176 | checkCache | train | func (h *hawkularSink) checkCache(key string, hash uint64) bool {
h.regLock.Lock()
defer h.regLock.Unlock()
_, found := h.expReg[key]
if !found || h.expReg[key].hash != hash {
return false
}
// Update the TTL
h.expReg[key].ttl = h.runId
return true
} | go | {
"resource": ""
} |
q22177 | expireCache | train | func (h *hawkularSink) expireCache(runId uint64) {
h.regLock.Lock()
defer h.regLock.Unlock()
for k, v := range h.expReg {
if (v.ttl + h.cacheAge) <= runId {
delete(h.expReg, k)
}
}
} | go | {
"resource": ""
} |
q22178 | updateDefinitions | train | func (h *hawkularSink) updateDefinitions(mds []*metrics.MetricDefinition) error {
for _, p := range mds {
if model, f := h.models[p.Tags[descriptorTag]]; f && !h.recent(p, model) {
if err := h.client.UpdateTags(p.Type, p.ID, p.Tags, h.modifiers...); err != nil {
return err
}
}
h.cache(p)
}
return ni... | go | {
"resource": ""
} |
q22179 | recent | train | func (h *hawkularSink) recent(live *metrics.MetricDefinition, model *metrics.MetricDefinition) bool {
recent := true
for k := range model.Tags {
if v, found := live.Tags[k]; !found {
// There's a label that wasn't in our stored definition
live.Tags[k] = v
recent = false
}
}
return recent
} | go | {
"resource": ""
} |
q22180 | descriptorToDefinition | train | func (h *hawkularSink) descriptorToDefinition(md *core.MetricDescriptor) metrics.MetricDefinition {
tags := make(map[string]string)
// Postfix description tags with _description
for _, l := range md.Labels {
if len(l.Description) > 0 {
tags[l.Key+descriptionTag] = l.Description
}
}
if len(md.Units.String()... | go | {
"resource": ""
} |
q22181 | pointToLabeledMetricHeader | train | func (h *hawkularSink) pointToLabeledMetricHeader(ms *core.MetricSet, metric core.LabeledMetric, timestamp time.Time) (*metrics.MetricHeader, error) {
name := h.idName(ms, metric.Name)
if resourceID, found := metric.Labels[core.LabelResourceID.Key]; found {
name = h.idName(ms, metric.Name+separator+resourceID)
}
... | go | {
"resource": ""
} |
q22182 | parseFilters | train | func parseFilters(v []string) ([]Filter, error) {
fs := make([]Filter, 0, len(v))
for _, s := range v {
p := strings.Index(s, "(")
if p < 0 {
return nil, fmt.Errorf("Incorrect syntax in filter parameters, missing (")
}
if strings.Index(s, ")") != len(s)-1 {
return nil, fmt.Errorf("Incorrect syntax in f... | go | {
"resource": ""
} |
q22183 | main | train | func main() {
encoding.Register()
s, e := tcell.NewScreen()
if e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
if e := s.Init(); e != nil {
fmt.Fprintf(os.Stderr, "%v\n", e)
os.Exit(1)
}
defStyle = tcell.StyleDefault.
Background(tcell.ColorBlack).
Foreground(tcell.ColorWhite)
s.SetStyle(... | go | {
"resource": ""
} |
q22184 | Fill | train | func (v *ViewPort) Fill(ch rune, style tcell.Style) {
if v.v != nil {
for y := 0; y < v.height; y++ {
for x := 0; x < v.width; x++ {
v.v.SetContent(x+v.physx, y+v.physy, ch, nil, style)
}
}
}
} | go | {
"resource": ""
} |
q22185 | Reset | train | func (v *ViewPort) Reset() {
v.limx = 0
v.limy = 0
v.viewx = 0
v.viewy = 0
} | go | {
"resource": ""
} |
q22186 | MakeVisible | train | func (v *ViewPort) MakeVisible(x, y int) {
if x < v.limx && x >= v.viewx+v.width {
v.viewx = x - (v.width - 1)
}
if x >= 0 && x < v.viewx {
v.viewx = x
}
if y < v.limy && y >= v.viewy+v.height {
v.viewy = y - (v.height - 1)
}
if y >= 0 && y < v.viewy {
v.viewy = y
}
v.ValidateView()
} | go | {
"resource": ""
} |
q22187 | ValidateViewY | train | func (v *ViewPort) ValidateViewY() {
if v.viewy >= v.limy-v.height {
v.viewy = (v.limy - v.height)
}
if v.viewy < 0 {
v.viewy = 0
}
} | go | {
"resource": ""
} |
q22188 | ValidateViewX | train | func (v *ViewPort) ValidateViewX() {
if v.viewx >= v.limx-v.width {
v.viewx = (v.limx - v.width)
}
if v.viewx < 0 {
v.viewx = 0
}
} | go | {
"resource": ""
} |
q22189 | Center | train | func (v *ViewPort) Center(x, y int) {
if x < 0 || y < 0 || x >= v.limx || y >= v.limy || v.v == nil {
return
}
v.viewx = x - (v.width / 2)
v.viewy = y - (v.height / 2)
v.ValidateView()
} | go | {
"resource": ""
} |
q22190 | ScrollUp | train | func (v *ViewPort) ScrollUp(rows int) {
v.viewy -= rows
v.ValidateViewY()
} | go | {
"resource": ""
} |
q22191 | ScrollDown | train | func (v *ViewPort) ScrollDown(rows int) {
v.viewy += rows
v.ValidateViewY()
} | go | {
"resource": ""
} |
q22192 | ScrollLeft | train | func (v *ViewPort) ScrollLeft(cols int) {
v.viewx -= cols
v.ValidateViewX()
} | go | {
"resource": ""
} |
q22193 | ScrollRight | train | func (v *ViewPort) ScrollRight(cols int) {
v.viewx += cols
v.ValidateViewX()
} | go | {
"resource": ""
} |
q22194 | SetSize | train | func (v *ViewPort) SetSize(width, height int) {
v.height = height
v.width = width
v.ValidateView()
} | go | {
"resource": ""
} |
q22195 | GetVisible | train | func (v *ViewPort) GetVisible() (int, int, int, int) {
return v.viewx, v.viewy, v.viewx + v.width - 1, v.viewy + v.height - 1
} | go | {
"resource": ""
} |
q22196 | GetPhysical | train | func (v *ViewPort) GetPhysical() (int, int, int, int) {
return v.physx, v.physy, v.physx + v.width - 1, v.physy + v.height - 1
} | go | {
"resource": ""
} |
q22197 | Resize | train | func (v *ViewPort) Resize(x, y, width, height int) {
if v.v == nil {
return
}
px, py := v.v.Size()
if x >= 0 && x < px {
v.physx = x
}
if y >= 0 && y < py {
v.physy = y
}
if width < 0 {
width = px - x
}
if height < 0 {
height = py - y
}
if width <= x+px {
v.width = width
}
if height <= y+py {
... | go | {
"resource": ""
} |
q22198 | SetCenter | train | func (t *TextBar) SetCenter(s string, style tcell.Style) {
t.initialize()
if style == tcell.StyleDefault {
style = t.style
}
t.center.SetText(s)
t.center.SetStyle(style)
} | go | {
"resource": ""
} |
q22199 | SetStyle | train | func (t *TextBar) SetStyle(style tcell.Style) {
t.initialize()
t.style = style
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.