Skip to content

Commit

Permalink
allow sdk for prometheus and runtime at the golangci level
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Sep 23, 2024
1 parent 5e80ecc commit 52b38b6
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 75 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ linters-settings:
no-sdk-instrumentation:
files:
- "**/*/{bridges,instrumentation}/**/*.go"
- "!**/*/bridges/prometheus/*.go" # prometheus bridge is meant to use the SDK
- "!**/*/instrumentation/runtime/*.go" # runtime instrumentation is meant to use the SDK
- "!**/*test/*.go"
- "!**/*test/**/*.go"
- "!**/*example/*.go"
Expand Down
2 changes: 1 addition & 1 deletion bridges/prometheus/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package prometheus_test

import (
"go.opentelemetry.io/contrib/bridges/prometheus"
"go.opentelemetry.io/otel/sdk/metric" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric"
)

func ExampleNewMetricProducer() {
Expand Down
6 changes: 3 additions & 3 deletions bridges/prometheus/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/instrumentation" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric/metricdata" //nolint:depguard
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions bridges/prometheus/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/instrumentation" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric/metricdata" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" //nolint:depguard
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion instrumentation/runtime/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"go.opentelemetry.io/contrib/instrumentation/runtime"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/sdk/metric" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric"
)

func Example() {
Expand Down
6 changes: 3 additions & 3 deletions instrumentation/runtime/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"time"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/instrumentation" //nolint:depguard // We rely on instrumentation.Scope.
"go.opentelemetry.io/otel/sdk/metric" //nolint:depguard // We rely on metric.Producer.
"go.opentelemetry.io/otel/sdk/metric/metricdata" // nolint:depguard // We rely on metricdata.
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

var startTime time.Time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

package test
package runtime // import "go.opentelemetry.io/contrib/instrumentation/runtime"

import (
"context"
Expand All @@ -10,15 +10,14 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/contrib/instrumentation/runtime"
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
)

func TestNewProducer(t *testing.T) {
reader := metric.NewManualReader(metric.WithProducer(runtime.NewProducer()))
reader := metric.NewManualReader(metric.WithProducer(NewProducer()))
_ = metric.NewMeterProvider(metric.WithReader(reader))
rm := metricdata.ResourceMetrics{}
err := reader.Collect(context.Background(), &rm)
Expand All @@ -29,7 +28,7 @@ func TestNewProducer(t *testing.T) {
expectedScopeMetric := metricdata.ScopeMetrics{
Scope: instrumentation.Scope{
Name: "go.opentelemetry.io/contrib/instrumentation/runtime",
Version: runtime.Version(),
Version: Version(),
},
Metrics: []metricdata.Metrics{
{
Expand Down
8 changes: 4 additions & 4 deletions instrumentation/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/sdk/instrumentation" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric/metricdata" //nolint:depguard
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest" //nolint:depguard
"go.opentelemetry.io/otel/sdk/instrumentation"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
"go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
)

func TestRefreshGoCollector(t *testing.T) {
Expand Down
23 changes: 0 additions & 23 deletions instrumentation/runtime/test/go.mod

This file was deleted.

33 changes: 0 additions & 33 deletions instrumentation/runtime/test/go.sum

This file was deleted.

0 comments on commit 52b38b6

Please sign in to comment.