Skip to content

Commit

Permalink
Merge pull request #3057 from cloudfoundry-incubator/metrics-fix-job-…
Browse files Browse the repository at this point in the history
…matching

Metrics: Fix issue where wrong job can be matched up when there are multiple jobs
  • Loading branch information
KlapTrap authored Sep 25, 2018
2 parents dfcf2ca + d458bc4 commit 256259f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/jetstream/plugins/metrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (m *MetricsSpecification) UpdateMetadata(info *interfaces.Info, userGUID st
// Look to see if we can find the metrics provider for this URL
if provider, ok := hasMetricsProvider(metricsProviders, endpoint.DopplerLoggingEndpoint); ok {
endpoint.Metadata["metrics"] = provider.EndpointGUID
endpoint.Metadata["metrics_job"] = provider.Job
}
}
}
Expand Down Expand Up @@ -244,18 +245,20 @@ func (m *MetricsSpecification) getMetricsEndpoints(userGUID string, cnsiList []s
for _, metricProviderInfo := range metricsProviders {
for guid, info := range endpointsMap {
// Depends on the type
if info.DopplerLoggingEndpoint == metricProviderInfo.URL {
if info.CNSIType == metricProviderInfo.Type && info.DopplerLoggingEndpoint == metricProviderInfo.URL {
relate := EndpointMetricsRelation{}
relate.endpoint = info
relate.metrics = &metricProviderInfo
// Make a copy
relate.metrics = &MetricsMetadata{}
*relate.metrics = metricProviderInfo
results[guid] = relate
delete(endpointsMap, guid)
break
}
}
}

// If there are still items in the endpoints map, then we did not find all metric providers
// Did we find a metric provider for each endpoint?
if len(endpointsMap) != 0 {
return nil, errors.New("Can not find a metric provider for all of the specified endpoints")
}
Expand Down

0 comments on commit 256259f

Please sign in to comment.