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

Commit b0cbe77

Browse files
authored
Remove outdated option GetMonitoredResource (#186)
1 parent a8e01fd commit b0cbe77

3 files changed

Lines changed: 0 additions & 95 deletions

File tree

stackdriver.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ import (
6262
"contrib.go.opencensus.io/exporter/stackdriver/monitoredresource"
6363
"go.opencensus.io/resource"
6464
"go.opencensus.io/stats/view"
65-
"go.opencensus.io/tag"
6665
"go.opencensus.io/trace"
6766
"golang.org/x/oauth2/google"
6867
"google.golang.org/api/option"
@@ -242,21 +241,6 @@ type Options struct {
242241
// Timeout for all API calls. If not set, defaults to 5 seconds.
243242
Timeout time.Duration
244243

245-
// GetMonitoredResource may be provided to supply the details of the
246-
// monitored resource dynamically based on the tags associated with each
247-
// data point. Most users will not need to set this, but should instead
248-
// set the MonitoredResource field.
249-
//
250-
// GetMonitoredResource may add or remove tags by returning a new set of
251-
// tags. It is safe for the function to mutate its argument and return it.
252-
//
253-
// See the documentation on the MonitoredResource field for guidance on the
254-
// interaction between monitored resources and labels.
255-
//
256-
// The MonitoredResource field is ignored if this field is set to a non-nil
257-
// value.
258-
GetMonitoredResource func(*view.View, []tag.Tag) ([]tag.Tag, monitoredresource.Interface)
259-
260244
// ReportingInterval sets the interval between reporting metrics.
261245
// If it is set to zero then default value is used.
262246
ReportingInterval time.Duration

stats.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,6 @@ func (e *statsExporter) stopMetricsReader() {
163163
}
164164

165165
func (e *statsExporter) getMonitoredResource(v *view.View, tags []tag.Tag) ([]tag.Tag, *monitoredrespb.MonitoredResource) {
166-
if get := e.o.GetMonitoredResource; get != nil {
167-
newTags, mr := get(v, tags)
168-
return newTags, convertMonitoredResourceToPB(mr)
169-
}
170166
resource := e.o.Resource
171167
if resource == nil {
172168
resource = &monitoredrespb.MonitoredResource{

stats_test.go

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,81 +1080,6 @@ func TestExporter_makeReq_withCustomMonitoredResource(t *testing.T) {
10801080
},
10811081
},
10821082
},
1083-
{
1084-
name: "GetMonitoredResource and labels",
1085-
opts: func() Options {
1086-
var labels Labels
1087-
labels.Set("pid", "1234", "Process identifier")
1088-
return Options{
1089-
GetMonitoredResource: func(v *view.View, t []tag.Tag) ([]tag.Tag, monitoredresource.Interface) {
1090-
return t, gceInst
1091-
},
1092-
DefaultMonitoringLabels: &labels,
1093-
}
1094-
}(),
1095-
vd: newTestViewData(v, start, end, count1, count2),
1096-
want: []*monitoringpb.CreateTimeSeriesRequest{
1097-
{
1098-
Name: monitoring.MetricProjectPath("proj-id"),
1099-
TimeSeries: []*monitoringpb.TimeSeries{
1100-
{
1101-
Metric: &metricpb.Metric{
1102-
Type: "custom.googleapis.com/opencensus/testview",
1103-
Labels: map[string]string{
1104-
"test_key": "test-value-1",
1105-
"pid": "1234",
1106-
},
1107-
},
1108-
Resource: resource,
1109-
Points: []*monitoringpb.Point{
1110-
{
1111-
Interval: &monitoringpb.TimeInterval{
1112-
StartTime: &timestamp.Timestamp{
1113-
Seconds: start.Unix(),
1114-
Nanos: int32(start.Nanosecond()),
1115-
},
1116-
EndTime: &timestamp.Timestamp{
1117-
Seconds: end.Unix(),
1118-
Nanos: int32(end.Nanosecond()),
1119-
},
1120-
},
1121-
Value: &monitoringpb.TypedValue{Value: &monitoringpb.TypedValue_Int64Value{
1122-
Int64Value: 10,
1123-
}},
1124-
},
1125-
},
1126-
},
1127-
{
1128-
Metric: &metricpb.Metric{
1129-
Type: "custom.googleapis.com/opencensus/testview",
1130-
Labels: map[string]string{
1131-
"test_key": "test-value-2",
1132-
"pid": "1234",
1133-
},
1134-
},
1135-
Resource: resource,
1136-
Points: []*monitoringpb.Point{
1137-
{
1138-
Interval: &monitoringpb.TimeInterval{
1139-
StartTime: &timestamp.Timestamp{
1140-
Seconds: start.Unix(),
1141-
Nanos: int32(start.Nanosecond()),
1142-
},
1143-
EndTime: &timestamp.Timestamp{
1144-
Seconds: end.Unix(),
1145-
Nanos: int32(end.Nanosecond()),
1146-
},
1147-
},
1148-
Value: &monitoringpb.TypedValue{Value: &monitoringpb.TypedValue_Int64Value{
1149-
Int64Value: 16,
1150-
}},
1151-
},
1152-
},
1153-
},
1154-
},
1155-
},
1156-
},
1157-
},
11581083
{
11591084
name: "custom default monitoring labels",
11601085
opts: func() Options {

0 commit comments

Comments
 (0)