diff --git a/LICENSE b/LICENSE index cbeb29fe65..b4f8761cf3 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2012 Prometheus Team + Copyright 2013 Prometheus Team Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 6c3153e125..9dc694f154 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ -# Copyright 2012 Prometheus Team +# Copyright 2013 Prometheus Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/Makefile.TRAVIS b/Makefile.TRAVIS index 4eae9649d2..0bd4113013 100644 --- a/Makefile.TRAVIS +++ b/Makefile.TRAVIS @@ -1,4 +1,4 @@ -# Copyright 2012 Prometheus Team +# Copyright 2013 Prometheus Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/api/query.go b/api/query.go index a13bfeb5e1..3041a0bfb8 100644 --- a/api/query.go +++ b/api/query.go @@ -7,6 +7,7 @@ import ( "github.com/prometheus/prometheus/rules" "github.com/prometheus/prometheus/rules/ast" "log" + "net/http" "sort" "time" ) @@ -74,14 +75,14 @@ func (serv MetricsService) Metrics() string { rb.SetContentType(gorest.Application_Json) if err != nil { log.Printf("Error loading metric names: %v", err) - rb.SetResponseCode(500) + rb.SetResponseCode(http.StatusInternalServerError) return err.Error() } sort.Strings(metricNames) resultBytes, err := json.Marshal(metricNames) if err != nil { log.Printf("Error marshalling metric names: %v", err) - rb.SetResponseCode(500) + rb.SetResponseCode(http.StatusInternalServerError) return err.Error() } return string(resultBytes) diff --git a/coding/indexable/time.go b/coding/indexable/time.go index 19080fa729..930e367ae9 100644 --- a/coding/indexable/time.go +++ b/coding/indexable/time.go @@ -1,10 +1,10 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/coding/indexable/time_test.go b/coding/indexable/time_test.go index 6706540f3b..f24c0a07ad 100644 --- a/coding/indexable/time_test.go +++ b/coding/indexable/time_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/coding/interface.go b/coding/interface.go index fd1c7a790e..98441d68d7 100644 --- a/coding/interface.go +++ b/coding/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/coding/protocol_buffer.go b/coding/protocol_buffer.go index 105c3c2eb5..8ad93424df 100644 --- a/coding/protocol_buffer.go +++ b/coding/protocol_buffer.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/main.go b/main.go index b5c7995dd3..38c019e99f 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/model/Makefile b/model/Makefile index 471ef1e2d6..87d95d7546 100644 --- a/model/Makefile +++ b/model/Makefile @@ -1,4 +1,4 @@ -# Copyright 2012 Prometheus Team +# Copyright 2013 Prometheus Team # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/model/data.proto b/model/data.proto index 7a957ea4d7..c3ad6ab1dd 100644 --- a/model/data.proto +++ b/model/data.proto @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/model/dto.go b/model/dto.go index e9695cd13e..9860eadd97 100644 --- a/model/dto.go +++ b/model/dto.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/model/metric.go b/model/metric.go index 6a517a6a74..de7a7620fb 100644 --- a/model/metric.go +++ b/model/metric.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/rules/load.go b/rules/load.go index bf12fdde87..c4f94235c5 100644 --- a/rules/load.go +++ b/rules/load.go @@ -92,10 +92,10 @@ func LoadRulesFromString(rulesString string) ([]*Rule, error) { func LoadRulesFromFile(fileName string) ([]*Rule, error) { rulesReader, err := os.Open(fileName) - defer rulesReader.Close() if err != nil { return []*Rule{}, err } + defer rulesReader.Close() return LoadRulesFromReader(rulesReader) } diff --git a/storage/interface.go b/storage/interface.go index 0c3c722cc4..2bc1b72d3d 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/interface.go b/storage/metric/interface.go index bcb03b84fe..9748dedda5 100644 --- a/storage/metric/interface.go +++ b/storage/metric/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/diagnostics.go b/storage/metric/leveldb/diagnostics.go index de6a725289..1c8fa98d55 100644 --- a/storage/metric/leveldb/diagnostics.go +++ b/storage/metric/leveldb/diagnostics.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/instrumentation.go b/storage/metric/leveldb/instrumentation.go index 2bfcb65865..cad5a140bd 100644 --- a/storage/metric/leveldb/instrumentation.go +++ b/storage/metric/leveldb/instrumentation.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/interface_test.go b/storage/metric/leveldb/interface_test.go index bbd54a9235..002f77852a 100644 --- a/storage/metric/leveldb/interface_test.go +++ b/storage/metric/leveldb/interface_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/leveldb_test.go b/storage/metric/leveldb/leveldb_test.go index d914ac28cd..faef77fb18 100644 --- a/storage/metric/leveldb/leveldb_test.go +++ b/storage/metric/leveldb/leveldb_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/lifecycle.go b/storage/metric/leveldb/lifecycle.go index cbe8cd1e86..683a5a239c 100644 --- a/storage/metric/leveldb/lifecycle.go +++ b/storage/metric/leveldb/lifecycle.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/mutable.go b/storage/metric/leveldb/mutable.go index ab927ed455..68409ba23d 100644 --- a/storage/metric/leveldb/mutable.go +++ b/storage/metric/leveldb/mutable.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/reading.go b/storage/metric/leveldb/reading.go index cfef876bff..98cffe1bbc 100644 --- a/storage/metric/leveldb/reading.go +++ b/storage/metric/leveldb/reading.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -15,7 +15,6 @@ package leveldb import ( "code.google.com/p/goprotobuf/proto" - "errors" "github.com/prometheus/prometheus/coding" "github.com/prometheus/prometheus/coding/indexable" "github.com/prometheus/prometheus/model" @@ -644,42 +643,34 @@ func (d *MetricKeyDecoder) DecodeValue(in interface{}) (out interface{}, err err return } -type AcceptAllFilter struct{} +type MetricNamesFilter struct{} -func (f *AcceptAllFilter) Filter(key, value interface{}) (filterResult storage.FilterResult) { - return storage.ACCEPT +func (f *MetricNamesFilter) Filter(key, value interface{}) (filterResult storage.FilterResult) { + unmarshaled, ok := key.(*dto.LabelPair) + if ok && *unmarshaled.Name == "name" { + return storage.ACCEPT + } + return storage.SKIP } type CollectMetricNamesOp struct { - MetricNameMap map[string]bool + metricNames []string } func (op *CollectMetricNamesOp) Operate(key, value interface{}) (err *storage.OperatorError) { - unmarshaled, ok := key.(*dto.LabelPair) - if !ok { - return &storage.OperatorError{ - error: errors.New("Key is not of correct type"), - Continuable: true, - } - } - if *unmarshaled.Name == "name" { - op.MetricNameMap[*unmarshaled.Value] = true - } + unmarshaled := key.(*dto.LabelPair) + op.metricNames = append(op.metricNames, *unmarshaled.Value) return } func (l *LevelDBMetricPersistence) GetAllMetricNames() (metricNames []string, err error) { - metricNamesOp := &CollectMetricNamesOp{ - MetricNameMap: map[string]bool{}, - } + metricNamesOp := &CollectMetricNamesOp{} - _, err = l.labelSetToFingerprints.ForEach(&MetricKeyDecoder{}, &AcceptAllFilter{}, metricNamesOp) + _, err = l.labelSetToFingerprints.ForEach(&MetricKeyDecoder{}, &MetricNamesFilter{}, metricNamesOp) if err != nil { return } - for labelName := range metricNamesOp.MetricNameMap { - metricNames = append(metricNames, labelName) - } + metricNames = metricNamesOp.metricNames return } diff --git a/storage/metric/leveldb/regressions_test.go b/storage/metric/leveldb/regressions_test.go index 94559bc46b..64c5e7735c 100644 --- a/storage/metric/leveldb/regressions_test.go +++ b/storage/metric/leveldb/regressions_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/rule_integration_test.go b/storage/metric/leveldb/rule_integration_test.go index c7cf6b3ad6..3498bb52f5 100644 --- a/storage/metric/leveldb/rule_integration_test.go +++ b/storage/metric/leveldb/rule_integration_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/metric/leveldb/type.go b/storage/metric/leveldb/type.go index e5c7be6f75..fb060e92ef 100644 --- a/storage/metric/leveldb/type.go +++ b/storage/metric/leveldb/type.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/index/interface.go b/storage/raw/index/interface.go index 7ffecd7f08..237aab85fe 100644 --- a/storage/raw/index/interface.go +++ b/storage/raw/index/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/index/leveldb/interface_test.go b/storage/raw/index/leveldb/interface_test.go index 3b005d7457..99959d02d1 100644 --- a/storage/raw/index/leveldb/interface_test.go +++ b/storage/raw/index/leveldb/interface_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/index/leveldb/leveldb.go b/storage/raw/index/leveldb/leveldb.go index df5456c952..f527da08d9 100644 --- a/storage/raw/index/leveldb/leveldb.go +++ b/storage/raw/index/leveldb/leveldb.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/interface.go b/storage/raw/interface.go index 67103ba2b3..c552710fdf 100644 --- a/storage/raw/interface.go +++ b/storage/raw/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/leveldb/interface_test.go b/storage/raw/leveldb/interface_test.go index 25158470fd..141267a996 100644 --- a/storage/raw/leveldb/interface_test.go +++ b/storage/raw/leveldb/interface_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/storage/raw/leveldb/leveldb.go b/storage/raw/leveldb/leveldb.go index fffb2d4a3a..a82331bc0c 100644 --- a/storage/raw/leveldb/leveldb.go +++ b/storage/raw/leveldb/leveldb.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/utility/set.go b/utility/set.go index f2a565a72c..fee3b37cc7 100644 --- a/utility/set.go +++ b/utility/set.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/utility/set_test.go b/utility/set_test.go index 5938ed7e55..81400a333e 100644 --- a/utility/set_test.go +++ b/utility/set_test.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at diff --git a/utility/test/interface.go b/utility/test/interface.go index e0750af3de..e46e85f9e6 100644 --- a/utility/test/interface.go +++ b/utility/test/interface.go @@ -1,4 +1,4 @@ -// Copyright 2012 Prometheus Team +// Copyright 2013 Prometheus Team // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at