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

Fix issues in TypeScript getting started example code #1374

Merged
merged 3 commits into from
Aug 5, 2020
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
7 changes: 4 additions & 3 deletions getting-started/ts-example/monitoring.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MeterProvider } from '@opentelemetry/metrics';
import { Metric, BoundCounter } from '@opentelemetry/api';
import { Counter } from '@opentelemetry/api';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
import { RequestHandler } from "express";
Copy link
Member

Choose a reason for hiding this comment

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

interesting is that this line didn't cause the build to fail on linting, as there should be single quotes.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the getting started guide is linted

Copy link
Member

Choose a reason for hiding this comment

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

@mickdekkers can you please change this line to use single quotes ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, I'll change it to single quotes 👍

FYI, this isn't consistent in the getting started guide: tracing.ts uses both single and double quotes and app.ts uses double quotes

Copy link
Member

Choose a reason for hiding this comment

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

Like I said, the guide isn't linted. Since the guide rarely changes, I think it isn't necessarily a problem. Let's make these small quote changes and merge this. Eventually, the guide will need to be rewritten for the sdk package, and maybe we should start linting it then.


const exporter = new PrometheusExporter(
{
Expand All @@ -18,13 +19,13 @@ const meter = new MeterProvider({
interval: 1000,
}).getMeter('example-ts');

const requestCount: Metric<BoundCounter> = meter.createCounter("requests", {
const requestCount: Counter = meter.createCounter("requests", {
description: "Count all incoming requests"
});

const handles = new Map();

export const countAllRequests = () => {
export const countAllRequests = (): RequestHandler => {
return (req, res, next) => {
if (!handles.has(req.path)) {
const labels = { route: req.path };
Expand Down
2 changes: 2 additions & 0 deletions getting-started/ts-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
"devDependencies": {
"@types/express": "^4.17.7",
"@types/node": "^14.0.27",
"ts-node": "8.10.2"
},
"dependencies": {
Expand Down