Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change UploadMetrics signature from slice to single Resource #2491

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- Fixes the instrument kind for noop async instruments. (#2461)
- Change UploadMetrics signature from slice to single Resource. (#2491)
MrAlias marked this conversation as resolved.
Show resolved Hide resolved

## [1.3.0] - 2021-12-10

Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ type Client interface {
// UploadMetrics should transform the passed metrics to the
// wire format and send it to the collector. May be called
// concurrently.
UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error
UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error
}
3 changes: 1 addition & 2 deletions exporters/otlp/otlpmetric/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"go.opentelemetry.io/otel/sdk/metric/export"
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
"go.opentelemetry.io/otel/sdk/resource"
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
)

var (
Expand Down Expand Up @@ -57,7 +56,7 @@ func (e *Exporter) Export(ctx context.Context, res *resource.Resource, ilr expor
// call, as per the specification. We can change the
// signature of UploadMetrics correspondingly. Here create a
// singleton list to reduce the size of the current PR:
return e.client.UploadMetrics(ctx, []*metricpb.ResourceMetrics{rm})
return e.client.UploadMetrics(ctx, rm)
}

// Start establishes a connection to the receiving endpoint.
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (m *stubClient) Stop(ctx context.Context) error {
return nil
}

func (m *stubClient) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error {
m.rm = append(m.rm, protoMetrics...)
func (m *stubClient) UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error {
m.rm = append(m.rm, []*metricpb.ResourceMetrics{protoMetrics}...)
hanyuancheung marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ var errShutdown = errors.New("the client is shutdown")
//
// Retryable errors from the server will be handled according to any
// RetryConfig the client was created with.
func (c *client) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error {
func (c *client) UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error {
// Hold a read lock to ensure a shut down initiated after this starts does
// not abandon the export. This read lock acquire has less priority than a
// write lock acquire (i.e. Stop), meaning if the client is shutting down
Expand All @@ -197,7 +197,7 @@ func (c *client) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.Res

return c.requestFunc(ctx, func(iCtx context.Context) error {
_, err := c.msc.Export(iCtx, &colmetricpb.ExportMetricsServiceRequest{
ResourceMetrics: protoMetrics,
ResourceMetrics: []*metricpb.ResourceMetrics{protoMetrics},
})
// nil is converted to OK.
if status.Code(err) == codes.OK {
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetrichttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ func (d *client) Stop(ctx context.Context) error {
}

// UploadMetrics sends a batch of metrics to the collector.
func (d *client) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error {
func (d *client) UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error {
pbRequest := &colmetricpb.ExportMetricsServiceRequest{
ResourceMetrics: protoMetrics,
ResourceMetrics: []*metricpb.ResourceMetrics{protoMetrics},
}
rawRequest, err := proto.Marshal(pbRequest)
if err != nil {
Expand Down