Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: template prometheus endpoint in examples rather than hardcode #1142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

);
},
);

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