@backstage/backend-plugin-api 1.9.1-next.0 → 1.9.1-next.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
+ ## 1.9.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 90b572e: Adds an alpha `TracingService` to provide a unified interface for emitting trace spans across Backstage plugins.
8
+
3
9
  ## 1.9.1-next.0
4
10
 
5
11
  ### Patch Changes
@@ -15,9 +15,13 @@ const rootSystemMetadataServiceRef = backendPluginApi.createServiceRef({
15
15
  const metricsServiceRef = backendPluginApi.createServiceRef({
16
16
  id: "alpha.core.metrics"
17
17
  });
18
+ const tracingServiceRef = backendPluginApi.createServiceRef({
19
+ id: "alpha.core.tracing"
20
+ });
18
21
 
19
22
  exports.actionsRegistryServiceRef = actionsRegistryServiceRef;
20
23
  exports.actionsServiceRef = actionsServiceRef;
21
24
  exports.metricsServiceRef = metricsServiceRef;
22
25
  exports.rootSystemMetadataServiceRef = rootSystemMetadataServiceRef;
26
+ exports.tracingServiceRef = tracingServiceRef;
23
27
  //# sourceMappingURL=refs.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"refs.cjs.js","sources":["../../src/alpha/refs.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '@backstage/backend-plugin-api';\n\n/**\n * Service for calling distributed actions\n *\n * See {@link ActionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsServiceRef = createServiceRef<\n import('./ActionsService').ActionsService\n>({\n id: 'alpha.core.actions',\n});\n\n/**\n * Service for registering and managing distributed actions.\n *\n * See {@link ActionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsRegistryServiceRef = createServiceRef<\n import('./ActionsRegistryService').ActionsRegistryService\n>({\n id: 'alpha.core.actionsRegistry',\n});\n\n/**\n * Read information about your current Backstage deployment.\n * @alpha\n */\nexport const rootSystemMetadataServiceRef = createServiceRef<\n import('./RootSystemMetadataService').RootSystemMetadataService\n>({\n id: 'alpha.core.rootSystemMetadata',\n scope: 'root',\n});\n\n/**\n * Service for managing metrics.\n *\n * @alpha\n */\nexport const metricsServiceRef = createServiceRef<\n import('./MetricsService').MetricsService\n>({\n id: 'alpha.core.metrics',\n});\n"],"names":["createServiceRef"],"mappings":";;;;AA2BO,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAWM,MAAM,4BAA4BA,iCAAA,CAEvC;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAMM,MAAM,+BAA+BA,iCAAA,CAE1C;AAAA,EACA,EAAA,EAAI,+BAAA;AAAA,EACJ,KAAA,EAAO;AACT,CAAC;AAOM,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;;;;;;;"}
1
+ {"version":3,"file":"refs.cjs.js","sources":["../../src/alpha/refs.ts"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createServiceRef } from '@backstage/backend-plugin-api';\n\n/**\n * Service for calling distributed actions\n *\n * See {@link ActionsService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsServiceRef = createServiceRef<\n import('./ActionsService').ActionsService\n>({\n id: 'alpha.core.actions',\n});\n\n/**\n * Service for registering and managing distributed actions.\n *\n * See {@link ActionsRegistryService}\n * and {@link https://backstage.io/docs/backend-system/core-services/actions-registry | the service docs}\n * for more information.\n *\n * @alpha\n */\nexport const actionsRegistryServiceRef = createServiceRef<\n import('./ActionsRegistryService').ActionsRegistryService\n>({\n id: 'alpha.core.actionsRegistry',\n});\n\n/**\n * Read information about your current Backstage deployment.\n * @alpha\n */\nexport const rootSystemMetadataServiceRef = createServiceRef<\n import('./RootSystemMetadataService').RootSystemMetadataService\n>({\n id: 'alpha.core.rootSystemMetadata',\n scope: 'root',\n});\n\n/**\n * Service for managing metrics.\n *\n * @alpha\n */\nexport const metricsServiceRef = createServiceRef<\n import('./MetricsService').MetricsService\n>({\n id: 'alpha.core.metrics',\n});\n\n/**\n * Service for managing trace spans.\n *\n * See {@link TracingService} for the API surface.\n *\n * @alpha\n */\nexport const tracingServiceRef = createServiceRef<\n import('./TracingService').TracingService\n>({\n id: 'alpha.core.tracing',\n});\n"],"names":["createServiceRef"],"mappings":";;;;AA2BO,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAWM,MAAM,4BAA4BA,iCAAA,CAEvC;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AAMM,MAAM,+BAA+BA,iCAAA,CAE1C;AAAA,EACA,EAAA,EAAI,+BAAA;AAAA,EACJ,KAAA,EAAO;AACT,CAAC;AAOM,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;AASM,MAAM,oBAAoBA,iCAAA,CAE/B;AAAA,EACA,EAAA,EAAI;AACN,CAAC;;;;;;;;"}
package/dist/alpha.cjs.js CHANGED
@@ -8,4 +8,5 @@ exports.actionsRegistryServiceRef = refs.actionsRegistryServiceRef;
8
8
  exports.actionsServiceRef = refs.actionsServiceRef;
9
9
  exports.metricsServiceRef = refs.metricsServiceRef;
10
10
  exports.rootSystemMetadataServiceRef = refs.rootSystemMetadataServiceRef;
11
+ exports.tracingServiceRef = refs.tracingServiceRef;
11
12
  //# sourceMappingURL=alpha.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
1
+ {"version":3,"file":"alpha.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
package/dist/alpha.d.ts CHANGED
@@ -4,6 +4,7 @@ import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
4
4
  import { LoggerService, BackstageCredentials } from '@backstage/backend-plugin-api';
5
5
  import { JsonObject, JsonValue } from '@backstage/types';
6
6
  import { JSONSchema7 } from 'json-schema';
7
+ import { Request } from 'express';
7
8
 
8
9
  /** @public */
9
10
  interface RootSystemMetadataServicePluginInfo {
@@ -288,6 +289,76 @@ interface MetricsService {
288
289
  createObservableGauge<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceObservableGauge<TAttributes>;
289
290
  }
290
291
 
292
+ /**
293
+ * Attribute values that can be attached to spans.
294
+ *
295
+ * @alpha
296
+ */
297
+ type TracingServiceAttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
298
+ /**
299
+ * A set of key-value pairs that can be attached to spans.
300
+ *
301
+ * @alpha
302
+ */
303
+ interface TracingServiceAttributes {
304
+ [key: string]: TracingServiceAttributeValue | undefined;
305
+ }
306
+ /**
307
+ * The kind of operation a span represents.
308
+ *
309
+ * @alpha
310
+ */
311
+ type TracingServiceSpanKind = 'internal' | 'server' | 'client' | 'producer' | 'consumer';
312
+ /**
313
+ * The status of a span.
314
+ *
315
+ * @alpha
316
+ */
317
+ interface TracingServiceSpanStatus {
318
+ code: 'unset' | 'ok' | 'error';
319
+ message?: string;
320
+ }
321
+ /**
322
+ * A trace span. Provided to `startActiveSpan` so
323
+ * additional attributes or status can be set from within the callback.
324
+ *
325
+ * @alpha
326
+ */
327
+ interface TracingServiceSpan {
328
+ setAttribute(key: string, value: TracingServiceAttributeValue): void;
329
+ setStatus(status: TracingServiceSpanStatus): void;
330
+ }
331
+ /**
332
+ * Options for `startActiveSpan`.
333
+ *
334
+ * @alpha
335
+ */
336
+ interface TracingServiceSpanOptions {
337
+ /** Attributes to attach to the span. */
338
+ attributes?: TracingServiceAttributes;
339
+ /** The kind of span. */
340
+ kind?: TracingServiceSpanKind;
341
+ /**
342
+ * Authenticated principal source for span enrichment. Preferred when
343
+ * both `credentials` and `request` are supplied.
344
+ */
345
+ credentials?: BackstageCredentials;
346
+ /** HTTP request to extract credentials from for span enrichment. */
347
+ request?: Request<any, any, any, any, any>;
348
+ }
349
+ /**
350
+ * A service for emitting trace spans from a backend plugin.
351
+ *
352
+ * @alpha
353
+ */
354
+ interface TracingService {
355
+ /**
356
+ * Runs `fn` inside a new active span. The span is finished when `fn`
357
+ * resolves or throws.
358
+ */
359
+ startActiveSpan<T>(name: string, fn: (span: TracingServiceSpan) => T | Promise<T>, options?: TracingServiceSpanOptions): Promise<T>;
360
+ }
361
+
291
362
  /**
292
363
  * Service for calling distributed actions
293
364
  *
@@ -319,6 +390,14 @@ declare const rootSystemMetadataServiceRef: _backstage_backend_plugin_api.Servic
319
390
  * @alpha
320
391
  */
321
392
  declare const metricsServiceRef: _backstage_backend_plugin_api.ServiceRef<MetricsService, "plugin", "singleton">;
393
+ /**
394
+ * Service for managing trace spans.
395
+ *
396
+ * See {@link TracingService} for the API surface.
397
+ *
398
+ * @alpha
399
+ */
400
+ declare const tracingServiceRef: _backstage_backend_plugin_api.ServiceRef<TracingService, "plugin", "singleton">;
322
401
 
323
- export { actionsRegistryServiceRef, actionsServiceRef, metricsServiceRef, rootSystemMetadataServiceRef };
324
- export type { ActionsRegistryActionContext, ActionsRegistryActionExample, ActionsRegistryActionOptions, ActionsRegistryService, ActionsService, ActionsServiceAction, MetricAdvice, MetricAttributeValue, MetricAttributes, MetricOptions, MetricsService, MetricsServiceCounter, MetricsServiceGauge, MetricsServiceHistogram, MetricsServiceObservable, MetricsServiceObservableCallback, MetricsServiceObservableCounter, MetricsServiceObservableGauge, MetricsServiceObservableResult, MetricsServiceObservableUpDownCounter, MetricsServiceUpDownCounter, RootSystemMetadataService, RootSystemMetadataServicePluginInfo };
402
+ export { actionsRegistryServiceRef, actionsServiceRef, metricsServiceRef, rootSystemMetadataServiceRef, tracingServiceRef };
403
+ export type { ActionsRegistryActionContext, ActionsRegistryActionExample, ActionsRegistryActionOptions, ActionsRegistryService, ActionsService, ActionsServiceAction, MetricAdvice, MetricAttributeValue, MetricAttributes, MetricOptions, MetricsService, MetricsServiceCounter, MetricsServiceGauge, MetricsServiceHistogram, MetricsServiceObservable, MetricsServiceObservableCallback, MetricsServiceObservableCounter, MetricsServiceObservableGauge, MetricsServiceObservableResult, MetricsServiceObservableUpDownCounter, MetricsServiceUpDownCounter, RootSystemMetadataService, RootSystemMetadataServicePluginInfo, TracingService, TracingServiceAttributeValue, TracingServiceAttributes, TracingServiceSpan, TracingServiceSpanKind, TracingServiceSpanOptions, TracingServiceSpanStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "1.9.1-next.0",
3
+ "version": "1.9.1-next.1",
4
4
  "description": "Core API used by Backstage backend plugins",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -68,8 +68,8 @@
68
68
  "@backstage/cli-common": "0.2.2-next.0",
69
69
  "@backstage/config": "1.3.8-next.0",
70
70
  "@backstage/errors": "1.3.1-next.0",
71
- "@backstage/plugin-auth-node": "0.7.1-next.0",
72
- "@backstage/plugin-permission-common": "0.9.9-next.0",
71
+ "@backstage/plugin-auth-node": "0.7.1-next.1",
72
+ "@backstage/plugin-permission-common": "0.9.9-next.1",
73
73
  "@backstage/plugin-permission-node": "0.10.13-next.0",
74
74
  "@backstage/types": "1.2.2",
75
75
  "@types/express": "^4.17.6",
@@ -81,8 +81,8 @@
81
81
  "zod": "^3.25.76 || ^4.0.0"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/backend-test-utils": "1.11.3-next.0",
85
- "@backstage/cli": "0.36.2-next.0"
84
+ "@backstage/backend-test-utils": "1.11.3-next.2",
85
+ "@backstage/cli": "0.36.2-next.1"
86
86
  },
87
87
  "configSchema": "config.d.ts"
88
88
  }