@openapi-typescript-infra/service 2.6.6 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/types.d.ts CHANGED
@@ -5,7 +5,7 @@ import type pino from 'pino';
5
5
  import type { Request, Response } from 'express';
6
6
  import type { Application } from 'express-serve-static-core';
7
7
  import type { middleware } from 'express-openapi-validator';
8
- import type { Meter, MeterProvider } from '@opentelemetry/api-metrics';
8
+ import type { Meter, MeterProvider } from '@opentelemetry/api';
9
9
  import type { ConfigStore } from './config/types';
10
10
  export interface InternalLocals extends Record<string, unknown> {
11
11
  server?: Server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-typescript-infra/service",
3
- "version": "2.6.6",
3
+ "version": "2.7.0",
4
4
  "description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -62,11 +62,9 @@
62
62
  "@gasbuddy/confit": "^3.0.0",
63
63
  "@godaddy/terminus": "^4.12.1",
64
64
  "@opentelemetry/api": "^1.6.0",
65
- "@opentelemetry/api-metrics": "^0.33.0",
66
65
  "@opentelemetry/exporter-prometheus": "^0.43.0",
67
66
  "@opentelemetry/exporter-trace-otlp-proto": "^0.43.0",
68
67
  "@opentelemetry/instrumentation": "^0.43.0",
69
- "@opentelemetry/instrumentation-aws-sdk": "^0.36.0",
70
68
  "@opentelemetry/instrumentation-dns": "^0.32.2",
71
69
  "@opentelemetry/instrumentation-express": "^0.33.1",
72
70
  "@opentelemetry/instrumentation-generic-pool": "^0.32.2",
@@ -78,6 +76,7 @@
78
76
  "@opentelemetry/instrumentation-pino": "^0.34.1",
79
77
  "@opentelemetry/sdk-metrics": "^1.17.0",
80
78
  "@opentelemetry/sdk-node": "^0.43.0",
79
+ "@opentelemetry/sdk-trace-base": "^1.17.0",
81
80
  "@opentelemetry/semantic-conventions": "^1.17.0",
82
81
  "cookie-parser": "^1.4.6",
83
82
  "dotenv": "^16.3.1",
@@ -7,7 +7,9 @@ import express from 'express';
7
7
  import { pino } from 'pino';
8
8
  import cookieParser from 'cookie-parser';
9
9
  import { MeterProvider } from '@opentelemetry/sdk-metrics';
10
- import { metrics } from '@opentelemetry/api-metrics';
10
+ import { Resource } from '@opentelemetry/resources';
11
+ import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
12
+ import { metrics } from '@opentelemetry/api';
11
13
  import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
12
14
  import { createTerminus } from '@godaddy/terminus';
13
15
  import type { RequestHandler, Response } from 'express';
@@ -48,7 +50,11 @@ async function enableMetrics<SLocals extends ServiceLocals = ServiceLocals>(
48
50
  app: ServiceExpress<SLocals>,
49
51
  name: string,
50
52
  ) {
51
- const meterProvider = new MeterProvider();
53
+ const meterProvider = new MeterProvider({
54
+ resource: new Resource({
55
+ [SemanticResourceAttributes.SERVICE_NAME]: name,
56
+ }),
57
+ });
52
58
  metrics.setGlobalMeterProvider(meterProvider);
53
59
  app.locals.meter = meterProvider.getMeter(name);
54
60
 
@@ -0,0 +1,11 @@
1
+ import { SpanExporter } from '@opentelemetry/sdk-trace-base';
2
+
3
+ export class DummySpanExporter implements SpanExporter {
4
+ export() {
5
+ // Nothing
6
+ }
7
+
8
+ async shutdown() {
9
+ // Nothing
10
+ }
11
+ }
@@ -6,6 +6,9 @@ import {
6
6
  Attributes,
7
7
  context,
8
8
  propagation,
9
+ metrics,
10
+ Meter,
11
+ MeterProvider,
9
12
  Span,
10
13
  SpanKind,
11
14
  SpanStatusCode,
@@ -13,7 +16,6 @@ import {
13
16
  Tracer,
14
17
  TracerProvider,
15
18
  } from '@opentelemetry/api';
16
- import { Meter, MeterProvider, metrics } from '@opentelemetry/api-metrics';
17
19
 
18
20
  interface ListenerRecord {
19
21
  name: string;
@@ -11,6 +11,7 @@ import type {
11
11
  import type { ListenFn, StartAppFn } from '../express-app/index';
12
12
 
13
13
  import { getAutoInstrumentations } from './instrumentations';
14
+ import { DummySpanExporter } from './DummyExporter';
14
15
 
15
16
  // For troubleshooting, set the log level to DiagLogLevel.DEBUG
16
17
  diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
@@ -27,6 +28,7 @@ function getExporter() {
27
28
  if (process.env.ENABLE_CONSOLE_OLTP_EXPORTER) {
28
29
  return new opentelemetry.tracing.ConsoleSpanExporter();
29
30
  }
31
+ return new DummySpanExporter();
30
32
  }
31
33
 
32
34
  export async function startWithTelemetry<
@@ -1,5 +1,4 @@
1
1
  import type { Instrumentation } from '@opentelemetry/instrumentation';
2
- import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';
3
2
  import { DnsInstrumentation } from '@opentelemetry/instrumentation-dns';
4
3
  import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express';
5
4
  import { GenericPoolInstrumentation } from '@opentelemetry/instrumentation-generic-pool';
@@ -12,11 +11,8 @@ import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
12
11
  import { FetchInstrumentation } from './fetchInstrumentation';
13
12
 
14
13
  const InstrumentationMap = {
15
- // Disable this for now because it logs a stupid message
16
- // '@opentelemetry/instrumentation-aws-lambda': AwsLambdaInstrumentation,
17
14
  '@opentelemetry/instrumentation-http': HttpInstrumentation,
18
15
  'opentelemetry-instrumentation-node-18-fetch': FetchInstrumentation,
19
- '@opentelemetry/instrumentation-aws-sdk': AwsInstrumentation,
20
16
  '@opentelemetry/instrumentation-dns': DnsInstrumentation,
21
17
  '@opentelemetry/instrumentation-express': ExpressInstrumentation,
22
18
  '@opentelemetry/instrumentation-generic-pool': GenericPoolInstrumentation,
package/src/types.ts CHANGED
@@ -4,7 +4,7 @@ import type pino from 'pino';
4
4
  import type { Request, Response } from 'express';
5
5
  import type { Application } from 'express-serve-static-core';
6
6
  import type { middleware } from 'express-openapi-validator';
7
- import type { Meter, MeterProvider } from '@opentelemetry/api-metrics';
7
+ import type { Meter, MeterProvider } from '@opentelemetry/api';
8
8
 
9
9
  import type { ConfigStore } from './config/types';
10
10