Skip to content

Commit

Permalink
chore: template prometheus endpoint in examples rather than hardcode (#…
Browse files Browse the repository at this point in the history
…1142)

Signed-off-by: Naseem <[email protected]>
  • Loading branch information
Naseem authored Jun 4, 2020
1 parent dadcad7 commit 121b03d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
4 changes: 3 additions & 1 deletion examples/metrics/metrics/observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter(
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
);
},
);

Expand Down
4 changes: 3 additions & 1 deletion examples/prometheus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter(
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
);
},
);

Expand Down
7 changes: 6 additions & 1 deletion getting-started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,17 @@ Next, modify your `monitoring.js` file to look like this:
const { MeterProvider } = require('@opentelemetry/metrics');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');
const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port
const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint
const exporter = new PrometheusExporter(
{
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`,
);
},
);

Expand Down
4 changes: 3 additions & 1 deletion getting-started/monitored-example/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter(
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
);
},
);

Expand Down
7 changes: 6 additions & 1 deletion getting-started/ts-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,17 @@ import { MeterProvider } from '@opentelemetry/metrics';
import { Metric, BoundCounter } from '@opentelemetry/api';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port
const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint
const exporter = new PrometheusExporter(
{
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`,
);
},
);

Expand Down
4 changes: 3 additions & 1 deletion getting-started/ts-example/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const exporter = new PrometheusExporter(
startServer: true,
},
() => {
console.log('prometheus scrape endpoint: http://localhost:9464/metrics');
console.log(
`prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`,
);
},
);

Expand Down

0 comments on commit 121b03d

Please sign in to comment.