plutin 1.6.6 → 1.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/dist/index.cjs CHANGED
@@ -456,6 +456,7 @@ __export(src_exports, {
456
456
  Inject: () => Inject,
457
457
  NotificationErrorInMemory: () => NotificationErrorInMemory,
458
458
  NotificationFactory: () => NotificationFactory,
459
+ OpenTelemetry: () => OpenTelemetry,
459
460
  SentryNotifier: () => SentryNotifier,
460
461
  Span: () => Span,
461
462
  TracerGatewayOpentelemetry: () => TracerGatewayOpentelemetry,
@@ -1518,17 +1519,14 @@ var WinstonOtelFastify = class WinstonOtelFastify2 {
1518
1519
  static {
1519
1520
  __name(this, "WinstonOtelFastify");
1520
1521
  }
1521
- env;
1522
1522
  logger;
1523
1523
  consoleLogger;
1524
- level;
1525
- constructor(env) {
1526
- this.env = env;
1527
- this.level = "info";
1528
- if (this.env.OTEL_ENABLE) {
1529
- this.logger = import_api_logs.logs.getLogger(this.env.OTEL_SERVICE_NAME, this.env.OTEL_SERVICE_VERSION);
1530
- this.level = this.env.LOG_LEVEL;
1531
- const transports = this.env.NODE_ENV === "test" ? [
1524
+ level = "info";
1525
+ constructor() {
1526
+ if (process.env.OTEL_ENABLE) {
1527
+ this.logger = import_api_logs.logs.getLogger(process.env.OTEL_SERVICE_NAME, process.env.OTEL_SERVICE_VERSION);
1528
+ this.level = process.env.LOG_LEVEL;
1529
+ const transports = process.env.NODE_ENV === "test" ? [
1532
1530
  new import_winston.default.transports.Console({
1533
1531
  silent: true
1534
1532
  })
@@ -1540,7 +1538,7 @@ var WinstonOtelFastify = class WinstonOtelFastify2 {
1540
1538
  format: import_winston.default.format.combine(import_winston.default.format.timestamp({
1541
1539
  format: "YYYY-MM-DD HH:mm:ss:ms"
1542
1540
  }), import_winston.default.format((info) => {
1543
- if (this.env.NODE_ENV !== "test") {
1541
+ if (process.env.NODE_ENV !== "test") {
1544
1542
  const span = import_api.default.trace.getActiveSpan();
1545
1543
  if (span) {
1546
1544
  info.spanId = span.spanContext().spanId;
@@ -1580,7 +1578,7 @@ var WinstonOtelFastify = class WinstonOtelFastify2 {
1580
1578
  logMessage(body, severityNumber, severityText) {
1581
1579
  const message = this.buildMessage(body);
1582
1580
  this.consoleLogger[severityText.toLowerCase()](message);
1583
- if (this.env.NODE_ENV !== "test") {
1581
+ if (process.env.NODE_ENV !== "test") {
1584
1582
  this.logger.emit({
1585
1583
  body: message,
1586
1584
  severityNumber,
@@ -1604,7 +1602,7 @@ var WinstonOtelFastify = class WinstonOtelFastify2 {
1604
1602
  this.logMessage(body, import_api_logs.SeverityNumber.WARN, "WARN");
1605
1603
  }
1606
1604
  trace(message) {
1607
- if (this.env.NODE_ENV !== "test") {
1605
+ if (process.env.NODE_ENV !== "test") {
1608
1606
  this.logger.emit({
1609
1607
  body: message,
1610
1608
  severityNumber: import_api_logs.SeverityNumber.TRACE,
@@ -1613,7 +1611,47 @@ var WinstonOtelFastify = class WinstonOtelFastify2 {
1613
1611
  }
1614
1612
  }
1615
1613
  child() {
1616
- return new WinstonOtelFastify2(process.env);
1614
+ return new WinstonOtelFastify2();
1615
+ }
1616
+ };
1617
+
1618
+ // src/infra/adapters/observability/otel/opentelemetry.ts
1619
+ var import_exporter_logs_otlp_proto = require("@opentelemetry/exporter-logs-otlp-proto");
1620
+ var import_exporter_metrics_otlp_proto = require("@opentelemetry/exporter-metrics-otlp-proto");
1621
+ var import_exporter_trace_otlp_proto = require("@opentelemetry/exporter-trace-otlp-proto");
1622
+ var import_resources = require("@opentelemetry/resources");
1623
+ var import_sdk_logs = require("@opentelemetry/sdk-logs");
1624
+ var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
1625
+ var import_sdk_node = require("@opentelemetry/sdk-node");
1626
+ var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
1627
+ var OpenTelemetry = class OpenTelemetry2 {
1628
+ static {
1629
+ __name(this, "OpenTelemetry");
1630
+ }
1631
+ env;
1632
+ sdk;
1633
+ constructor(env) {
1634
+ this.env = env;
1635
+ this.sdk = new import_sdk_node.NodeSDK({
1636
+ resource: new import_resources.Resource({
1637
+ [import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: this.env.OTEL_SERVICE_NAME,
1638
+ [import_semantic_conventions.SEMRESATTRS_SERVICE_VERSION]: this.env.OTEL_SERVICE_VERSION
1639
+ }),
1640
+ traceExporter: new import_exporter_trace_otlp_proto.OTLPTraceExporter({
1641
+ url: this.env.OTEL_OTLP_TRACES_EXPORTER_URL
1642
+ }),
1643
+ logRecordProcessor: new import_sdk_logs.BatchLogRecordProcessor(new import_exporter_logs_otlp_proto.OTLPLogExporter({
1644
+ url: this.env.OTEL_OTLP_LOGS_EXPORTER_URL
1645
+ })),
1646
+ metricReader: new import_sdk_metrics.PeriodicExportingMetricReader({
1647
+ exporter: new import_exporter_metrics_otlp_proto.OTLPMetricExporter({
1648
+ url: this.env.OTEL_OTLP_METRICS_EXPORTER_URL
1649
+ })
1650
+ })
1651
+ });
1652
+ }
1653
+ startSdk() {
1654
+ this.sdk.start();
1617
1655
  }
1618
1656
  };
1619
1657
 
@@ -1757,6 +1795,7 @@ var baseEnvSchema = import_zod.z.object({
1757
1795
  Inject,
1758
1796
  NotificationErrorInMemory,
1759
1797
  NotificationFactory,
1798
+ OpenTelemetry,
1760
1799
  SentryNotifier,
1761
1800
  Span,
1762
1801
  TracerGatewayOpentelemetry,