@backstage/backend-plugin-api 1.7.0-next.1 → 1.7.1-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @backstage/backend-plugin-api
2
2
 
3
+ ## 1.7.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 1ee5b28: Adds an alpha `MetricsService` to provide a unified interface for metrics instrumentation across Backstage plugins.
8
+ - Updated dependencies
9
+ - @backstage/cli-common@0.2.0-next.0
10
+ - @backstage/config@1.3.6
11
+ - @backstage/errors@1.2.7
12
+ - @backstage/types@1.2.2
13
+ - @backstage/plugin-auth-node@0.6.14-next.0
14
+ - @backstage/plugin-permission-common@0.9.6
15
+ - @backstage/plugin-permission-node@0.10.11-next.0
16
+
17
+ ## 1.7.0
18
+
19
+ ### Minor Changes
20
+
21
+ - f1d29b4: Added support for extension point factories. This makes it possible to call `registerExtensionPoint` with a single options argument and provide a factory for the extension point rather than a direct implementation. The factory is passed a context with a `reportModuleStartupFailure` method that makes it possible for plugins to report and attribute startup errors to the module that consumed the extension point.
22
+ - bb9b471: Plugin IDs that do not match the standard format are deprecated (letters, digits, and dashes only, starting with a letter). Plugin IDs that do no match this format will be rejected in a future release.
23
+
24
+ In addition, plugin IDs that don't match the legacy pattern that also allows underscores, with be rejected.
25
+
26
+ ### Patch Changes
27
+
28
+ - 7455dae: Use node prefix on native imports
29
+ - 69d880e: Bump to latest zod to ensure it has the latest features
30
+ - Updated dependencies
31
+ - @backstage/cli-common@0.1.18
32
+ - @backstage/plugin-auth-node@0.6.13
33
+ - @backstage/plugin-permission-common@0.9.6
34
+ - @backstage/plugin-permission-node@0.10.10
35
+
3
36
  ## 1.7.0-next.1
4
37
 
5
38
  ### Minor Changes
@@ -12,8 +12,12 @@ const rootSystemMetadataServiceRef = backendPluginApi.createServiceRef({
12
12
  id: "alpha.core.rootSystemMetadata",
13
13
  scope: "root"
14
14
  });
15
+ const metricsServiceRef = backendPluginApi.createServiceRef({
16
+ id: "alpha.core.metrics"
17
+ });
15
18
 
16
19
  exports.actionsRegistryServiceRef = actionsRegistryServiceRef;
17
20
  exports.actionsServiceRef = actionsServiceRef;
21
+ exports.metricsServiceRef = metricsServiceRef;
18
22
  exports.rootSystemMetadataServiceRef = rootSystemMetadataServiceRef;
19
23
  //# 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"],"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;;;;;;"}
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;;;;;;;"}
package/dist/alpha.cjs.js CHANGED
@@ -6,5 +6,6 @@ var refs = require('./alpha/refs.cjs.js');
6
6
 
7
7
  exports.actionsRegistryServiceRef = refs.actionsRegistryServiceRef;
8
8
  exports.actionsServiceRef = refs.actionsServiceRef;
9
+ exports.metricsServiceRef = refs.metricsServiceRef;
9
10
  exports.rootSystemMetadataServiceRef = refs.rootSystemMetadataServiceRef;
10
11
  //# 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
@@ -84,6 +84,189 @@ interface ActionsService {
84
84
  }>;
85
85
  }
86
86
 
87
+ /**
88
+ * Attribute values that can be attached to metric measurements.
89
+ *
90
+ * @alpha
91
+ */
92
+ type MetricAttributeValue = string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>;
93
+ /**
94
+ * A set of key-value pairs that can be attached to metric measurements.
95
+ *
96
+ * @alpha
97
+ */
98
+ interface MetricAttributes {
99
+ [attributeKey: string]: MetricAttributeValue | undefined;
100
+ }
101
+ /**
102
+ * Advisory options that influence aggregation configuration.
103
+ *
104
+ * @alpha
105
+ */
106
+ interface MetricAdvice {
107
+ /**
108
+ * Hint the explicit bucket boundaries for histogram aggregation.
109
+ */
110
+ explicitBucketBoundaries?: number[];
111
+ }
112
+ /**
113
+ * Options for creating a metric instrument.
114
+ *
115
+ * @alpha
116
+ */
117
+ interface MetricOptions {
118
+ /**
119
+ * The description of the Metric.
120
+ */
121
+ description?: string;
122
+ /**
123
+ * The unit of the Metric values.
124
+ */
125
+ unit?: string;
126
+ /**
127
+ * Advisory options that influence aggregation configuration.
128
+ */
129
+ advice?: MetricAdvice;
130
+ }
131
+ /**
132
+ * A counter metric that only supports non-negative increments.
133
+ *
134
+ * @alpha
135
+ */
136
+ interface MetricsServiceCounter<TAttributes extends MetricAttributes = MetricAttributes> {
137
+ add(value: number, attributes?: TAttributes): void;
138
+ }
139
+ /**
140
+ * A counter metric that supports both positive and negative increments.
141
+ *
142
+ * @alpha
143
+ */
144
+ interface MetricsServiceUpDownCounter<TAttributes extends MetricAttributes = MetricAttributes> {
145
+ add(value: number, attributes?: TAttributes): void;
146
+ }
147
+ /**
148
+ * A histogram metric for recording distributions of values.
149
+ *
150
+ * @alpha
151
+ */
152
+ interface MetricsServiceHistogram<TAttributes extends MetricAttributes = MetricAttributes> {
153
+ record(value: number, attributes?: TAttributes): void;
154
+ }
155
+ /**
156
+ * A gauge metric for recording instantaneous values.
157
+ *
158
+ * @alpha
159
+ */
160
+ interface MetricsServiceGauge<TAttributes extends MetricAttributes = MetricAttributes> {
161
+ record(value: number, attributes?: TAttributes): void;
162
+ }
163
+ /**
164
+ * The result object passed to observable metric callbacks.
165
+ *
166
+ * @alpha
167
+ */
168
+ interface MetricsServiceObservableResult<TAttributes extends MetricAttributes = MetricAttributes> {
169
+ observe(value: number, attributes?: TAttributes): void;
170
+ }
171
+ /**
172
+ * A callback function for observable metrics. Called whenever a metric
173
+ * collection is initiated.
174
+ *
175
+ * @alpha
176
+ */
177
+ type MetricsServiceObservableCallback<TAttributes extends MetricAttributes = MetricAttributes> = (observableResult: MetricsServiceObservableResult<TAttributes>) => void | Promise<void>;
178
+ /**
179
+ * An observable metric instrument that reports values via callbacks.
180
+ *
181
+ * @alpha
182
+ */
183
+ interface MetricsServiceObservable<TAttributes extends MetricAttributes = MetricAttributes> {
184
+ addCallback(callback: MetricsServiceObservableCallback<TAttributes>): void;
185
+ removeCallback(callback: MetricsServiceObservableCallback<TAttributes>): void;
186
+ }
187
+ /**
188
+ * An observable counter metric that reports non-negative sums via callbacks.
189
+ *
190
+ * @alpha
191
+ */
192
+ type MetricsServiceObservableCounter<TAttributes extends MetricAttributes = MetricAttributes> = MetricsServiceObservable<TAttributes>;
193
+ /**
194
+ * An observable counter metric that reports sums that can go up or down
195
+ * via callbacks.
196
+ *
197
+ * @alpha
198
+ */
199
+ type MetricsServiceObservableUpDownCounter<TAttributes extends MetricAttributes = MetricAttributes> = MetricsServiceObservable<TAttributes>;
200
+ /**
201
+ * An observable gauge metric that reports instantaneous values via callbacks.
202
+ *
203
+ * @alpha
204
+ */
205
+ type MetricsServiceObservableGauge<TAttributes extends MetricAttributes = MetricAttributes> = MetricsServiceObservable<TAttributes>;
206
+ /**
207
+ * A service that provides a facility for emitting metrics.
208
+ *
209
+ * @alpha
210
+ */
211
+ interface MetricsService {
212
+ /**
213
+ * Creates a new counter metric.
214
+ *
215
+ * @param name - The name of the metric.
216
+ * @param opts - The options for the metric.
217
+ * @returns The counter metric.
218
+ */
219
+ createCounter<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceCounter<TAttributes>;
220
+ /**
221
+ * Creates a new up-down counter metric.
222
+ *
223
+ * @param name - The name of the metric.
224
+ * @param opts - The options for the metric.
225
+ * @returns The up-down counter metric.
226
+ */
227
+ createUpDownCounter<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceUpDownCounter<TAttributes>;
228
+ /**
229
+ * Creates a new histogram metric.
230
+ *
231
+ * @param name - The name of the metric.
232
+ * @param opts - The options for the metric.
233
+ * @returns The histogram metric.
234
+ */
235
+ createHistogram<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceHistogram<TAttributes>;
236
+ /**
237
+ * Creates a new gauge metric.
238
+ *
239
+ * @param name - The name of the metric.
240
+ * @param opts - The options for the metric.
241
+ * @returns The gauge metric.
242
+ */
243
+ createGauge<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceGauge<TAttributes>;
244
+ /**
245
+ * Creates a new observable counter metric.
246
+ *
247
+ * @param name - The name of the metric.
248
+ * @param opts - The options for the metric.
249
+ * @returns The observable counter metric.
250
+ */
251
+ createObservableCounter<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceObservableCounter<TAttributes>;
252
+ /**
253
+ * Creates a new observable up-down counter metric.
254
+ *
255
+ * @param name - The name of the metric.
256
+ * @param opts - The options for the metric.
257
+ * @returns The observable up-down counter metric.
258
+ */
259
+ createObservableUpDownCounter<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceObservableUpDownCounter<TAttributes>;
260
+ /**
261
+ * Creates a new observable gauge metric.
262
+ *
263
+ * @param name - The name of the metric.
264
+ * @param opts - The options for the metric.
265
+ * @returns The observable gauge metric.
266
+ */
267
+ createObservableGauge<TAttributes extends MetricAttributes = MetricAttributes>(name: string, opts?: MetricOptions): MetricsServiceObservableGauge<TAttributes>;
268
+ }
269
+
87
270
  /**
88
271
  * Service for calling distributed actions
89
272
  *
@@ -109,6 +292,12 @@ declare const actionsRegistryServiceRef: _backstage_backend_plugin_api.ServiceRe
109
292
  * @alpha
110
293
  */
111
294
  declare const rootSystemMetadataServiceRef: _backstage_backend_plugin_api.ServiceRef<RootSystemMetadataService, "root", "singleton">;
295
+ /**
296
+ * Service for managing metrics.
297
+ *
298
+ * @alpha
299
+ */
300
+ declare const metricsServiceRef: _backstage_backend_plugin_api.ServiceRef<MetricsService, "plugin", "singleton">;
112
301
 
113
- export { actionsRegistryServiceRef, actionsServiceRef, rootSystemMetadataServiceRef };
114
- export type { ActionsRegistryActionContext, ActionsRegistryActionOptions, ActionsRegistryService, ActionsService, ActionsServiceAction, RootSystemMetadataService, RootSystemMetadataServicePluginInfo };
302
+ export { actionsRegistryServiceRef, actionsServiceRef, metricsServiceRef, rootSystemMetadataServiceRef };
303
+ export type { ActionsRegistryActionContext, ActionsRegistryActionOptions, ActionsRegistryService, ActionsService, ActionsServiceAction, MetricAdvice, MetricAttributeValue, MetricAttributes, MetricOptions, MetricsService, MetricsServiceCounter, MetricsServiceGauge, MetricsServiceHistogram, MetricsServiceObservable, MetricsServiceObservableCallback, MetricsServiceObservableCounter, MetricsServiceObservableGauge, MetricsServiceObservableResult, MetricsServiceObservableUpDownCounter, MetricsServiceUpDownCounter, RootSystemMetadataService, RootSystemMetadataServicePluginInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/backend-plugin-api",
3
- "version": "1.7.0-next.1",
3
+ "version": "1.7.1-next.0",
4
4
  "description": "Core API used by Backstage backend plugins",
5
5
  "backstage": {
6
6
  "role": "node-library"
@@ -65,12 +65,12 @@
65
65
  "test": "backstage-cli package test"
66
66
  },
67
67
  "dependencies": {
68
- "@backstage/cli-common": "0.1.18-next.0",
68
+ "@backstage/cli-common": "0.2.0-next.0",
69
69
  "@backstage/config": "1.3.6",
70
70
  "@backstage/errors": "1.2.7",
71
- "@backstage/plugin-auth-node": "0.6.13-next.0",
72
- "@backstage/plugin-permission-common": "0.9.6-next.0",
73
- "@backstage/plugin-permission-node": "0.10.10-next.0",
71
+ "@backstage/plugin-auth-node": "0.6.14-next.0",
72
+ "@backstage/plugin-permission-common": "0.9.6",
73
+ "@backstage/plugin-permission-node": "0.10.11-next.0",
74
74
  "@backstage/types": "1.2.2",
75
75
  "@types/express": "^4.17.6",
76
76
  "@types/json-schema": "^7.0.6",
@@ -81,8 +81,8 @@
81
81
  "zod": "^3.25.76"
82
82
  },
83
83
  "devDependencies": {
84
- "@backstage/backend-test-utils": "1.10.5-next.0",
85
- "@backstage/cli": "0.35.4-next.1"
84
+ "@backstage/backend-test-utils": "1.11.1-next.0",
85
+ "@backstage/cli": "0.35.5-next.0"
86
86
  },
87
87
  "configSchema": "config.d.ts"
88
88
  }