-
Notifications
You must be signed in to change notification settings - Fork 76
Add GetMonitoredResource option #46
Add GetMonitoredResource option #46
Conversation
e5e6bd7
to
82e3217
Compare
stackdriver.go
Outdated
// | ||
// The MonitoredResource field is ignored if this field is set to a non-nil | ||
// value. | ||
GetMonitoredResource func([]tag.Tag) monitoredresource.Interface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this take an ViewData and also return a new ViewData and MonitorResource. User usually want to remove that tag probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also some people want to configure the project id as well. This is useful when export metrics on behalf of others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it take and return a []tag.Tag since I think this will accomplish the same thing without the complexity of having to clone and mutate a full ViewData. Regarding the project ID, it is part of the MonitoredResource.
18bf666
to
1eb1b2e
Compare
@@ -101,11 +101,3 @@ func TestAWSEC2InstanceMonitoredResources(t *testing.T) { | |||
t.Errorf("AWSEC2InstanceMonitoredResource Failed: %v", autoDetected) | |||
} | |||
} | |||
|
|||
func TestNullMonitoredResources(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was failing on Travis because (I guess) the Travis worker is an EC2 instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a GCE instance :) Tests failed because GCE resource is detected correctly, which is a good indication.
@@ -1105,7 +1264,7 @@ func TestExporter_customContext(t *testing.T) { | |||
var timedOut = 0 | |||
createMetricDescriptor = func(ctx context.Context, c *monitoring.MetricClient, mdr *monitoringpb.CreateMetricDescriptorRequest) (*metric.MetricDescriptor, error) { | |||
select { | |||
case <-time.After(15 * time.Millisecond): | |||
case <-time.After(1 * time.Second): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase time because it was failing intermittently on Travis
@bogdandrutu updated PTAL |
stackdriver.go
Outdated
|
||
// GetMonitoredResource may be provided to supply the details of the | ||
// monitored resource dynamically based on the tags associated with each | ||
// data point. Most users will not need need to set this, but should instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:s/need need/need/
stackdriver.go
Outdated
// | ||
// The MonitoredResource field is ignored if this field is set to a non-nil | ||
// value. | ||
GetMonitoredResource func([]tag.Tag) ([]tag.Tag, monitoredresource.Interface) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the purpose here to create monitored resource labels based only on Tags? OR will it be a combination of two (based on tag and GCEInstance/GKE/AWS)?
Since MonitoredResource and GetMonitoredResource both cannot be set and GetMonitoredResource supersedes MonitoredResource, can MonitoredResource be deprecated?
we also have this PR on monitored resources. We would have three different ways to create monitored resources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @rakyll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think MonitoredResource should be deprecated even though there is a lot of overlap in functionality. GetMonitoredResources is really an advanced feature that most users should not need to care about. MonitoredResource on the other hand should usually be set by most users and is much easier to understand.
1eb1b2e
to
8d57087
Compare
@bogdandrutu updated to allow modification of the tags, PTAL |
This allows customizing the MonitoredResource based on tag values.
8d57087
to
7baa60f
Compare
ping @bogdandrutu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change LGTM though I don't have much context about the background. /cc @fabxc.
@@ -101,11 +101,3 @@ func TestAWSEC2InstanceMonitoredResources(t *testing.T) { | |||
t.Errorf("AWSEC2InstanceMonitoredResource Failed: %v", autoDetected) | |||
} | |||
} | |||
|
|||
func TestNullMonitoredResources(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's actually a GCE instance :) Tests failed because GCE resource is detected correctly, which is a good indication.
I wanted to submit a PR with support for resources and this certainly conflicts. @bogdandrutu @Ramonza could you provide some background on the use case this was added for? I'd like to find a good way to accommodate this use case within the new resources. |
@fabxc this was added so that you can record against more than one monitored resource based on what tags are set. For example, if you are recording stats on behalf of another process. |
We deliberately deferred the discussion of multiple resources from a single process initially. I thought this would rather be an aspect of the core library as well and would either way be discussed in the scope of a language and exporter independent spec. The only way forward right now seems to be to provide the intended core resource handling as a |
This allows customizing the MonitoredResource based on tag values.