Skip to content

Commit

Permalink
Rename :orgId to :instanceId in metrics graph url
Browse files Browse the repository at this point in the history
- Renames placeholders `:orgId` to `:instanceId` in
  `--app.metrics-graph`
- Adjusts frontend client to use the provided instanceId by its host
  application (Weave Cloud)
  • Loading branch information
rndstr committed Dec 14, 2018
1 parent a721b49 commit 1e0c3fe
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions client/app/scripts/components/cloud-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CloudFeature from './cloud-feature';
* that is comprised of Weave Cloud related pieces.
*
* We support here relative links with a leading `/` that rewrite
* the browser url as well as cloud-related placeholders (:orgId).
* the browser url as well as cloud-related placeholders (:instanceId).
*
* If no `url` is given, only the children is rendered (no anchor).
*
Expand Down Expand Up @@ -50,8 +50,8 @@ class LinkWrapper extends React.Component {

buildHref(url) {
const { params } = this.props;
if (!url || !params || !params.orgId) return url;
return url.replace(/:orgid/gi, encodeURIComponent(this.props.params.orgId));
if (!url || !params || !params.instanceId) return url;
return url.replace(/:instanceid/gi, encodeURIComponent(params.instanceId));
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('NodeDetailsHealthLinkItem', () => {
});

it('appends as json for cloud link', () => {
const url = appendTime('/prom/:orgid/notebook/new/%7B%22cells%22%3A%5B%7B%22queries%22%3A%5B%22go_goroutines%22%5D%7D%5D%7D', time);
const url = appendTime('/prom/:instanceid/notebook/new/%7B%22cells%22%3A%5B%7B%22queries%22%3A%5B%22go_goroutines%22%5D%7D%5D%7D', time);
expect(url).toContain(timeUnix);

const payload = JSON.parse(decodeURIComponent(url.substr(url.indexOf('new/') + 4)));
Expand Down
6 changes: 3 additions & 3 deletions client/app/scripts/utils/web-api-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export function basePathSlash(urlPath) {
// i.e. in this case Weave Cloud, rather than being hardcoded here.
export function getApiPath(pathname = window.location.pathname) {
if (process.env.SCOPE_API_PREFIX) {
// Extract the instance name (pathname in WC context is of format '/:orgId/explore').
const orgId = pathname.split('/')[1];
return basePath(`${process.env.SCOPE_API_PREFIX}/app/${orgId}`);
// Extract the instance name (pathname in WC context is of format '/:instanceId/explore').
const instanceId = pathname.split('/')[1];
return basePath(`${process.env.SCOPE_API_PREFIX}/app/${instanceId}`);
}

return basePath(pathname);
Expand Down
2 changes: 1 addition & 1 deletion prog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func setupFlags(flags *flags) {
flag.IntVar(&flags.app.memcachedCompressionLevel, "app.memcached.compression", gzip.DefaultCompression, "How much to compress reports stored in memcached.")
flag.StringVar(&flags.app.userIDHeader, "app.userid.header", "", "HTTP header to use as userid")
flag.BoolVar(&flags.app.externalUI, "app.externalUI", false, "Point to externally hosted static UI assets")
flag.StringVar(&flags.app.metricsGraphURL, "app.metrics-graph", "", "Enable extended metrics graph by providing a templated URL (supports :orgID and :query). Example: --app.metric-graph=/prom/:orgID/notebook/new")
flag.StringVar(&flags.app.metricsGraphURL, "app.metrics-graph", "", "Enable extended metrics graph by providing a templated URL (supports :instanceID and :query). Example: --app.metric-graph=/prom/:instanceID/notebook/new")
flag.StringVar(&flags.app.serviceName, "app.service-name", "app", "The name for this service which should be reported in instrumentation")

flag.IntVar(&flags.app.blockProfileRate, "app.block.profile.rate", 0, "If more than 0, enable block profiling. The profiler aims to sample an average of one blocking event per rate nanoseconds spent blocked.")
Expand Down
2 changes: 1 addition & 1 deletion render/detailed/links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

const (
sampleMetricsGraphURL = "/prom/:orgID/notebook/new"
sampleMetricsGraphURL = "/prom/:instanceID/notebook/new"
)

var (
Expand Down

0 comments on commit 1e0c3fe

Please sign in to comment.