You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: implement named meter
* chore: update name provider to registry, remove 'default' name on MeterProvider
* chore: remove duplicated types import
* chore: address comments
const meter = new MeterRegistry().getMeter('your-meter-name');
244
244
```
245
245
246
246
Now, you can require this file from your application code and use the `Meter` to create and manage metrics. The simplest of these metrics is a counter. Let's create and export from our `monitoring.js` file a middleware function that express can use to count all requests by route. Modify the `monitoring.js` file so that it looks like this:
247
247
248
248
```javascript
249
249
'use strict';
250
250
251
-
const { Meter } = require("@opentelemetry/metrics");
After these dependencies are installed, we will need to initialize and register them. Modify `tracing.ts` so that it matches the following code snippet, replacing the service name `"getting-started"` with your own service name if you wish.
// import { JaegerExporter } from "@opentelemetry/exporter-jaeger";
115
+
// import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
116
116
117
117
const tracer:NodeTracer=newNodeTracer({
118
118
logLevel: opentelemetry.LogLevel.ERROR
@@ -236,18 +236,18 @@ In order to create and monitor metrics, we will need a `Meter`. In OpenTelemetry
236
236
Create a file named `monitoring.ts` and add the following code:
237
237
238
238
```typescript
239
-
import { Meter } from "@opentelemetry/metrics";
239
+
import { MeterRegistry } from '@opentelemetry/metrics';
240
240
241
-
const meter = new Meter();
241
+
const meter = new MeterRegistry().getMeter('your-meter-name');
242
242
```
243
243
244
244
Now, you can require this file from your application code and use the `Meter` to create and manage metrics. The simplest of these metrics is a counter. Let's create and export from our `monitoring.ts` file a middleware function that express can use to count all requests by route. Modify the `monitoring.ts` file so that it looks like this:
245
245
246
246
```typescript
247
-
import { Meter } from "@opentelemetry/metrics";
248
-
import { Metric, BoundCounter } from "@opentelemetry/types";
247
+
import { MeterRegistry } from '@opentelemetry/metrics';
248
+
import { Metric, BoundCounter } from '@opentelemetry/types';
249
249
250
-
const meter = new Meter();
250
+
const meter = new MeterRegistry().getMeter('your-meter-name');
Choose this kind of metric when the value is a quantity, the sum is of primary interest, and the event count and value distribution are not of primary interest. Counters are defined as `Monotonic = true` by default, meaning that positive values are expected.
20
20
21
21
```js
22
-
const { Meter } =require('@opentelemetry/metrics');
Gauge metrics express a pre-calculated value. Generally, this kind of metric should be used when the metric cannot be expressed as a sum or because the measurement interval is arbitrary. Use this kind of metric when the measurement is not a quantity, and the sum and event count are not of interest. Gauges are defined as `Monotonic = false` by default, meaning that new values are permitted to make positive or negative changes to the gauge. There is no restriction on the sign of the input for gauges.
41
41
42
42
```js
43
-
const { Meter } =require('@opentelemetry/metrics');
0 commit comments