Skip to content

Commit

Permalink
use less aggressive trace element disabling for release v1.13.1-rc.4
Browse files Browse the repository at this point in the history
Signed-off-by: denis-tingaikin <[email protected]>
  • Loading branch information
denis-tingaikin committed Sep 17, 2024
1 parent 38bce48 commit dcfb9f0
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 22 deletions.
14 changes: 9 additions & 5 deletions pkg/networkservice/core/chain/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020 Cisco Systems, Inc.
//
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,11 +23,15 @@ import (

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/trace"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// NewNetworkServiceClient - chains together a list of networkservice.NetworkServiceClient with tracing
func NewNetworkServiceClient(clients ...networkservice.NetworkServiceClient) networkservice.NetworkServiceClient {
return next.NewNetworkServiceClient(
next.NewWrappedNetworkServiceClient(trace.NewNetworkServiceClient, clients...),
)
if opentelemetry.IsEnabled() {
return next.NewNetworkServiceClient(
next.NewWrappedNetworkServiceClient(trace.NewNetworkServiceClient, clients...),
)
}
return next.NewNetworkServiceClient(clients...)
}
14 changes: 9 additions & 5 deletions pkg/networkservice/core/chain/server.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020 Cisco Systems, Inc.
//
// Copyright (c) 2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,11 +25,15 @@ import (

"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/trace"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// NewNetworkServiceServer - chains together a list of networkservice.Servers with tracing
func NewNetworkServiceServer(servers ...networkservice.NetworkServiceServer) networkservice.NetworkServiceServer {
return next.NewNetworkServiceServer(
next.NewWrappedNetworkServiceServer(trace.NewNetworkServiceServer, servers...),
)
if opentelemetry.IsEnabled() {
return next.NewNetworkServiceServer(
next.NewWrappedNetworkServiceServer(trace.NewNetworkServiceServer, servers...),
)
}
return next.NewNetworkServiceServer(servers...)
}
3 changes: 3 additions & 0 deletions pkg/networkservice/core/trace/traceconcise/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package traceconcise_test
import (
"bytes"
"context"
"os"
"testing"

"github.com/sirupsen/logrus"
Expand All @@ -34,6 +35,7 @@ import (
)

func TestOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
// Configure logging
// Set output to buffer
var buff bytes.Buffer
Expand Down Expand Up @@ -76,6 +78,7 @@ func TestOutput(t *testing.T) {
}

func TestErrorOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
// Configure logging
// Set output to buffer
var buff bytes.Buffer
Expand Down
3 changes: 3 additions & 0 deletions pkg/networkservice/core/trace/traceverbose/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"bytes"
"context"
"encoding/json"
"os"

"testing"

Expand Down Expand Up @@ -104,6 +105,7 @@ func TestDiffPathAdd(t *testing.T) {
}

func TestTraceOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
// Configure logging
// Set output to buffer
var buff bytes.Buffer
Expand Down Expand Up @@ -159,6 +161,7 @@ func TestTraceOutput(t *testing.T) {
}

func TestErrorOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
// Configure logging
// Set output to buffer
var buff bytes.Buffer
Expand Down
15 changes: 11 additions & 4 deletions pkg/registry/core/chain/ns_registry.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2023 Cisco Systems, Inc.
//
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -23,14 +23,21 @@ import (

"github.com/networkservicemesh/sdk/pkg/registry/core/next"
"github.com/networkservicemesh/sdk/pkg/registry/core/trace"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// NewNetworkServiceRegistryServer - creates a chain of servers
func NewNetworkServiceRegistryServer(servers ...registry.NetworkServiceRegistryServer) registry.NetworkServiceRegistryServer {
return next.NewWrappedNetworkServiceRegistryServer(trace.NewNetworkServiceRegistryServer, servers...)
if opentelemetry.IsEnabled() {
return next.NewWrappedNetworkServiceRegistryServer(trace.NewNetworkServiceRegistryServer, servers...)
}
return next.NewNetworkServiceRegistryServer(servers...)
}

// NewNetworkServiceRegistryClient - creates a chain of clients
func NewNetworkServiceRegistryClient(clients ...registry.NetworkServiceRegistryClient) registry.NetworkServiceRegistryClient {
return next.NewWrappedNetworkServiceRegistryClient(trace.NewNetworkServiceRegistryClient, clients...)
if opentelemetry.IsEnabled() {
return next.NewWrappedNetworkServiceRegistryClient(trace.NewNetworkServiceRegistryClient, clients...)
}
return next.NewNetworkServiceRegistryClient(clients...)
}
15 changes: 11 additions & 4 deletions pkg/registry/core/chain/nse_registry.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) 2020-2023 Cisco Systems, Inc.
//
// Copyright (c) 2020-2023 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,14 +24,21 @@ import (

"github.com/networkservicemesh/sdk/pkg/registry/core/next"
"github.com/networkservicemesh/sdk/pkg/registry/core/trace"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// NewNetworkServiceEndpointRegistryServer - creates a chain of servers
func NewNetworkServiceEndpointRegistryServer(servers ...registry.NetworkServiceEndpointRegistryServer) registry.NetworkServiceEndpointRegistryServer {
return next.NewWrappedNetworkServiceEndpointRegistryServer(trace.NewNetworkServiceEndpointRegistryServer, servers...)
if opentelemetry.IsEnabled() {
return next.NewWrappedNetworkServiceEndpointRegistryServer(trace.NewNetworkServiceEndpointRegistryServer, servers...)
}
return next.NewNetworkServiceEndpointRegistryServer(servers...)
}

// NewNetworkServiceEndpointRegistryClient - creates a chain of clients
func NewNetworkServiceEndpointRegistryClient(clients ...registry.NetworkServiceEndpointRegistryClient) registry.NetworkServiceEndpointRegistryClient {
return next.NewWrappedNetworkServiceEndpointRegistryClient(trace.NewNetworkServiceEndpointRegistryClient, clients...)
if opentelemetry.IsEnabled() {
return next.NewWrappedNetworkServiceEndpointRegistryClient(trace.NewNetworkServiceEndpointRegistryClient, clients...)
}
return next.NewNetworkServiceEndpointRegistryClient(clients...)
}
3 changes: 3 additions & 0 deletions pkg/registry/core/trace/traceconcise/traceconcise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package traceconcise_test
import (
"bytes"
"context"
"os"
"testing"

"github.com/networkservicemesh/api/pkg/api/registry"
Expand All @@ -41,6 +42,7 @@ import (
)

func TestOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
t.Cleanup(func() { goleak.VerifyNone(t) })

var buff bytes.Buffer
Expand Down Expand Up @@ -89,6 +91,7 @@ func TestOutput(t *testing.T) {
}

func TestErrorOutput(t *testing.T) {
_ = os.Setenv("TELEMETRY", "true")
t.Cleanup(func() { goleak.VerifyNone(t) })

var buff bytes.Buffer
Expand Down
12 changes: 8 additions & 4 deletions pkg/tools/dnsutils/chain/server.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2022 Cisco Systems, Inc.
// Copyright (c) 2022-2024 Cisco Systems, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -21,11 +21,15 @@ import (
"github.com/networkservicemesh/sdk/pkg/tools/dnsutils"
"github.com/networkservicemesh/sdk/pkg/tools/dnsutils/next"
"github.com/networkservicemesh/sdk/pkg/tools/dnsutils/trace"
"github.com/networkservicemesh/sdk/pkg/tools/opentelemetry"
)

// NewDNSHandler - chains together a list of dnsutils.Handler with tracing
func NewDNSHandler(handlers ...dnsutils.Handler) dnsutils.Handler {
return next.NewDNSHandler(
next.NewWrappedDNSHandler(trace.NewDNSHandler, handlers...),
)
if opentelemetry.IsEnabled() {
return next.NewDNSHandler(
next.NewWrappedDNSHandler(trace.NewDNSHandler, handlers...),
)
}
return next.NewDNSHandler(handlers...)
}

0 comments on commit dcfb9f0

Please sign in to comment.