Skip to content

Commit

Permalink
Merge pull request containerd#6750 from mxpv/tracing
Browse files Browse the repository at this point in the history
Add no_tracing tag
  • Loading branch information
dmcgowan authored Apr 4, 2022
2 parents 0f5c06b + 0b2a95e commit e079e4a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 0 additions & 1 deletion cmd/containerd/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ import (
_ "github.com/containerd/containerd/services/snapshots"
_ "github.com/containerd/containerd/services/tasks"
_ "github.com/containerd/containerd/services/version"
_ "github.com/containerd/containerd/tracing/plugin"
)
24 changes: 24 additions & 0 deletions cmd/containerd/builtins_tracing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build !no_tracing
// +build !no_tracing

/*
Copyright The containerd Authors.
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.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
_ "github.com/containerd/containerd/tracing/plugin"
)
6 changes: 0 additions & 6 deletions cmd/containerd/command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys"
"github.com/containerd/containerd/tracing"
"github.com/containerd/containerd/version"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -302,7 +301,6 @@ func applyFlags(context *cli.Context, config *srvconfig.Config) error {
if err := setLogFormat(config); err != nil {
return err
}
setLogHooks()

for _, v := range []struct {
name string
Expand Down Expand Up @@ -369,10 +367,6 @@ func setLogFormat(config *srvconfig.Config) error {
return nil
}

func setLogHooks() {
logrus.StandardLogger().AddHook(tracing.NewLogrusHook())
}

func dumpStacks(writeToFile bool) {
var (
buf []byte
Expand Down
5 changes: 5 additions & 0 deletions tracing/plugin/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (

"github.com/containerd/containerd/log"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/tracing"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
Expand Down Expand Up @@ -59,6 +61,9 @@ func init() {
return newTracer(ic)
},
})

// Register logging hook for tracing
logrus.StandardLogger().AddHook(tracing.NewLogrusHook())
}

// OTLPConfig holds the configurations for the built-in otlp span processor
Expand Down

0 comments on commit e079e4a

Please sign in to comment.