mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-04-23 11:58:56 +02:00
change UploadMetrics signature from slice to single Resource (#2491)
* change UploadMetrics signature from slice to single Resource * add changelog * fix otlp exporter bug. * Update exporters/otlp/otlpmetric/exporter_test.go Co-authored-by: Anthony Mirabella <a9@aneurysm9.com> * Update CHANGELOG.md Co-authored-by: Anthony Mirabella <a9@aneurysm9.com> Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
parent
776bfdcb23
commit
4b815ff70c
@ -21,6 +21,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixes the instrument kind for noop async instruments. (#2461)
|
- Fixes the instrument kind for noop async instruments. (#2461)
|
||||||
|
- Change the `otlpmetric.Client` interface's `UploadMetrics` method to accept a single `ResourceMetrics` instead of a slice of them. (#2491)
|
||||||
|
|
||||||
## [1.3.0] - 2021-12-10
|
## [1.3.0] - 2021-12-10
|
||||||
|
|
||||||
|
@ -39,5 +39,5 @@ type Client interface {
|
|||||||
// UploadMetrics should transform the passed metrics to the
|
// UploadMetrics should transform the passed metrics to the
|
||||||
// wire format and send it to the collector. May be called
|
// wire format and send it to the collector. May be called
|
||||||
// concurrently.
|
// concurrently.
|
||||||
UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error
|
UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"go.opentelemetry.io/otel/sdk/metric/export"
|
"go.opentelemetry.io/otel/sdk/metric/export"
|
||||||
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
|
"go.opentelemetry.io/otel/sdk/metric/export/aggregation"
|
||||||
"go.opentelemetry.io/otel/sdk/resource"
|
"go.opentelemetry.io/otel/sdk/resource"
|
||||||
metricpb "go.opentelemetry.io/proto/otlp/metrics/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -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
|
// call, as per the specification. We can change the
|
||||||
// signature of UploadMetrics correspondingly. Here create a
|
// signature of UploadMetrics correspondingly. Here create a
|
||||||
// singleton list to reduce the size of the current PR:
|
// 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.
|
// Start establishes a connection to the receiving endpoint.
|
||||||
|
@ -63,8 +63,8 @@ func (m *stubClient) Stop(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *stubClient) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.ResourceMetrics) error {
|
func (m *stubClient) UploadMetrics(ctx context.Context, protoMetrics *metricpb.ResourceMetrics) error {
|
||||||
m.rm = append(m.rm, protoMetrics...)
|
m.rm = append(m.rm, protoMetrics)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ var errShutdown = errors.New("the client is shutdown")
|
|||||||
//
|
//
|
||||||
// Retryable errors from the server will be handled according to any
|
// Retryable errors from the server will be handled according to any
|
||||||
// RetryConfig the client was created with.
|
// 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
|
// 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
|
// 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
|
// write lock acquire (i.e. Stop), meaning if the client is shutting down
|
||||||
@ -197,7 +197,7 @@ func (c *client) UploadMetrics(ctx context.Context, protoMetrics []*metricpb.Res
|
|||||||
|
|
||||||
return c.requestFunc(ctx, func(iCtx context.Context) error {
|
return c.requestFunc(ctx, func(iCtx context.Context) error {
|
||||||
_, err := c.msc.Export(iCtx, &colmetricpb.ExportMetricsServiceRequest{
|
_, err := c.msc.Export(iCtx, &colmetricpb.ExportMetricsServiceRequest{
|
||||||
ResourceMetrics: protoMetrics,
|
ResourceMetrics: []*metricpb.ResourceMetrics{protoMetrics},
|
||||||
})
|
})
|
||||||
// nil is converted to OK.
|
// nil is converted to OK.
|
||||||
if status.Code(err) == codes.OK {
|
if status.Code(err) == codes.OK {
|
||||||
|
@ -144,9 +144,9 @@ func (d *client) Stop(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UploadMetrics sends a batch of metrics to the collector.
|
// 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{
|
pbRequest := &colmetricpb.ExportMetricsServiceRequest{
|
||||||
ResourceMetrics: protoMetrics,
|
ResourceMetrics: []*metricpb.ResourceMetrics{protoMetrics},
|
||||||
}
|
}
|
||||||
rawRequest, err := proto.Marshal(pbRequest)
|
rawRequest, err := proto.Marshal(pbRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user