Пример #1
0
func init() {
	bm_sched_50k = &Schedule{}
	val := &Metavalue{Time: time.Now(), Value: "foo"}

	bm_sched_50k.Metadata = map[metadata.Metakey]*Metavalue{
		{Tags: "host=host1", Name: "foo"}: val,
	}
	bm_sched_50k.metricMetadata = map[string]*MetadataMetric{}
	for i := 0; i < 50000; i++ {
		key := metadata.Metakey{Name: "foo"}
		key.Tags = fmt.Sprintf("host=host%d,somethingElse=aaa", i)
		bm_sched_50k.Metadata[key] = val

		bm_sched_50k.metricMetadata[fmt.Sprintf("m%d", i)] = &MetadataMetric{Description: "aaa"}
	}
	bm_sched_2m = &Schedule{}
	bm_sched_2m.Metadata = map[metadata.Metakey]*Metavalue{
		{Tags: "host=host1", Name: "foo"}: val,
	}
	for i := 0; i < 2000000; i++ {
		key := metadata.Metakey{Name: "foo"}
		key.Tags = fmt.Sprintf("host=host%d,somethingElse=aaa", i)
		bm_sched_2m.Metadata[key] = val
	}
}
Пример #2
0
func (s *Schedule) PutMetadata(k metadata.Metakey, v interface{}) error {

	isCoreMeta := (k.Name == "desc" || k.Name == "unit" || k.Name == "rate")
	if !isCoreMeta {
		s.DataAccess.Metadata().PutTagMetadata(k.TagSet(), k.Name, fmt.Sprint(v), utcNow())
		return nil
	}
	if k.Metric == "" {
		err := fmt.Errorf("desc, rate, and unit require metric name")
		slog.Error(err)
		return err
	}
	strVal, ok := v.(string)
	if !ok {
		err := fmt.Errorf("desc, rate, and unit require value to be string. Found: %s", reflect.TypeOf(v))
		slog.Error(err)
		return err
	}
	return s.DataAccess.Metadata().PutMetricMetadata(k.Metric, k.Name, strVal)
}