@reactionary/core 0.2.10 → 0.2.11

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,15 +1,11 @@
1
- import { trace } from "@opentelemetry/api";
1
+ import { SpanStatusCode, trace } from "@opentelemetry/api";
2
2
  import { z } from "zod";
3
3
  import { getReactionaryMeter } from "../metrics/metrics.js";
4
4
  import { error, success } from "../schemas/result.js";
5
5
  const TRACER_NAME = "@reactionary";
6
6
  const TRACER_VERSION = "0.0.1";
7
- let globalTracer = null;
8
7
  function getTracer() {
9
- if (!globalTracer) {
10
- globalTracer = trace.getTracer(TRACER_NAME, TRACER_VERSION);
11
- }
12
- return globalTracer;
8
+ return trace.getTracer(TRACER_NAME, TRACER_VERSION);
13
9
  }
14
10
  class ReactionaryDecoratorOptions {
15
11
  constructor() {
@@ -102,9 +98,10 @@ function Reactionary(options) {
102
98
  validatedResult.meta.cache.hit = !!fromCache;
103
99
  validatedResult.meta.cache.key = cacheKey;
104
100
  }
105
- return result;
101
+ return validatedResult;
106
102
  } catch (err) {
107
103
  status = "error";
104
+ trace.getActiveSpan()?.setStatus({ code: SpanStatusCode.ERROR, message: errorToString(err) });
108
105
  const result = error({
109
106
  type: "Generic",
110
107
  message: errorToString(err)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/core",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "main": "index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "dependencies": {
@@ -19,7 +19,9 @@ export type Fail<E> = {
19
19
  trace: string;
20
20
  };
21
21
  };
22
- export type Result<T, E = Error> = Ok<T> | Fail<E>;
22
+ export type Result<T, E = {
23
+ type: string;
24
+ }> = Ok<T> | Fail<E>;
23
25
  /**
24
26
  * Utility function for asserting and unwrapping the value of a success.
25
27
  * It is an assert, so treat it as such (similar to any unwrap, assert or similar function).