当前位置: 首页>>代码示例>>Golang>>正文


Golang TagSet.String方法代码示例

本文整理汇总了Golang中bosun/org/opentsdb.TagSet.String方法的典型用法代码示例。如果您正苦于以下问题:Golang TagSet.String方法的具体用法?Golang TagSet.String怎么用?Golang TagSet.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bosun/org/opentsdb.TagSet的用法示例。


在下文中一共展示了TagSet.String方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Put

// Put is useful for capturing "events" that have a gauge value. Subsequent
// calls between the sending interval will overwrite previous calls.
func Put(metric string, ts opentsdb.TagSet, v interface{}) error {
	if err := check(metric, &ts); err != nil {
		return err
	}
	tss := metric + ts.String()
	mlock.Lock()
	puts[tss] = &putMetric{metric, ts.Copy(), v}
	mlock.Unlock()
	return nil
}
开发者ID:pdf,项目名称:bosun,代码行数:12,代码来源:collect.go

示例2: Set

// Set registers a callback for the given metric and tags, calling f immediately
// before queueing data for send.
func Set(metric string, ts opentsdb.TagSet, f func() interface{}) error {
	if err := check(metric, &ts); err != nil {
		return err
	}
	tss := metric + ts.String()
	mlock.Lock()
	sets[tss] = &setMetric{metric, ts.Copy(), f}
	mlock.Unlock()
	return nil
}
开发者ID:pdf,项目名称:bosun,代码行数:12,代码来源:collect.go

示例3: GetLast

// GetLast returns the value of the most recent data point for the given metric
// and tag. tags should be of the form "{key=val,key2=val2}". If diff is true,
// the value is treated as a counter. err is non nil if there is no match.
func (s *Search) GetLast(metric string, tags opentsdb.TagSet, diff bool) (v float64, err error) {
	s.RLock()
	defer s.RUnlock()

	if mmap := s.last[metric]; mmap != nil {
		if p := mmap[tags.String()]; p != nil {
			if diff {
				return p.DiffFromPrev, nil
			}
			return p.LastVal, nil
		}
	}
	return 0, nil
}
开发者ID:urog,项目名称:bosun,代码行数:17,代码来源:search.go

示例4: Add

// Add takes a metric and increments a counter for that metric. The metric name
// is appended to the basename specified in the Init function.
func Add(metric string, ts opentsdb.TagSet, inc int64) error {
	if err := check(metric, &ts); err != nil {
		return err
	}
	tss := metric + ts.String()
	mlock.Lock()
	if counters[tss] == nil {
		counters[tss] = &addMetric{
			metric: metric,
			ts:     ts.Copy(),
		}
	}
	counters[tss].value += inc
	mlock.Unlock()
	return nil
}
开发者ID:pdf,项目名称:bosun,代码行数:18,代码来源:collect.go

示例5: Sample

func Sample(metric string, ts opentsdb.TagSet, v float64) error {
	if err := check(metric, &ts); err != nil {
		return err
	}
	tss := metric + ts.String()
	mlock.Lock()
	if aggs[tss] == nil {
		aggs[tss] = &agMetric{
			metric: metric,
			ts:     ts.Copy(),
		}
	}
	aggs[tss].values = append(aggs[tss].values, v)
	mlock.Unlock()
	return nil
}
开发者ID:pdf,项目名称:bosun,代码行数:16,代码来源:collect.go

示例6: TestTagMetadata_RoundTrip

func TestTagMetadata_RoundTrip(t *testing.T) {
	host := randString(4)
	tagset := opentsdb.TagSet{"host": host, "iface": "foo", "iname": "bar", "direction": "in"}
	if err := testData.Metadata().PutTagMetadata(tagset, "alias", "foo", time.Now()); err != nil {
		t.Fatal(err)
	}
	metas, err := testData.Metadata().GetTagMetadata(tagset, "alias")
	if err != nil {
		t.Fatal(err)
	}
	if len(metas) != 1 {
		t.Fatal("expected 1 metadata result")
	}
	m := metas[0]
	if m.Name != "alias" {
		t.Fatalf("name %s != alias", m.Name)
	}
	if !m.Tags.Equal(tagset) {
		t.Fatalf("tagset %s != %s", m.Tags.String(), tagset.String())
	}
}
开发者ID:eswdd,项目名称:bosun,代码行数:21,代码来源:tag_metadata_test.go

示例7: Host


//.........这里部分代码省略.........
	if err != nil {
		return nil, err
	}
	serviceTags, err := tagsByKey("os.service.running", "host")
	if err != nil {
		return nil, err
	}
	// Will assume the same tagsets exist .mem_real, .mem_virtual and possibly .count
	processTags, err := tagsByKey("os.proc.cpu", "host")
	if err != nil {
		return nil, err
	}
	// Will make the assumption that the metric bosun.ping.timeout, resolved, and rtt
	// all share the same tagset
	icmpTimeOutTags, err := tagsByKey("bosun.ping.timeout", "dst_host")
	if err != nil {
		return nil, err
	}
	for name, host := range hosts {
		host.Name = name
		hostTagSet := opentsdb.TagSet{"host": host.Name}
		hostMetadata, err := s.GetMetadata("", hostTagSet)
		if err != nil {
			slog.Error(err)
		}
		processHostIncidents(host, states, silences)
		for _, ts := range icmpTimeOutTags[host.Name] {
			// The host tag represents the polling source for these set of metrics
			source, ok := ts["host"]
			if !ok {
				slog.Errorf("couldn't find source tag for icmp data for host %s", host.Name)
			}
			// 1 Means it timed out
			timeout, timestamp, err := s.Search.GetLast("bosun.ping.timeout", ts.String(), false)
			if oldOrErr(timestamp, err) {
				continue
			}
			rtt, rttTimestamp, _ := s.Search.GetLast("bosun.ping.rtt", ts.String(), false)
			// 1 means dns resolution was successful
			dnsLookup, dnsTimestamp, dnsErr := s.Search.GetLast("bosun.ping.resolved", ts.String(), false)
			host.ICMPData[source] = &ICMPData{
				TimedOut:               timeout == 1 && err == nil,
				TimedOutLastUpdated:    timestamp,
				DNSResolved:            dnsLookup == 1 && dnsErr == nil,
				DNSResolvedLastUpdated: dnsTimestamp,
				RTTMS:          rtt,
				RTTLastUpdated: rttTimestamp,
			}

		}
		for _, ts := range serviceTags[host.Name] {
			name, ok := ts["name"]
			if !ok {
				slog.Errorf("couldn't find service name tag %s for host %s", name, host.Name)
				continue
			}
			fstatus, timestamp, err := s.Search.GetLast("os.service.running", ts.String(), false)
			running := false
			if fstatus != 0 {
				running = true
			}
			if !oldOrErr(timestamp, err) {
				host.Services[name] = &ServiceStatus{
					Running:            running,
					RunningLastUpdated: timestamp,
				}
开发者ID:eswdd,项目名称:bosun,代码行数:67,代码来源:host.go

示例8: NewAlertKey

func NewAlertKey(name string, group opentsdb.TagSet) AlertKey {
	return AlertKey(name + group.String())
}
开发者ID:eswdd,项目名称:bosun,代码行数:3,代码来源:alertKey.go


注:本文中的bosun/org/opentsdb.TagSet.String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。