Skip to content

Commit

Permalink
change UploadMetrics signature from slice to single Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
hanyuancheung committed Jan 2, 2022
1 parent 4769bbe commit ab55912
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/clients.go
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
}
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/exporter_test.go
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}...)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/otlpmetric/otlpmetricgrpc/client.go
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
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

0 comments on commit ab55912

Please sign in to comment.