@platformatic/telemetry 0.37.4 → 0.38.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/lib/schema.js CHANGED
@@ -42,7 +42,21 @@ const TelemetrySchema = {
42
42
  type: 'array',
43
43
  description: 'An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.',
44
44
  items: {
45
- type: 'string'
45
+ type: 'object',
46
+ properties: {
47
+ path: {
48
+ type: 'string',
49
+ description: 'The path to skip. Can be a string or a regex.'
50
+ },
51
+ method: {
52
+ type: 'array',
53
+ description: 'An array of HTTP methods to skip. If not specified, all methods will be skipped.',
54
+ items: {
55
+ type: 'string',
56
+ enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
57
+ }
58
+ }
59
+ }
46
60
  }
47
61
  },
48
62
  exporter: {
package/lib/telemetry.js CHANGED
@@ -133,7 +133,10 @@ async function setupTelemetry (app, opts) {
133
133
  // const { serviceName, version } = opts
134
134
  const openTelemetryAPIs = setupProvider(app, opts)
135
135
  const { tracer, propagator, provider } = openTelemetryAPIs
136
- const skipOperations = opts.skip || []
136
+ const skipOperations = opts?.skip?.map(skip => {
137
+ const { method, path } = skip
138
+ return `${method}${path}`
139
+ }) || []
137
140
 
138
141
  // expose the span as a request decorator
139
142
  app.decorateRequest('span')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/telemetry",
3
- "version": "0.37.4",
3
+ "version": "0.38.0",
4
4
  "description": "OpenTelemetry integration for Platformatic",
5
5
  "main": "index.js",
6
6
  "author": "Marco Piraccini <marco.piraccini@gmail.com>",
@@ -263,7 +263,12 @@ test('should ignore the skipped operations', async ({ equal, same, ok, teardown
263
263
 
264
264
  const app = await setupApp({
265
265
  serviceName: 'test-service',
266
- skip: ['POST/skipme'],
266
+ skip: [
267
+ {
268
+ path: '/skipme',
269
+ method: 'POST'
270
+ }
271
+ ],
267
272
  exporter: {
268
273
  type: 'memory'
269
274
  }
@@ -268,9 +268,10 @@ test('should not trace if the operation is skipped', async ({ equal, same, teard
268
268
  const app = await setupApp({
269
269
  serviceName: 'test-service',
270
270
  version: '1.0.0',
271
- skip: [
272
- 'GET/documentation/json'
273
- ],
271
+ skip: [{
272
+ path: '/documentation/json',
273
+ method: 'GET'
274
+ }],
274
275
  exporter: {
275
276
  type: 'memory'
276
277
  }