@platformatic/telemetry 2.72.0 → 3.0.0-alpha.1

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.
@@ -1,21 +1,15 @@
1
1
  'use strict'
2
2
 
3
- const {
4
- ExportResultCode,
5
- hrTimeToMicroseconds,
6
- } = require('@opentelemetry/core')
7
- const path = require('node:path')
3
+ const { ExportResultCode, hrTimeToMicroseconds } = require('@opentelemetry/core')
4
+ const { resolve: resolvePath } = require('node:path')
8
5
  const { appendFileSync } = require('node:fs')
6
+ const { workerData } = require('node:worker_threads')
9
7
 
10
8
  // Export spans to a file, mostly for testing purposes.
11
9
  class FileSpanExporter {
12
10
  #path
13
11
  constructor (opts) {
14
- if (!opts.path) {
15
- this.#path = path.resolve('spans.log')
16
- } else {
17
- this.#path = opts.path
18
- }
12
+ this.#path = resolvePath(workerData?.dirname ?? process.cwd(), opts.path ?? 'spans.log')
19
13
  }
20
14
 
21
15
  export (spans, resultCallback) {
@@ -48,7 +42,7 @@ class FileSpanExporter {
48
42
  events: span.events,
49
43
  links: span.links,
50
44
  resource: span.resource,
51
- instrumentationLibrary: span.instrumentationLibrary,
45
+ instrumentationLibrary: span.instrumentationLibrary
52
46
  }
53
47
  }
54
48
  }
@@ -9,7 +9,7 @@ const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions')
9
9
  const { workerData } = require('node:worker_threads')
10
10
  const { resolve } = require('node:path')
11
11
  const { tmpdir } = require('node:os')
12
- const logger = require('abstract-logging')
12
+ const { abstractLogger } = require('@platformatic/utils')
13
13
  const { statSync, readFileSync } = require('node:fs') // We want to have all this synch
14
14
  const util = require('node:util')
15
15
  const { getInstrumentations } = require('./pluggable-instrumentations')
@@ -38,7 +38,7 @@ const setupNodeHTTPTelemetry = async (opts, serviceDir) => {
38
38
 
39
39
  let exporter = opts.exporter
40
40
  if (!exporter) {
41
- logger.warn('No exporter configured, defaulting to console.')
41
+ abstractLogger.warn('No exporter configured, defaulting to console.')
42
42
  exporter = { type: 'console' }
43
43
  }
44
44
  const exporters = Array.isArray(exporter) ? exporter : [exporter]
@@ -64,7 +64,7 @@ const setupNodeHTTPTelemetry = async (opts, serviceDir) => {
64
64
  } else if (exporter.type === 'file') {
65
65
  exporterObj = new FileSpanExporter(exporterOptions)
66
66
  } else {
67
- logger.warn(
67
+ abstractLogger.warn(
68
68
  `Unknown exporter type: ${exporter.type}, defaulting to console.`
69
69
  )
70
70
  exporterObj = new ConsoleSpanExporter(exporterOptions)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/telemetry",
3
- "version": "2.72.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "OpenTelemetry integration for Platformatic",
5
5
  "main": "index.js",
6
6
  "author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
@@ -33,11 +33,9 @@
33
33
  "@opentelemetry/sdk-node": "^0.57.0",
34
34
  "@opentelemetry/sdk-trace-base": "^1.22.0",
35
35
  "@opentelemetry/semantic-conventions": "1.30.0",
36
- "abstract-logging": "^2.0.1",
37
36
  "fast-uri": "^3.0.0",
38
37
  "fastify-plugin": "^5.0.0",
39
- "@platformatic/config": "2.72.0",
40
- "@platformatic/utils": "2.72.0"
38
+ "@platformatic/utils": "3.0.0-alpha.1"
41
39
  },
42
40
  "scripts": {
43
41
  "test": "npm run lint && borp --timeout=120000 --concurrency=1",