Skip to content

Commit

Permalink
[chore] [exporter/signalfx] Remove setting of sampled logger (#27448)
Browse files Browse the repository at this point in the history
The original logger is now sampled by default after
open-telemetry/opentelemetry-collector#8134
  • Loading branch information
dmitryax authored Oct 5, 2023
1 parent 09b6221 commit f3851d8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
3 changes: 1 addition & 2 deletions exporter/signalfxexporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ func newSignalFxExporter(
return nil, err
}

sampledLogger := translation.CreateSampledLogger(createSettings.Logger)
converter, err := translation.NewMetricsConverter(
sampledLogger,
createSettings.TelemetrySettings.Logger,
metricTranslator,
config.ExcludeMetrics,
config.IncludeMetrics,
Expand Down
24 changes: 1 addition & 23 deletions exporter/signalfxexporter/internal/translation/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ package translation // import "github.com/open-telemetry/opentelemetry-collector
import (
"fmt"
"strings"
"time"
"unicode"

sfxpb "github.com/signalfx/com_signalfx_metrics_protobuf/model"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/translation/dpfilters"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk"
Expand Down Expand Up @@ -184,7 +182,7 @@ type datapointValidator struct {
}

func newDatapointValidator(logger *zap.Logger, nonAlphanumericDimChars string) *datapointValidator {
return &datapointValidator{logger: CreateSampledLogger(logger), nonAlphanumericDimChars: nonAlphanumericDimChars}
return &datapointValidator{logger: logger, nonAlphanumericDimChars: nonAlphanumericDimChars}
}

// sanitizeDataPoints sanitizes datapoints prior to dispatching them to the backend.
Expand Down Expand Up @@ -277,23 +275,3 @@ func (dpv *datapointValidator) isValidDimensionValue(value, name string) bool {
}
return true
}

// CreateSampledLogger was copied from https://github.com/open-telemetry/opentelemetry-collector/blob/v0.26.0/exporter/exporterhelper/queued_retry.go#L108
func CreateSampledLogger(logger *zap.Logger) *zap.Logger {
if logger.Core().Enabled(zapcore.DebugLevel) {
// Debugging is enabled. Don't do any sampling.
return logger
}

// Create a logger that samples all messages to 1 per 10 seconds initially,
// and 1/10000 of messages after that.
opts := zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewSamplerWithOptions(
core,
10*time.Second,
1,
10000,
)
})
return logger.WithOptions(opts)
}

0 comments on commit f3851d8

Please sign in to comment.