Migrate "golang.org/x/net/context" -> "context" (#3333)

In some places, where ctxhttp or gRPC are concerned, we still need to use the
old contexts.
This commit is contained in:
Julius Volz 2017-10-24 21:21:42 -07:00 committed by GitHub
parent bd52950ce8
commit 099df0c5f0
43 changed files with 81 additions and 79 deletions

View file

@ -15,6 +15,7 @@
package main package main
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -34,7 +35,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/version" "github.com/prometheus/common/version"
"golang.org/x/net/context"
"gopkg.in/alecthomas/kingpin.v2" "gopkg.in/alecthomas/kingpin.v2"
k8s_runtime "k8s.io/apimachinery/pkg/util/runtime" k8s_runtime "k8s.io/apimachinery/pkg/util/runtime"

View file

@ -14,6 +14,7 @@
package azure package azure
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strings" "strings"
@ -27,7 +28,6 @@ import (
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"

View file

@ -14,6 +14,7 @@
package consul package consul
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -30,7 +31,6 @@ import (
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/httputil" "github.com/prometheus/prometheus/util/httputil"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
) )
const ( const (

View file

@ -14,6 +14,7 @@
package discovery package discovery
import ( import (
"context"
"fmt" "fmt"
"sync" "sync"
"time" "time"
@ -32,7 +33,6 @@ import (
"github.com/prometheus/prometheus/discovery/openstack" "github.com/prometheus/prometheus/discovery/openstack"
"github.com/prometheus/prometheus/discovery/triton" "github.com/prometheus/prometheus/discovery/triton"
"github.com/prometheus/prometheus/discovery/zookeeper" "github.com/prometheus/prometheus/discovery/zookeeper"
"golang.org/x/net/context"
) )
// A TargetProvider provides information about target groups. It maintains a set // A TargetProvider provides information about target groups. It maintains a set

View file

@ -14,10 +14,10 @@
package discovery package discovery
import ( import (
"context"
"testing" "testing"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"golang.org/x/net/context"
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
) )

View file

@ -14,6 +14,7 @@
package dns package dns
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strings" "strings"
@ -25,7 +26,6 @@ import (
"github.com/miekg/dns" "github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
) )

View file

@ -14,6 +14,7 @@
package ec2 package ec2
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strings" "strings"
@ -27,7 +28,6 @@ import (
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/ec2"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"

View file

@ -14,6 +14,7 @@
package file package file
import ( import (
"context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -26,7 +27,6 @@ import (
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"gopkg.in/fsnotify.v1" "gopkg.in/fsnotify.v1"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"

View file

@ -14,6 +14,7 @@
package file package file
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"os" "os"
@ -22,7 +23,6 @@ import (
"time" "time"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
) )

View file

@ -14,20 +14,19 @@
package gce package gce
import ( import (
"context"
"fmt" "fmt"
"net/http" "net/http"
"strings" "strings"
"time" "time"
"google.golang.org/api/compute/v1"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"golang.org/x/oauth2" "golang.org/x/oauth2"
"golang.org/x/oauth2/google" "golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"

View file

@ -14,18 +14,18 @@
package kubernetes package kubernetes
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
"github.com/prometheus/prometheus/config"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
apiv1 "k8s.io/client-go/pkg/api/v1" apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
) )
// Endpoints discovers new endpoint targets. // Endpoints discovers new endpoint targets.

View file

@ -14,6 +14,7 @@
package kubernetes package kubernetes
import ( import (
"context"
"fmt" "fmt"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
@ -21,7 +22,6 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/apis/extensions/v1beta1" "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
) )

View file

@ -14,23 +14,23 @@
package kubernetes package kubernetes
import ( import (
"context"
"io/ioutil" "io/ioutil"
"sync" "sync"
"time" "time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/config"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1" apiv1 "k8s.io/client-go/pkg/api/v1"
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1" extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/rest" "k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
) )
const ( const (

View file

@ -14,6 +14,7 @@
package kubernetes package kubernetes
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
@ -23,7 +24,6 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1" apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"

View file

@ -14,6 +14,7 @@
package kubernetes package kubernetes
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"sync" "sync"
@ -21,12 +22,12 @@ import (
"time" "time"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
) )
type fakeInformer struct { type fakeInformer struct {

View file

@ -14,6 +14,7 @@
package kubernetes package kubernetes
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
@ -22,12 +23,12 @@ import (
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/api" "k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1" apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
) )
// Pod discovers new pod targets. // Pod discovers new pod targets.

View file

@ -14,6 +14,7 @@
package kubernetes package kubernetes
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
@ -21,11 +22,11 @@ import (
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
apiv1 "k8s.io/client-go/pkg/api/v1" apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
) )
// Service implements discovery of Kubernetes services. // Service implements discovery of Kubernetes services.

View file

@ -14,6 +14,7 @@
package marathon package marathon
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -24,8 +25,6 @@ import (
"strings" "strings"
"time" "time"
"golang.org/x/net/context"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/mwitkow/go-conntrack" "github.com/mwitkow/go-conntrack"

View file

@ -14,13 +14,13 @@
package marathon package marathon
import ( import (
"context"
"errors" "errors"
"net/http" "net/http"
"testing" "testing"
"time" "time"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
) )

View file

@ -14,6 +14,7 @@
package openstack package openstack
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"time" "time"
@ -25,7 +26,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/hypervisors" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/hypervisors"
"github.com/gophercloud/gophercloud/pagination" "github.com/gophercloud/gophercloud/pagination"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
) )

View file

@ -14,6 +14,7 @@
package openstack package openstack
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"time" "time"
@ -26,7 +27,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/gophercloud/gophercloud/pagination" "github.com/gophercloud/gophercloud/pagination"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"

View file

@ -14,6 +14,7 @@
package openstack package openstack
import ( import (
"context"
"errors" "errors"
"time" "time"
@ -21,7 +22,6 @@ import (
"github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack" "github.com/gophercloud/gophercloud/openstack"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
) )

View file

@ -14,6 +14,7 @@
package triton package triton
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -25,9 +26,9 @@ import (
"github.com/mwitkow/go-conntrack" "github.com/mwitkow/go-conntrack"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/httputil" "github.com/prometheus/prometheus/util/httputil"
"golang.org/x/net/context"
) )
const ( const (

View file

@ -14,6 +14,7 @@
package triton package triton
import ( import (
"context"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -23,10 +24,10 @@ import (
"testing" "testing"
"time" "time"
"github.com/stretchr/testify/assert"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
) )
var ( var (

View file

@ -14,17 +14,17 @@
package zookeeper package zookeeper
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net" "net"
"strconv" "strconv"
"time" "time"
"github.com/go-kit/kit/log"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/samuel/go-zookeeper/zk" "github.com/samuel/go-zookeeper/zk"
"golang.org/x/net/context"
"github.com/go-kit/kit/log"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
"github.com/prometheus/prometheus/util/treecache" "github.com/prometheus/prometheus/util/treecache"

View file

@ -15,6 +15,7 @@ package opentsdb
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -26,7 +27,6 @@ import (
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
) )

View file

@ -15,6 +15,7 @@ package notifier
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net" "net"
@ -30,7 +31,7 @@ import (
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context" old_ctx "golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
@ -123,7 +124,7 @@ type Options struct {
ExternalLabels model.LabelSet ExternalLabels model.LabelSet
RelabelConfigs []*config.RelabelConfig RelabelConfigs []*config.RelabelConfig
// Used for sending HTTP requests to the Alertmanager. // Used for sending HTTP requests to the Alertmanager.
Do func(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) Do func(ctx old_ctx.Context, client *http.Client, req *http.Request) (*http.Response, error)
Registerer prometheus.Registerer Registerer prometheus.Registerer
} }

View file

@ -14,6 +14,7 @@
package notifier package notifier
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -24,7 +25,7 @@ import (
"testing" "testing"
"time" "time"
"golang.org/x/net/context" old_ctx "golang.org/x/net/context"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
@ -198,7 +199,7 @@ func TestCustomDo(t *testing.T) {
var received bool var received bool
h := New(&Options{ h := New(&Options{
Do: func(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { Do: func(ctx old_ctx.Context, client *http.Client, req *http.Request) (*http.Response, error) {
received = true received = true
body, err := ioutil.ReadAll(req.Body) body, err := ioutil.ReadAll(req.Body)
if err != nil { if err != nil {

View file

@ -14,6 +14,7 @@
package promql package promql
import ( import (
"context"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math" "math"
@ -23,7 +24,6 @@ import (
"time" "time"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage"

View file

@ -17,6 +17,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"context"
"fmt" "fmt"
"io" "io"
"math" "math"
@ -29,9 +30,7 @@ import (
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/version" "github.com/prometheus/common/version"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"

View file

@ -15,6 +15,7 @@ package retrieval
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -30,7 +31,6 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"

View file

@ -14,11 +14,11 @@
package retrieval package retrieval
import ( import (
"context"
"sync" "sync"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/discovery" "github.com/prometheus/prometheus/discovery"

View file

@ -14,17 +14,16 @@
package rules package rules
import ( import (
"context"
"fmt" "fmt"
"net/url" "net/url"
"sync" "sync"
"time" "time"
yaml "gopkg.in/yaml.v2"
"golang.org/x/net/context"
html_template "html/template" html_template "html/template"
yaml "gopkg.in/yaml.v2"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"

View file

@ -14,6 +14,7 @@
package rules package rules
import ( import (
"context"
"errors" "errors"
"fmt" "fmt"
"math" "math"
@ -28,7 +29,6 @@ import (
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/notifier" "github.com/prometheus/prometheus/notifier"

View file

@ -14,6 +14,7 @@
package rules package rules
import ( import (
"context"
"fmt" "fmt"
"html/template" "html/template"
"net/url" "net/url"
@ -21,8 +22,6 @@ import (
yaml "gopkg.in/yaml.v2" yaml "gopkg.in/yaml.v2"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/rulefmt" "github.com/prometheus/prometheus/pkg/rulefmt"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"

View file

@ -14,12 +14,11 @@
package rules package rules
import ( import (
"context"
"reflect" "reflect"
"testing" "testing"
"time" "time"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"

View file

@ -16,6 +16,7 @@ package remote
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"context"
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
@ -24,10 +25,9 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"github.com/golang/snappy" "github.com/golang/snappy"
"golang.org/x/net/context" "github.com/prometheus/common/model"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/util/httputil" "github.com/prometheus/prometheus/util/httputil"

View file

@ -15,6 +15,7 @@ package template
import ( import (
"bytes" "bytes"
"context"
"errors" "errors"
"fmt" "fmt"
"math" "math"
@ -28,9 +29,8 @@ import (
text_template "text/template" text_template "text/template"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/util/strutil" "github.com/prometheus/prometheus/util/strutil"
) )

View file

@ -14,13 +14,13 @@
package template package template
import ( import (
"context"
"math" "math"
"net/url" "net/url"
"testing" "testing"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"

View file

@ -14,6 +14,7 @@
package v1 package v1
import ( import (
"context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -26,7 +27,6 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/route" "github.com/prometheus/common/route"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"

View file

@ -14,6 +14,7 @@
package v1 package v1
import ( import (
"context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -27,7 +28,6 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/route" "github.com/prometheus/common/route"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"

View file

@ -14,7 +14,7 @@
package api_v2 package api_v2
import ( import (
native_context "context" "context"
"fmt" "fmt"
"math" "math"
"math/rand" "math/rand"
@ -24,7 +24,7 @@ import (
"path/filepath" "path/filepath"
"time" "time"
"golang.org/x/net/context" old_ctx "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
@ -33,14 +33,15 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/protoutil" "github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/tsdb"
tsdbLabels "github.com/prometheus/tsdb/labels"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/pkg/timestamp"
pb "github.com/prometheus/prometheus/prompb" pb "github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/retrieval" "github.com/prometheus/prometheus/retrieval"
"github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage"
"github.com/prometheus/tsdb"
tsdbLabels "github.com/prometheus/tsdb/labels"
) )
// API encapsulates all API services. // API encapsulates all API services.
@ -48,7 +49,7 @@ type API struct {
enableAdmin bool enableAdmin bool
now func() time.Time now func() time.Time
db func() *tsdb.DB db func() *tsdb.DB
q func(ctx native_context.Context, mint, maxt int64) (storage.Querier, error) q func(ctx context.Context, mint, maxt int64) (storage.Querier, error)
targets func() []*retrieval.Target targets func() []*retrieval.Target
alertmanagers func() []*url.URL alertmanagers func() []*url.URL
} }
@ -58,7 +59,7 @@ func New(
now func() time.Time, now func() time.Time,
db func() *tsdb.DB, db func() *tsdb.DB,
qe *promql.Engine, qe *promql.Engine,
q func(ctx native_context.Context, mint, maxt int64) (storage.Querier, error), q func(ctx context.Context, mint, maxt int64) (storage.Querier, error),
targets func() []*retrieval.Target, targets func() []*retrieval.Target,
alertmanagers func() []*url.URL, alertmanagers func() []*url.URL,
enableAdmin bool, enableAdmin bool,
@ -139,12 +140,12 @@ type adminDisabled struct {
} }
// TSDBSnapshot implements pb.AdminServer. // TSDBSnapshot implements pb.AdminServer.
func (s *adminDisabled) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) { func (s *adminDisabled) TSDBSnapshot(_ old_ctx.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
return nil, status.Error(codes.Unavailable, "Admin APIs are disabled") return nil, status.Error(codes.Unavailable, "Admin APIs are disabled")
} }
// DeleteSeries imeplements pb.AdminServer. // DeleteSeries imeplements pb.AdminServer.
func (s *adminDisabled) DeleteSeries(_ context.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) { func (s *adminDisabled) DeleteSeries(_ old_ctx.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
return nil, status.Error(codes.Unavailable, "Admin APIs are disabled") return nil, status.Error(codes.Unavailable, "Admin APIs are disabled")
} }
@ -161,7 +162,7 @@ func NewAdmin(db func() *tsdb.DB) *Admin {
} }
// TSDBSnapshot implements pb.AdminServer. // TSDBSnapshot implements pb.AdminServer.
func (s *Admin) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) { func (s *Admin) TSDBSnapshot(_ old_ctx.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
db := s.db() db := s.db()
if db == nil { if db == nil {
return nil, status.Errorf(codes.Unavailable, "TSDB not ready") return nil, status.Errorf(codes.Unavailable, "TSDB not ready")
@ -181,7 +182,7 @@ func (s *Admin) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.
} }
// DeleteSeries implements pb.AdminServer. // DeleteSeries implements pb.AdminServer.
func (s *Admin) DeleteSeries(_ context.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) { func (s *Admin) DeleteSeries(_ old_ctx.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
mint, maxt, err := extractTimeRange(r.MinTime, r.MaxTime) mint, maxt, err := extractTimeRange(r.MinTime, r.MaxTime)
if err != nil { if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error()) return nil, status.Error(codes.InvalidArgument, err.Error())

View file

@ -15,6 +15,7 @@ package web
import ( import (
"bytes" "bytes"
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
@ -41,23 +42,22 @@ import (
"github.com/cockroachdb/cmux" "github.com/cockroachdb/cmux"
"github.com/go-kit/kit/log" "github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level" "github.com/go-kit/kit/log/level"
"github.com/mwitkow/go-conntrack"
"github.com/opentracing-contrib/go-stdlib/nethttp" "github.com/opentracing-contrib/go-stdlib/nethttp"
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/route" "github.com/prometheus/common/route"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/tsdb" "github.com/prometheus/tsdb"
"golang.org/x/net/context"
"golang.org/x/net/netutil" "golang.org/x/net/netutil"
"github.com/mwitkow/go-conntrack"
"github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/notifier" "github.com/prometheus/prometheus/notifier"
"github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/retrieval" "github.com/prometheus/prometheus/retrieval"
"github.com/prometheus/prometheus/rules" "github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/template" "github.com/prometheus/prometheus/template"
"github.com/prometheus/prometheus/util/httputil" "github.com/prometheus/prometheus/util/httputil"
api_v1 "github.com/prometheus/prometheus/web/api/v1" api_v1 "github.com/prometheus/prometheus/web/api/v1"