Skip to content

Commit

Permalink
updated based on feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
  • Loading branch information
codeboten committed Oct 16, 2024
1 parent d5c74f1 commit bbe69b3
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions config/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,28 +297,6 @@ func newIncludeExcludeFilter(lists *IncludeExclude) (attribute.Filter, error) {
}, nil
}

func prometheusReaderOpts(prometheusConfig *Prometheus) ([]otelprom.Option, error) {
var opts []otelprom.Option
if prometheusConfig.WithoutScopeInfo != nil && *prometheusConfig.WithoutScopeInfo {
opts = append(opts, otelprom.WithoutScopeInfo())
}
if prometheusConfig.WithoutTypeSuffix != nil && *prometheusConfig.WithoutTypeSuffix {
opts = append(opts, otelprom.WithoutCounterSuffixes())
}
if prometheusConfig.WithoutUnits != nil && *prometheusConfig.WithoutUnits {
opts = append(opts, otelprom.WithoutUnits())
}
if prometheusConfig.WithResourceConstantLabels != nil {
f, err := newIncludeExcludeFilter(prometheusConfig.WithResourceConstantLabels)
if err != nil {
return nil, err
}
opts = append(opts, otelprom.WithResourceAsConstantLabels(f))
}

return opts, nil
}

func prometheusReader(ctx context.Context, prometheusConfig *Prometheus) (sdkmetric.Reader, error) {
if prometheusConfig.Host == nil {
return nil, fmt.Errorf("host must be specified")
Expand Down Expand Up @@ -368,6 +346,28 @@ func prometheusReader(ctx context.Context, prometheusConfig *Prometheus) (sdkmet
return readerWithServer{reader, &server}, nil
}

func prometheusReaderOpts(prometheusConfig *Prometheus) ([]otelprom.Option, error) {
var opts []otelprom.Option
if prometheusConfig.WithoutScopeInfo != nil && *prometheusConfig.WithoutScopeInfo {
opts = append(opts, otelprom.WithoutScopeInfo())
}
if prometheusConfig.WithoutTypeSuffix != nil && *prometheusConfig.WithoutTypeSuffix {
opts = append(opts, otelprom.WithoutCounterSuffixes())
}
if prometheusConfig.WithoutUnits != nil && *prometheusConfig.WithoutUnits {
opts = append(opts, otelprom.WithoutUnits())
}
if prometheusConfig.WithResourceConstantLabels != nil {
f, err := newIncludeExcludeFilter(prometheusConfig.WithResourceConstantLabels)
if err != nil {
return nil, err

Check warning on line 363 in config/metric.go

View check run for this annotation

Codecov / codecov/patch

config/metric.go#L363

Added line #L363 was not covered by tests
}
opts = append(opts, otelprom.WithResourceAsConstantLabels(f))
}

return opts, nil
}

type readerWithServer struct {
sdkmetric.Reader
server *http.Server
Expand Down

0 comments on commit bbe69b3

Please sign in to comment.