Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

change ExportMetric api to ExportMetricProto #104

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion equivalence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {

ma.forEachRequest(func(emr *agentmetricspb.ExportMetricsServiceRequest) {
for _, metric := range emr.Metrics {
_ = se.ExportMetric(context.Background(), emr.Node, emr.Resource, metric)
_ = se.ExportMetricProto(context.Background(), emr.Node, emr.Resource, metric)
}
})
se.Flush()
Expand Down
10 changes: 8 additions & 2 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@ type metricPayload struct {
metric *metricspb.Metric
}

// ExportMetric exports OpenCensus Metrics to Stackdriver Monitoring.
func (se *statsExporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
// ExportMetric exports OpenCensus Metrics proto to Stackdriver Monitoring.
// Deprecated in lieu of ExportMetricProto
func (se *statsExporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metricpb *metricspb.Metric) error {
return se.ExportMetricProto(ctx, node, rsc, metricpb)
}

// ExportMetricProto exports OpenCensus Metrics proto to Stackdriver Monitoring.
func (se *statsExporter) ExportMetricProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
if metric == nil {
return errNilMetric
}
Expand Down
8 changes: 7 additions & 1 deletion stackdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,15 @@ func (e *Exporter) ExportView(vd *view.Data) {
e.statsExporter.ExportView(vd)
}

// ExportMetricProto exports OpenCensus Metrics to Stackdriver Monitoring.
func (e *Exporter) ExportMetricProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
return e.statsExporter.ExportMetricProto(ctx, node, rsc, metric)
}

// ExportMetric exports OpenCensus Metrics to Stackdriver Monitoring.
// Deprecated in lieu of ExportMetriProto
func (e *Exporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
return e.statsExporter.ExportMetric(ctx, node, rsc, metric)
return e.statsExporter.ExportMetricProto(ctx, node, rsc, metric)
}

// ExportSpan exports a SpanData to Stackdriver Trace.
Expand Down