Skip to content

Commit

Permalink
all: update zlog and corresponding otel packages
Browse files Browse the repository at this point in the history
Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay committed Feb 16, 2022
1 parent 45fae9f commit 128b27b
Show file tree
Hide file tree
Showing 18 changed files with 199 additions and 264 deletions.
4 changes: 1 addition & 3 deletions cmd/clair/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/quay/clair/config"
_ "github.com/quay/claircore/updater/defaults"
"github.com/quay/zlog"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"
"golang.org/x/sync/errgroup"
yaml "gopkg.in/yaml.v3"

Expand Down Expand Up @@ -75,7 +73,7 @@ func main() {
if err := initialize.Logging(ctx, &conf); err != nil {
golog.Fatalf("failed to set up logging: %v", err)
}
ctx = baggage.ContextWithValues(ctx, label.String("component", "main"))
ctx = zlog.ContextWithValues(ctx, "component", "main")
zlog.Info(ctx).
Str("version", Version).
Msg("starting")
Expand Down
6 changes: 2 additions & 4 deletions cmd/clairctl/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"github.com/quay/claircore"
"github.com/quay/zlog"
"github.com/urfave/cli/v2"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"
"golang.org/x/sync/errgroup"

"github.com/quay/clair/v4/internal/codec"
Expand Down Expand Up @@ -165,7 +163,7 @@ func reportAction(c *cli.Context) error {

for i := 0; i < args.Len(); i++ {
ref := args.Get(i)
ctx := baggage.ContextWithValues(ctx, label.String("ref", ref))
ctx := zlog.ContextWithValues(ctx, "ref", ref)
zlog.Debug(ctx).
Msg("fetching")
eg.Go(func() error {
Expand All @@ -176,7 +174,7 @@ func reportAction(c *cli.Context) error {
Send()
return err
}
ctx := baggage.ContextWithValues(ctx, label.Stringer("digest", d))
ctx := zlog.ContextWithValues(ctx, "digest", d.String())
zlog.Debug(ctx).
Msg("found manifest")

Expand Down
21 changes: 11 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/go-stomp/stomp v2.0.6+incompatible
github.com/google/go-cmp v0.5.6
github.com/google/go-cmp v0.5.7
github.com/google/go-containerregistry v0.6.0
github.com/google/uuid v1.2.0
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79
Expand All @@ -14,21 +14,22 @@ require (
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/prometheus/client_golang v1.9.0
github.com/quay/clair/config v1.0.0
github.com/quay/claircore v1.2.0
github.com/quay/zlog v0.0.0-20210113185248-ce16eed1dcec
github.com/quay/claircore v1.3.0
github.com/quay/zlog v1.1.0
github.com/remind101/migrate v0.0.0-20170729031349-52c1edff7319
github.com/rs/zerolog v1.26.0
github.com/streadway/amqp v1.0.0
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
github.com/ugorji/go/codec v1.2.4
github.com/urfave/cli/v2 v2.3.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.16.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0
go.opentelemetry.io/otel v0.16.0
go.opentelemetry.io/otel/exporters/stdout v0.16.0
go.opentelemetry.io/otel/exporters/trace/jaeger v0.16.0
go.opentelemetry.io/otel/sdk v0.16.0
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.29.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.29.0
go.opentelemetry.io/otel v1.4.0
go.opentelemetry.io/otel/exporters/jaeger v1.4.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.4.0
go.opentelemetry.io/otel/sdk v1.4.0
go.opentelemetry.io/otel/trace v1.4.0
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
gopkg.in/square/go-jose.v2 v2.5.1
Expand Down
84 changes: 52 additions & 32 deletions go.sum

Large diffs are not rendered by default.

10 changes: 2 additions & 8 deletions httptransport/notificationshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/google/uuid"
je "github.com/quay/claircore/pkg/jsonerr"
"github.com/quay/zlog"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"

"github.com/quay/clair/v4/internal/codec"
"github.com/quay/clair/v4/notifier"
Expand Down Expand Up @@ -52,9 +50,7 @@ func (h *NotifHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

func (h *NotifHandler) Delete(w http.ResponseWriter, r *http.Request) {
ctx := baggage.ContextWithValues(r.Context(),
label.String("component", "httptransport/NotifHander.Delete"),
)
ctx := zlog.ContextWithValues(r.Context(), "component", "httptransport/NotifHander.Delete")
path := r.URL.Path
id := filepath.Base(path)
notificationID, err := uuid.Parse(id)
Expand All @@ -81,9 +77,7 @@ func (h *NotifHandler) Delete(w http.ResponseWriter, r *http.Request) {

// Get will return paginated notifications to the caller.
func (h *NotifHandler) Get(w http.ResponseWriter, r *http.Request) {
ctx := baggage.ContextWithValues(r.Context(),
label.String("component", "httptransport/NotifHander.Get"),
)
ctx := zlog.ContextWithValues(r.Context(), "component", "httptransport/NotifHander.Get")
path := r.URL.Path
id := filepath.Base(path)
notificationID, err := uuid.Parse(id)
Expand Down
6 changes: 1 addition & 5 deletions httptransport/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/quay/zlog"
othttp "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"
"golang.org/x/sync/semaphore"

clairerror "github.com/quay/clair/v4/clair-error"
Expand Down Expand Up @@ -72,9 +70,7 @@ func New(ctx context.Context, conf config.Config, indexer indexer.Service, match
notifier: notifier,
traceOpt: othttp.WithTracerProvider(otel.GetTracerProvider()),
}
ctx = baggage.ContextWithValues(ctx,
label.String("component", "httptransport/New"),
)
ctx = zlog.ContextWithValues(ctx, "component", "httptransport/New")

if err := t.configureDiscovery(ctx); err != nil {
zlog.Warn(ctx).Err(err).Msg("configuring openapi discovery failed")
Expand Down
10 changes: 2 additions & 8 deletions httptransport/updateoperationhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/quay/claircore/libvuln/driver"
je "github.com/quay/claircore/pkg/jsonerr"
"github.com/quay/zlog"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"

"github.com/quay/clair/v4/internal/codec"
"github.com/quay/clair/v4/matcher"
Expand Down Expand Up @@ -58,9 +56,7 @@ func (h *UOHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Clients may provide an 'If-None-Match' header with the etag value to receive
// a StatusNotModified when no new UpdateOperations have been created.
func (h *UOHandler) Get(w http.ResponseWriter, r *http.Request) {
ctx := baggage.ContextWithValues(r.Context(),
label.String("component", "httptransport/UOHandler.Get"),
)
ctx := zlog.ContextWithValues(r.Context(), "component", "httptransport/UOHandler.Get")

kind := driver.VulnerabilityKind
switch k := r.URL.Query().Get("kind"); k {
Expand Down Expand Up @@ -112,9 +108,7 @@ func (h *UOHandler) Get(w http.ResponseWriter, r *http.Request) {

// Delete removes an UpdateOperation models from the system.
func (h *UOHandler) Delete(w http.ResponseWriter, r *http.Request) {
ctx := baggage.ContextWithValues(r.Context(),
label.String("component", "httptransport/UOHandler.Delete"),
)
ctx := zlog.ContextWithValues(r.Context(), "component", "httptransport/UOHandler.Delete")
path := r.URL.Path
id := filepath.Base(path)
uuid, err := uuid.Parse(id)
Expand Down
6 changes: 1 addition & 5 deletions initialize/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
"github.com/quay/claircore/libvuln"
"github.com/quay/claircore/libvuln/driver"
"github.com/quay/zlog"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"
"golang.org/x/net/publicsuffix"
"gopkg.in/square/go-jose.v2/jwt"

Expand Down Expand Up @@ -53,9 +51,7 @@ type Srv struct {
// Services configures the services needed for a given mode according to the
// provided configuration.
func Services(ctx context.Context, cfg *config.Config) (*Srv, error) {
ctx = baggage.ContextWithValues(ctx,
label.String("component", "initialize/Services"),
)
ctx = zlog.ContextWithValues(ctx, "component", "initialize/Services")
zlog.Info(ctx).Msg("begin service initialization")
defer zlog.Info(ctx).Msg("end service initialization")

Expand Down

0 comments on commit 128b27b

Please sign in to comment.