diff --git a/packages/nodejs/.changesets/update-span-type-in-scopemanager.md b/packages/nodejs/.changesets/update-span-type-in-scopemanager.md new file mode 100644 index 00000000..ce661b63 --- /dev/null +++ b/packages/nodejs/.changesets/update-span-type-in-scopemanager.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "change" +--- + +Update the expected Span type in ScopeManager to `Span` from the `@appsignal/nodejs` package, rather than the `NodeSpan` from the `@appsignal/types` package. The type definition is the same, but now all Span types used by the Node.js integration are defined in the `@appsigna/nodejs` package. diff --git a/packages/nodejs/src/scope.ts b/packages/nodejs/src/scope.ts index 601ebf8c..6856e1b6 100644 --- a/packages/nodejs/src/scope.ts +++ b/packages/nodejs/src/scope.ts @@ -8,7 +8,8 @@ * Copyright 2018, Google LLC */ -import { NodeSpan, Func } from "@appsignal/types" +import { Func } from "@appsignal/types" +import { Span } from "./interfaces/span" import * as asyncHooks from "async_hooks" import { EventEmitter } from "events" import shimmer from "shimmer" @@ -32,8 +33,8 @@ type ContextWrapped = T & { [WRAPPED]?: boolean } * @class */ export class ScopeManager { - #roots: Map - #scopes: Map + #roots: Map + #scopes: Map #asyncHook: asyncHooks.AsyncHook constructor() { @@ -105,7 +106,7 @@ export class ScopeManager { /** * Returns the current active `Span`. */ - public active(): NodeSpan | undefined { + public active(): Span | undefined { const uid = asyncHooks.executionAsyncId() return this.#scopes.get(uid) } @@ -113,7 +114,7 @@ export class ScopeManager { /** * Sets the root `Span` */ - public setRoot(rootSpan: NodeSpan) { + public setRoot(rootSpan: Span) { const uid = asyncHooks.executionAsyncId() this.#roots.set(uid, rootSpan) } @@ -121,7 +122,7 @@ export class ScopeManager { /* * Returns the current root `Span`. */ - public root(): NodeSpan | undefined { + public root(): Span | undefined { const uid = asyncHooks.executionAsyncId() return this.#roots.get(uid) } @@ -129,7 +130,7 @@ export class ScopeManager { /** * Executes a given function within the context of a given `Span`. */ - public withContext(span: NodeSpan, fn: (s: NodeSpan) => T): T { + public withContext(span: Span, fn: (s: Span) => T): T { const uid = asyncHooks.executionAsyncId() const oldScope = this.#scopes.get(uid) const rootSpan = this.#roots.get(uid)