Skip to content

Commit

Permalink
Replace use of golang.org/x/net/context with context
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskorn committed Aug 3, 2023
1 parent cf8bdc1 commit 2ea3a37
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 29 deletions.
2 changes: 1 addition & 1 deletion httpgrpc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package server

import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net"
Expand All @@ -17,7 +18,6 @@ import (
otgrpc "github.com/opentracing-contrib/go-grpc"
"github.com/opentracing/opentracing-go"
"github.com/sercand/kuberesolver/v4"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

Expand Down
19 changes: 0 additions & 19 deletions instrument/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/opentracing/opentracing-go/ext"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/prometheus/client_golang/prometheus"
oldcontext "golang.org/x/net/context"

"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/tracing"
Expand Down Expand Up @@ -189,21 +188,3 @@ func ErrorCode(err error) string {
}
return "500"
}

// TimeRequestHistogram runs 'f' and records how long it took in the given Prometheus
// histogram metric. If 'f' returns successfully, record a "200". Otherwise, record
// "500". It will also emit an OpenTracing span if you have a global tracer configured.
//
// Deprecated: Use CollectedRequest()
func TimeRequestHistogram(ctx oldcontext.Context, method string, metric *prometheus.HistogramVec, f func(context.Context) error) error {
return CollectedRequest(ctx, method, NewHistogramCollector(metric), ErrorCode, f)
}

// TimeRequestHistogramStatus runs 'f' and records how long it took in the given Prometheus
// histogram metric. If 'f' returns successfully, record a "200". Otherwise, record
// "500". It will also emit an OpenTracing span if you have a global tracer configured.
//
// Deprecated: Use CollectedRequest()
func TimeRequestHistogramStatus(ctx oldcontext.Context, method string, metric *prometheus.HistogramVec, toStatusCode func(error) string, f func(context.Context) error) error {
return CollectedRequest(ctx, method, NewHistogramCollector(metric), toStatusCode, f)
}
3 changes: 2 additions & 1 deletion middleware/grpc_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
package middleware

import (
"golang.org/x/net/context"
"context"

"google.golang.org/grpc"

"github.com/grafana/dskit/user"
Expand Down
2 changes: 1 addition & 1 deletion middleware/grpc_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
package middleware

import (
"context"
"errors"
"time"

"golang.org/x/net/context"
"google.golang.org/grpc"

grpcUtils "github.com/grafana/dskit/grpcutil"
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package server

import (
"context"
"crypto/tls"
"flag"
"fmt"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/exporter-toolkit/web"
"github.com/soheilhy/cmux"
"golang.org/x/net/context"
"golang.org/x/net/netutil"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package server

import (
"bytes"
"context"
"crypto/tls"
"crypto/x509"
"errors"
Expand All @@ -28,7 +29,6 @@ import (
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"

"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/log"
Expand Down
3 changes: 2 additions & 1 deletion user/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
package user

import (
"golang.org/x/net/context"
"context"

"google.golang.org/grpc/metadata"
)

Expand Down
3 changes: 1 addition & 2 deletions user/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
package user

import (
"context"
"net/http"

"golang.org/x/net/context"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion user/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package user

import (
"golang.org/x/net/context"
"context"

"github.com/grafana/dskit/errors"
)
Expand Down
2 changes: 1 addition & 1 deletion user/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package user

import (
"golang.org/x/net/context"
"context"

"github.com/grafana/dskit/log"
)
Expand Down

0 comments on commit 2ea3a37

Please sign in to comment.