Skip to content

Commit f51c916

Browse files
committed
fix: revert types/index.ts to original state
1 parent 45ffa9d commit f51c916

File tree

1 file changed

+13
-261
lines changed

1 file changed

+13
-261
lines changed

packages/metrics/src/types/index.ts

Lines changed: 13 additions & 261 deletions
Original file line numberDiff line numberDiff line change
@@ -1,261 +1,13 @@
1-
import type { MetricResolution, MetricUnit } from '../constants.js';
2-
3-
/**
4-
* Interface for the configuration service
5-
*/
6-
export interface ConfigServiceInterface {
7-
/**
8-
* Get the namespace from the configuration service
9-
*/
10-
getNamespace(): string | undefined;
11-
/**
12-
* Get the service name from the configuration service
13-
*/
14-
getServiceName(): string | undefined;
15-
}
16-
17-
/**
18-
* Dimensions are key-value pairs that are used to group metrics
19-
*/
20-
export type Dimensions = Record<string, string>;
21-
22-
/**
23-
* A dimension set is an array of dimension names
24-
*/
25-
export type DimensionSet = string[];
26-
27-
/**
28-
* Options for the Metrics constructor
29-
*/
30-
export interface MetricsOptions {
31-
/**
32-
* Custom configuration service
33-
*/
34-
customConfigService?: ConfigServiceInterface;
35-
/**
36-
* Default dimensions to be added to all metrics
37-
*/
38-
defaultDimensions?: Dimensions;
39-
/**
40-
* Function name to be used for the cold start metric
41-
*/
42-
functionName?: string;
43-
/**
44-
* Custom logger object used for emitting debug, warning, and error messages
45-
*/
46-
logger?: GenericLogger;
47-
/**
48-
* Namespace for the metrics
49-
*/
50-
namespace?: string;
51-
/**
52-
* Service name for the metrics
53-
*/
54-
serviceName?: string;
55-
/**
56-
* Whether this is a single metric instance
57-
*/
58-
singleMetric?: boolean;
59-
}
60-
61-
/**
62-
* Extra options for the logMetrics decorator
63-
*/
64-
export interface ExtraOptions {
65-
/**
66-
* Whether to capture a cold start metric
67-
*/
68-
captureColdStartMetric?: boolean;
69-
/**
70-
* Default dimensions to be added to all metrics
71-
*/
72-
defaultDimensions?: Dimensions;
73-
/**
74-
* Whether to throw an error if no metrics are emitted
75-
*/
76-
throwOnEmptyMetrics?: boolean;
77-
}
78-
79-
/**
80-
* Interface for the Metrics class
81-
*/
82-
export interface MetricsInterface {
83-
/**
84-
* Add a dimension to metrics
85-
*/
86-
addDimension(name: string, value: string): void;
87-
/**
88-
* Add multiple dimensions to metrics
89-
*/
90-
addDimensions(dimensions: Dimensions): void;
91-
/**
92-
* Add a metadata key-value pair to be included with metrics
93-
*/
94-
addMetadata(key: string, value: string): void;
95-
/**
96-
* Add a metric to the metrics buffer
97-
*/
98-
addMetric(
99-
name: string,
100-
unit: MetricUnit,
101-
value: number,
102-
resolution?: MetricResolution
103-
): void;
104-
/**
105-
* Immediately emit a cold start metric if this is a cold start invocation
106-
*/
107-
captureColdStartMetric(functionName?: string): void;
108-
/**
109-
* Clear all previously set default dimensions
110-
*/
111-
clearDefaultDimensions(): void;
112-
/**
113-
* Clear all the dimensions added to the Metrics instance
114-
*/
115-
clearDimensions(): void;
116-
/**
117-
* Clear all the metadata added to the Metrics instance
118-
*/
119-
clearMetadata(): void;
120-
/**
121-
* Clear all the metrics stored in the buffer
122-
*/
123-
clearMetrics(): void;
124-
/**
125-
* Check if there are stored metrics in the buffer
126-
*/
127-
hasStoredMetrics(): boolean;
128-
/**
129-
* Flush the stored metrics to standard output
130-
*/
131-
publishStoredMetrics(): void;
132-
/**
133-
* Serialize the stored metrics into a JSON object compliant with the Amazon CloudWatch EMF (Embedded Metric Format) schema
134-
*/
135-
serializeMetrics(): EmfOutput;
136-
/**
137-
* Set default dimensions that will be added to all metrics
138-
*/
139-
setDefaultDimensions(dimensions: Dimensions | undefined): void;
140-
/**
141-
* Set the flag to throw an error if no metrics are emitted
142-
*/
143-
setThrowOnEmptyMetrics(enabled: boolean): void;
144-
/**
145-
* Create a new Metrics instance configured to immediately flush a single metric
146-
*/
147-
singleMetric(): MetricsInterface;
148-
}
149-
150-
/**
151-
* Definition of a metric
152-
*/
153-
export interface MetricDefinition {
154-
/**
155-
* Name of the metric
156-
*/
157-
Name: string;
158-
/**
159-
* Unit of the metric
160-
*/
161-
Unit: MetricUnit;
162-
/**
163-
* Storage resolution of the metric
164-
*/
165-
StorageResolution?: MetricResolution;
166-
}
167-
168-
/**
169-
* Definition of a stored metric
170-
*/
171-
export interface StoredMetric {
172-
/**
173-
* Name of the metric
174-
*/
175-
name: string;
176-
/**
177-
* Resolution of the metric
178-
*/
179-
resolution: MetricResolution;
180-
/**
181-
* Unit of the metric
182-
*/
183-
unit: MetricUnit;
184-
/**
185-
* Value of the metric
186-
*/
187-
value: number | number[];
188-
}
189-
190-
/**
191-
* Storage for metrics before they are published
192-
*/
193-
export type StoredMetrics = Record<string, StoredMetric>;
194-
195-
/**
196-
* CloudWatch metrics object
197-
*/
198-
export interface CloudWatchMetrics {
199-
/**
200-
* Dimensions for the metrics
201-
*/
202-
Dimensions: DimensionSet[];
203-
/**
204-
* Metrics definitions
205-
*/
206-
Metrics: MetricDefinition[];
207-
/**
208-
* Namespace for the metrics
209-
*/
210-
Namespace: string;
211-
}
212-
213-
/**
214-
* AWS object in the EMF output
215-
*/
216-
export interface AwsObject {
217-
/**
218-
* CloudWatch metrics
219-
*/
220-
CloudWatchMetrics: CloudWatchMetrics[];
221-
/**
222-
* Timestamp for the metrics
223-
*/
224-
Timestamp: number;
225-
}
226-
227-
/**
228-
* EMF output object
229-
*/
230-
export interface EmfOutput {
231-
/**
232-
* AWS object
233-
*/
234-
_aws: AwsObject;
235-
/**
236-
* Additional properties
237-
*/
238-
[key: string]: unknown;
239-
}
240-
241-
/**
242-
* Generic logger interface
243-
*/
244-
export interface GenericLogger {
245-
/**
246-
* Log a debug message
247-
*/
248-
debug: (message: string) => void;
249-
/**
250-
* Log an error message
251-
*/
252-
error: (message: string) => void;
253-
/**
254-
* Log an info message
255-
*/
256-
info: (message: string) => void;
257-
/**
258-
* Log a warning message
259-
*/
260-
warn: (message: string) => void;
261-
}
1+
export type {
2+
MetricsOptions,
3+
Dimensions,
4+
EmfOutput,
5+
ExtraOptions,
6+
StoredMetrics,
7+
StoredMetric,
8+
MetricDefinition,
9+
MetricResolution,
10+
MetricUnit,
11+
MetricsInterface,
12+
} from './Metrics.js';
13+
export type { ConfigServiceInterface } from './ConfigServiceInterface.js';

0 commit comments

Comments
 (0)