Add no_tracing tag

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko 2022-03-31 14:37:11 -07:00
parent 887615c7d0
commit 0b2a95e107
4 changed files with 29 additions and 7 deletions

View File

@ -36,5 +36,4 @@ import (
_ "github.com/containerd/containerd/services/snapshots" _ "github.com/containerd/containerd/services/snapshots"
_ "github.com/containerd/containerd/services/tasks" _ "github.com/containerd/containerd/services/tasks"
_ "github.com/containerd/containerd/services/version" _ "github.com/containerd/containerd/services/version"
_ "github.com/containerd/containerd/tracing/plugin"
) )

View File

@ -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"
)

View File

@ -35,7 +35,6 @@ import (
"github.com/containerd/containerd/services/server" "github.com/containerd/containerd/services/server"
srvconfig "github.com/containerd/containerd/services/server/config" srvconfig "github.com/containerd/containerd/services/server/config"
"github.com/containerd/containerd/sys" "github.com/containerd/containerd/sys"
"github.com/containerd/containerd/tracing"
"github.com/containerd/containerd/version" "github.com/containerd/containerd/version"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -302,7 +301,6 @@ func applyFlags(context *cli.Context, config *srvconfig.Config) error {
if err := setLogFormat(config); err != nil { if err := setLogFormat(config); err != nil {
return err return err
} }
setLogHooks()
for _, v := range []struct { for _, v := range []struct {
name string name string
@ -369,10 +367,6 @@ func setLogFormat(config *srvconfig.Config) error {
return nil return nil
} }
func setLogHooks() {
logrus.StandardLogger().AddHook(tracing.NewLogrusHook())
}
func dumpStacks(writeToFile bool) { func dumpStacks(writeToFile bool) {
var ( var (
buf []byte buf []byte

View File

@ -25,6 +25,8 @@ import (
"github.com/containerd/containerd/log" "github.com/containerd/containerd/log"
"github.com/containerd/containerd/plugin" "github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/tracing"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel" "go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace" "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
@ -59,6 +61,9 @@ func init() {
return newTracer(ic) return newTracer(ic)
}, },
}) })
// Register logging hook for tracing
logrus.StandardLogger().AddHook(tracing.NewLogrusHook())
} }
// OTLPConfig holds the configurations for the built-in otlp span processor // OTLPConfig holds the configurations for the built-in otlp span processor