Skip to content

Commit

Permalink
Move otlpmetrics Client to an internal package. (#3486)
Browse files Browse the repository at this point in the history
* Move otlp client to an internal package

* update changelog

* Apply suggestions from code review

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
  • Loading branch information
MadVikingGod and MrAlias committed Nov 23, 2022
1 parent c4333a9 commit e36a361
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -53,6 +53,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Do not report empty partial-success responses in the `go.opentelemetry.io/otel/exporters/otlp` exporters. (#3438, #3432)
- Handle partial success responses in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` exporters. (#3162, #3440)

## Removed

- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.Client` interface is removed. (#3486)
- The `go.opentelemetry.io/otel/exporters/otlp/otlpmetric.New` function is removed. Use the `otlpmetric[http|grpc].New` directly. (#3486)

### Deprecated

- The `go.opentelemetry.io/otel/sdk/metric/view` package is deprecated.
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"

import (
"context"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"

import (
"context"
Expand Down
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package otlpmetric // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
package internal // import "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"

import (
"context"
Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/otlpmetric/internal/otest/client.go
Expand Up @@ -26,7 +26,7 @@ import (
"google.golang.org/protobuf/proto"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/metric/unit"
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
collpb "go.opentelemetry.io/proto/otlp/collector/metrics/v1"
Expand Down Expand Up @@ -168,13 +168,13 @@ var (
)

// ClientFactory is a function that when called returns a
// otlpmetric.Client implementation that is connected to also returned
// internal.Client implementation that is connected to also returned
// Collector implementation. The Client is ready to upload metric data to the
// Collector which is ready to store that data.
//
// If resultCh is not nil, the returned Collector needs to use the responses
// from that channel to send back to the client for every export request.
type ClientFactory func(resultCh <-chan ExportResult) (otlpmetric.Client, Collector)
type ClientFactory func(resultCh <-chan ExportResult) (internal.Client, Collector)

// RunClientTests runs a suite of Client integration tests. For example:
//
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/internal/otest/client_test.go
Expand Up @@ -20,7 +20,7 @@ import (

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
Expand Down Expand Up @@ -67,7 +67,7 @@ func (c *client) ForceFlush(ctx context.Context) error { return ctx.Err() }
func (c *client) Shutdown(ctx context.Context) error { return ctx.Err() }

func TestClientTests(t *testing.T) {
factory := func(rCh <-chan ExportResult) (otlpmetric.Client, Collector) {
factory := func(rCh <-chan ExportResult) (ominternal.Client, Collector) {
c := &client{rCh: rCh, storage: NewStorage()}
return c, c
}
Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/client.go
Expand Up @@ -27,7 +27,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/internal"
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/oconf"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
Expand All @@ -49,7 +49,7 @@ func New(ctx context.Context, options ...Option) (metric.Exporter, error) {
if err != nil {
return nil, err
}
return otlpmetric.New(c), nil
return ominternal.New(c), nil
}

type client struct {
Expand All @@ -70,7 +70,7 @@ type client struct {
}

// newClient creates a new gRPC metric client.
func newClient(ctx context.Context, options ...Option) (otlpmetric.Client, error) {
func newClient(ctx context.Context, options ...Option) (ominternal.Client, error) {
cfg := oconf.NewGRPCConfig(asGRPCOptions(options)...)

c := &client{
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go
Expand Up @@ -27,7 +27,7 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/durationpb"

"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otest"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestRetryable(t *testing.T) {
}

func TestClient(t *testing.T) {
factory := func(rCh <-chan otest.ExportResult) (otlpmetric.Client, otest.Collector) {
factory := func(rCh <-chan otest.ExportResult) (ominternal.Client, otest.Collector) {
coll, err := otest.NewGRPCCollector("", rCh)
require.NoError(t, err)

Expand Down
6 changes: 3 additions & 3 deletions exporters/otlp/otlpmetric/otlpmetrichttp/client.go
Expand Up @@ -32,7 +32,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/internal"
"go.opentelemetry.io/otel/exporters/otlp/internal/retry"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/oconf"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/aggregation"
Expand All @@ -49,7 +49,7 @@ func New(_ context.Context, opts ...Option) (metric.Exporter, error) {
if err != nil {
return nil, err
}
return otlpmetric.New(c), nil
return ominternal.New(c), nil
}

type client struct {
Expand Down Expand Up @@ -81,7 +81,7 @@ var ourTransport = &http.Transport{
}

// newClient creates a new HTTP metric client.
func newClient(opts ...Option) (otlpmetric.Client, error) {
func newClient(opts ...Option) (ominternal.Client, error) {
cfg := oconf.NewHTTPConfig(asHTTPOptions(opts)...)

httpClient := &http.Client{
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetrichttp/client_test.go
Expand Up @@ -27,14 +27,14 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
ominternal "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/internal/otest"
"go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/metric/metricdata"
)

func TestClient(t *testing.T) {
factory := func(rCh <-chan otest.ExportResult) (otlpmetric.Client, otest.Collector) {
factory := func(rCh <-chan otest.ExportResult) (ominternal.Client, otest.Collector) {
coll, err := otest.NewHTTPCollector("", rCh)
require.NoError(t, err)

Expand Down

0 comments on commit e36a361

Please sign in to comment.