@platformatic/telemetry
Advanced tools
| import { context, isSpanContextValid, trace } from '@opentelemetry/api' | ||
| const defaultLogKeys = { | ||
| traceId: 'trace_id', | ||
| spanId: 'span_id', | ||
| traceFlags: 'trace_flags' | ||
| } | ||
| function pinoInstrumentationCombinedMixin (logKeys, original, ...args) { | ||
| const result = original(...args) | ||
| const spanContext = trace.getSpan(context.active())?.spanContext() | ||
| if (spanContext && isSpanContextValid(spanContext)) { | ||
| result[logKeys.traceId] = spanContext.traceId | ||
| result[logKeys.spanId] = spanContext.spanId | ||
| result[logKeys.traceFlags] = `0${spanContext.traceFlags.toString(16)}` | ||
| } | ||
| return result | ||
| } | ||
| function pinoInstrumentationStandaloneMixin (logKeys) { | ||
| const spanContext = trace.getSpan(context.active())?.spanContext() | ||
| if (!spanContext || !isSpanContextValid(spanContext)) { | ||
| return {} | ||
| } | ||
| return { | ||
| [logKeys.traceId]: spanContext.traceId, | ||
| [logKeys.spanId]: spanContext.spanId, | ||
| [logKeys.traceFlags]: `0${spanContext.traceFlags.toString(16)}` | ||
| } | ||
| } | ||
| export function addPinoInstrumentation (options, overrides = {}) { | ||
| const logKeys = Object.assign({}, defaultLogKeys, overrides) | ||
| options.mixin = options.mixin | ||
| ? pinoInstrumentationCombinedMixin.bind(null, logKeys, options.mixin) | ||
| : pinoInstrumentationStandaloneMixin.bind(null, logKeys) | ||
| } |
+1
-0
@@ -0,3 +1,4 @@ | ||
| export { addPinoInstrumentation } from './lib/logger.js' | ||
| export * as schema from './lib/schema.js' | ||
| export * as telemetry from './lib/telemetry.js' | ||
| export { createTelemetryThreadInterceptorHooks } from './lib/thread-interceptor-hooks.js' |
+2
-2
| { | ||
| "name": "@platformatic/telemetry", | ||
| "version": "3.38.1", | ||
| "version": "3.39.0", | ||
| "description": "OpenTelemetry integration for Platformatic", | ||
@@ -39,3 +39,3 @@ "main": "index.js", | ||
| "fastify-plugin": "^5.0.1", | ||
| "@platformatic/foundation": "3.38.1" | ||
| "@platformatic/foundation": "3.39.0" | ||
| }, | ||
@@ -42,0 +42,0 @@ "engines": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
46245
2.97%20
5.26%886
3.99%+ Added
- Removed