@gravito/ripple 3.1.0 → 4.0.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/README.md +260 -19
- package/dist/atlas/src/DB.d.ts +348 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +41 -0
- package/dist/atlas/src/connection/Connection.d.ts +112 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +180 -0
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +54 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +79 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +96 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +79 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +33 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/Repository.d.ts +247 -0
- package/dist/atlas/src/orm/index.d.ts +6 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +458 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +150 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +92 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +138 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +124 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +98 -0
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +91 -0
- package/dist/atlas/src/pool/PoolStrategy.d.ts +129 -0
- package/dist/atlas/src/pool/PoolWarmer.d.ts +92 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +643 -0
- package/dist/atlas/src/query/RelationshipResolver.d.ts +23 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/MigrationGenerator.d.ts +45 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/SchemaDiff.d.ts +73 -0
- package/dist/atlas/src/schema/TypeGenerator.d.ts +57 -0
- package/dist/atlas/src/schema/TypeWriter.d.ts +42 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/sharding/ShardingManager.d.ts +59 -0
- package/dist/atlas/src/types/index.d.ts +1182 -0
- package/dist/atlas/src/utils/CursorEncoding.d.ts +63 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +39 -0
- package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
- package/dist/core/src/Container.d.ts +86 -11
- package/dist/core/src/ErrorHandler.d.ts +3 -0
- package/dist/core/src/HookManager.d.ts +511 -4
- package/dist/core/src/PlanetCore.d.ts +89 -0
- package/dist/core/src/RequestContext.d.ts +97 -0
- package/dist/core/src/Router.d.ts +1 -5
- package/dist/core/src/ServiceProvider.d.ts +22 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +1 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +5 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +4 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +1 -0
- package/dist/core/src/adapters/types.d.ts +27 -0
- package/dist/core/src/cli/queue-commands.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +7 -12
- package/dist/core/src/engine/FastContext.d.ts +27 -2
- package/dist/core/src/engine/Gravito.d.ts +0 -1
- package/dist/core/src/engine/MinimalContext.d.ts +25 -2
- package/dist/core/src/engine/types.d.ts +9 -1
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
- package/dist/core/src/events/BackpressureManager.d.ts +215 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +219 -0
- package/dist/core/src/events/EventBackend.d.ts +12 -0
- package/dist/core/src/events/EventOptions.d.ts +204 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +301 -0
- package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
- package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
- package/dist/core/src/events/RetryScheduler.d.ts +104 -0
- package/dist/core/src/events/WorkerPool.d.ts +98 -0
- package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
- package/dist/core/src/events/aggregation/types.d.ts +117 -0
- package/dist/core/src/events/index.d.ts +25 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +332 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
- package/dist/core/src/events/observability/index.d.ts +24 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +134 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/index.d.ts +1 -0
- package/dist/core/src/health/HealthProvider.d.ts +67 -0
- package/dist/core/src/http/types.d.ts +40 -0
- package/dist/core/src/index.d.ts +25 -4
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/observability/Metrics.d.ts +244 -0
- package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +350 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/index.js +6709 -9888
- package/dist/index.js.map +64 -62
- package/dist/photon/src/index.d.ts +19 -0
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +50 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +161 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/dist/proto/ripple.proto +120 -0
- package/dist/ripple/src/RippleServer.d.ts +64 -445
- package/dist/ripple/src/channels/ChannelManager.d.ts +25 -10
- package/dist/ripple/src/drivers/NATSDriver.d.ts +87 -0
- package/dist/ripple/src/drivers/RedisDriver.d.ts +30 -1
- package/dist/ripple/src/drivers/index.d.ts +1 -0
- package/dist/ripple/src/engines/BunEngine.d.ts +98 -0
- package/dist/ripple/src/engines/IRippleEngine.d.ts +205 -0
- package/dist/ripple/src/engines/UWebSocketsEngine.d.ts +97 -0
- package/dist/ripple/src/engines/WsEngine.d.ts +69 -0
- package/dist/ripple/src/engines/index.d.ts +15 -0
- package/dist/ripple/src/index.d.ts +2 -0
- package/dist/ripple/src/middleware/InterceptorManager.d.ts +21 -0
- package/dist/ripple/src/observability/RippleMetrics.d.ts +24 -0
- package/dist/ripple/src/reliability/AckManager.d.ts +48 -0
- package/dist/ripple/src/serializers/ISerializer.d.ts +39 -0
- package/dist/ripple/src/serializers/JsonSerializer.d.ts +19 -0
- package/dist/ripple/src/serializers/ProtobufSerializer.d.ts +41 -0
- package/dist/ripple/src/serializers/index.d.ts +3 -0
- package/dist/ripple/src/tracking/SessionManager.d.ts +104 -0
- package/dist/ripple/src/tracking/index.d.ts +1 -0
- package/dist/ripple/src/types.d.ts +188 -12
- package/dist/ripple/src/utils/MessageSerializer.d.ts +33 -23
- package/dist/ripple/src/utils/TokenBucket.d.ts +25 -0
- package/package.json +25 -8
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Pool Metrics Recorder for OpenTelemetry integration.
|
|
3
|
+
*
|
|
4
|
+
* Tracks Worker Pool statistics and emits OpenTelemetry metrics.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
import type { Meter } from '@opentelemetry/api';
|
|
9
|
+
/**
|
|
10
|
+
* Worker job status for metrics.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum WorkerJobStatus {
|
|
13
|
+
COMPLETED = "completed",
|
|
14
|
+
FAILED = "failed"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Stream Worker Metrics Recorder.
|
|
18
|
+
*
|
|
19
|
+
* Collects and records metrics related to Worker Pool execution:
|
|
20
|
+
* - Pool size and utilization
|
|
21
|
+
* - Job execution duration
|
|
22
|
+
* - Job success/failure counts
|
|
23
|
+
* - Queue depth
|
|
24
|
+
*/
|
|
25
|
+
export declare class StreamWorkerMetrics {
|
|
26
|
+
private meter;
|
|
27
|
+
private jobDurationHistogram?;
|
|
28
|
+
private jobCounterCompleted?;
|
|
29
|
+
constructor(meter: Meter);
|
|
30
|
+
/**
|
|
31
|
+
* Initialize OpenTelemetry metrics.
|
|
32
|
+
*/
|
|
33
|
+
private initializeMetrics;
|
|
34
|
+
/**
|
|
35
|
+
* Record job execution duration.
|
|
36
|
+
*
|
|
37
|
+
* @param durationSeconds - Duration in seconds
|
|
38
|
+
* @param status - Job status (completed or failed)
|
|
39
|
+
* @param queue - Queue name
|
|
40
|
+
*/
|
|
41
|
+
recordJobDuration(durationSeconds: number, status: WorkerJobStatus, queue?: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Record pool size change.
|
|
44
|
+
*
|
|
45
|
+
* @param poolSize - Current pool size
|
|
46
|
+
* @param callback - Optional callback to fetch pool size dynamically
|
|
47
|
+
*/
|
|
48
|
+
setPoolSizeProvider(callback: () => number): void;
|
|
49
|
+
private poolSizeCallback?;
|
|
50
|
+
/**
|
|
51
|
+
* Get current pool size.
|
|
52
|
+
*/
|
|
53
|
+
getPoolSize(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Record queue depth change.
|
|
56
|
+
*
|
|
57
|
+
* @param depth - Current queue depth
|
|
58
|
+
* @param callback - Optional callback to fetch queue depth dynamically
|
|
59
|
+
*/
|
|
60
|
+
setQueueDepthProvider(callback: () => number): void;
|
|
61
|
+
private queueDepthCallback?;
|
|
62
|
+
/**
|
|
63
|
+
* Get current queue depth.
|
|
64
|
+
*/
|
|
65
|
+
getQueueDepth(): number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Worker Metrics Recorder interface for dependency injection.
|
|
69
|
+
*/
|
|
70
|
+
export interface WorkerMetricsRecorder {
|
|
71
|
+
recordJobDuration(durationSeconds: number, status: WorkerJobStatus, queue?: string): void;
|
|
72
|
+
setPoolSizeProvider(callback: () => number): void;
|
|
73
|
+
setQueueDepthProvider(callback: () => number): void;
|
|
74
|
+
getPoolSize(): number;
|
|
75
|
+
getQueueDepth(): number;
|
|
76
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
export { EventMetrics } from './EventMetrics';
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export { EventTracer } from './EventTracer';
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export { EventTracing, type EventTracingConfig, getEventTracing } from './EventTracing';
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export { type ObservabilityConfig, ObservableHookManager } from './ObservableHookManager';
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export { OTelEventMetrics, type QueueDepthCallback } from './OTelEventMetrics';
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export { StreamWorkerMetrics, WorkerJobStatus, type WorkerMetricsRecorder, } from './StreamWorkerMetrics';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal metric types for event observability.
|
|
3
|
+
* Avoids importing @gravito/monitor from core to prevent circular dependency.
|
|
4
|
+
* Runtime implementations are provided by @gravito/monitor MetricsRegistry.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface EventMetricCounter {
|
|
9
|
+
inc(labels: Record<string, string>): void;
|
|
10
|
+
}
|
|
11
|
+
export interface EventMetricGauge {
|
|
12
|
+
set(value: number, labels: Record<string, string>): void;
|
|
13
|
+
}
|
|
14
|
+
export interface EventMetricHistogram {
|
|
15
|
+
observe(value: number, labels: Record<string, string>): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { ActionCallback } from '../HookManager';
|
|
2
|
+
import type { BackpressureConfig } from './BackpressureManager';
|
|
3
|
+
import type { EventOptions } from './EventOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Event task for priority queue processing.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface EventTask {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for this event task.
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Event hook name.
|
|
15
|
+
*/
|
|
16
|
+
hook: string;
|
|
17
|
+
/**
|
|
18
|
+
* Event payload/arguments.
|
|
19
|
+
*/
|
|
20
|
+
args: unknown;
|
|
21
|
+
/**
|
|
22
|
+
* Event options.
|
|
23
|
+
*/
|
|
24
|
+
options: EventOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Callbacks to execute for this event.
|
|
27
|
+
*/
|
|
28
|
+
callbacks: ActionCallback[];
|
|
29
|
+
/**
|
|
30
|
+
* Timestamp when the event was created.
|
|
31
|
+
*/
|
|
32
|
+
createdAt: number;
|
|
33
|
+
/**
|
|
34
|
+
* Timestamp when the event was enqueued (added to the queue).
|
|
35
|
+
* Used for priority escalation calculations.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
enqueuedAt: number;
|
|
39
|
+
/**
|
|
40
|
+
* Partition key for ordering (if applicable).
|
|
41
|
+
*/
|
|
42
|
+
partitionKey?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Number of retry attempts made.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
retryCount?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Timestamp when the event first failed.
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
firstFailedAt?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Last error encountered.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
lastError?: Error;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Strategy for handling backpressure when the queue is full.
|
|
61
|
+
*/
|
|
62
|
+
export type BackpressureStrategy = 'reject' | 'drop-oldest' | 'drop-newest' | 'ignore';
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for the event priority queue.
|
|
65
|
+
*/
|
|
66
|
+
export interface EventQueueConfig {
|
|
67
|
+
/**
|
|
68
|
+
* Maximum number of pending events in the queue.
|
|
69
|
+
* If exceeded, the backpressure strategy is applied.
|
|
70
|
+
* @default undefined (unbounded)
|
|
71
|
+
*/
|
|
72
|
+
maxSize?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Strategy to use when the queue is full.
|
|
75
|
+
* - 'reject': Throw an error (default)
|
|
76
|
+
* - 'drop-oldest': Drop the oldest lowest-priority event
|
|
77
|
+
* - 'drop-newest': Drop the incoming event
|
|
78
|
+
* - 'ignore': Silently drop the incoming event
|
|
79
|
+
* @default 'reject'
|
|
80
|
+
*/
|
|
81
|
+
strategy?: BackpressureStrategy;
|
|
82
|
+
/**
|
|
83
|
+
* Advanced backpressure management configuration.
|
|
84
|
+
* When enabled, provides state-based flow control with multi-strategy support.
|
|
85
|
+
* If not provided, falls back to simple strategy-based backpressure.
|
|
86
|
+
* @default undefined (disabled, uses simple strategy)
|
|
87
|
+
*/
|
|
88
|
+
backpressure?: BackpressureConfig;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Multi-priority queue depth snapshot (FS-103)
|
|
92
|
+
* Represents the current queue depth for each priority level.
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export interface MultiPriorityQueueDepth {
|
|
96
|
+
/** Queue depth for CRITICAL priority events */
|
|
97
|
+
critical: number;
|
|
98
|
+
/** Queue depth for HIGH priority events */
|
|
99
|
+
high: number;
|
|
100
|
+
/** Queue depth for NORMAL priority events */
|
|
101
|
+
normal: number;
|
|
102
|
+
/** Queue depth for LOW priority events */
|
|
103
|
+
low: number;
|
|
104
|
+
/** Total queue depth across all priorities */
|
|
105
|
+
total: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Window adjustment record for backpressure feedback (FS-103)
|
|
109
|
+
* Records when and why the aggregation window was adjusted.
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export interface WindowAdjustment {
|
|
113
|
+
/** Timestamp of the adjustment */
|
|
114
|
+
timestamp: number;
|
|
115
|
+
/** Previous window size in milliseconds */
|
|
116
|
+
from: number;
|
|
117
|
+
/** New window size in milliseconds */
|
|
118
|
+
to: number;
|
|
119
|
+
/** Backpressure state that triggered the adjustment */
|
|
120
|
+
reason: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Dead letter queue routing decision (FS-103)
|
|
124
|
+
* Determines whether an event should be routed to the DLQ.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export interface DeadLetterDecision {
|
|
128
|
+
/** Whether the event should be routed to DLQ */
|
|
129
|
+
shouldRoute: boolean;
|
|
130
|
+
/** Reason for the decision (if applicable) */
|
|
131
|
+
reason?: string;
|
|
132
|
+
/** Suggested retry strategy */
|
|
133
|
+
retryStrategy?: 'immediate' | 'delayed' | 'dlq-only';
|
|
134
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ServiceKey } from '../Container';
|
|
2
|
+
/**
|
|
3
|
+
* CircularDependencyException - Thrown when the container detects an infinite loop.
|
|
4
|
+
*
|
|
5
|
+
* @module @gravito/core
|
|
6
|
+
*/
|
|
7
|
+
export declare class CircularDependencyException extends Error {
|
|
8
|
+
constructor(key: ServiceKey, stack: ServiceKey[]);
|
|
9
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview HealthProvider - Cloud-native health checks
|
|
3
|
+
*
|
|
4
|
+
* Provides liveness and readiness probes for Kubernetes and cloud deployments
|
|
5
|
+
*
|
|
6
|
+
* @module @gravito/core/health
|
|
7
|
+
* @since 2.2.0
|
|
8
|
+
*/
|
|
9
|
+
import type { Container } from '../Container';
|
|
10
|
+
import type { PlanetCore } from '../PlanetCore';
|
|
11
|
+
import { ServiceProvider } from '../ServiceProvider';
|
|
12
|
+
/**
|
|
13
|
+
* Health check result
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface HealthCheckResult {
|
|
17
|
+
/** Health status */
|
|
18
|
+
status: 'healthy' | 'unhealthy';
|
|
19
|
+
/** Optional message */
|
|
20
|
+
message?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Health check function interface
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export interface HealthCheck {
|
|
27
|
+
/** Unique name for this check */
|
|
28
|
+
name: string;
|
|
29
|
+
/** Check function that returns health status */
|
|
30
|
+
check(): Promise<HealthCheckResult>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* HealthProvider - Provides /health/liveness and /health/readiness endpoints
|
|
34
|
+
*
|
|
35
|
+
* - Liveness: Always returns 200 OK (just checks if server is running)
|
|
36
|
+
* - Readiness: Returns 200 if all checks are healthy, 503 otherwise
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export declare class HealthProvider extends ServiceProvider {
|
|
41
|
+
private checks;
|
|
42
|
+
register(container: Container): void;
|
|
43
|
+
/**
|
|
44
|
+
* Register a health check
|
|
45
|
+
*
|
|
46
|
+
* @param check - The health check to register
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const health = core.container.make<HealthProvider>('health')
|
|
51
|
+
* health.registerCheck({
|
|
52
|
+
* name: 'database',
|
|
53
|
+
* check: async () => {
|
|
54
|
+
* try {
|
|
55
|
+
* await db.ping()
|
|
56
|
+
* return { status: 'healthy' }
|
|
57
|
+
* } catch {
|
|
58
|
+
* return { status: 'unhealthy', message: 'DB unreachable' }
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
registerCheck(check: HealthCheck): void;
|
|
65
|
+
boot(core: PlanetCore): void;
|
|
66
|
+
}
|
|
67
|
+
export default HealthProvider;
|
|
@@ -57,6 +57,13 @@ export interface GravitoVariables {
|
|
|
57
57
|
* Cookie jar for managing response cookies
|
|
58
58
|
*/
|
|
59
59
|
cookieJar?: unknown;
|
|
60
|
+
/**
|
|
61
|
+
* Middleware scope tracking for Orbit isolation
|
|
62
|
+
* Tracks which Orbit/scope this request belongs to
|
|
63
|
+
* Used to prevent cross-Orbit middleware contamination
|
|
64
|
+
* @since 2.3.0
|
|
65
|
+
*/
|
|
66
|
+
middlewareScope?: string;
|
|
60
67
|
/** @deprecated Use ctx.route() instead */
|
|
61
68
|
route?: unknown;
|
|
62
69
|
[key: string]: unknown;
|
|
@@ -85,6 +92,20 @@ export interface GravitoRequest {
|
|
|
85
92
|
readonly method: string;
|
|
86
93
|
/** Request path without query string */
|
|
87
94
|
readonly path: string;
|
|
95
|
+
/**
|
|
96
|
+
* Route pattern (e.g., /users/:id) for the matched route
|
|
97
|
+
*
|
|
98
|
+
* This provides the parameterized route pattern instead of the concrete path,
|
|
99
|
+
* which is critical for preventing high cardinality issues in metrics systems.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // For request: GET /users/123
|
|
104
|
+
* ctx.req.path // => "/users/123"
|
|
105
|
+
* ctx.req.routePattern // => "/users/:id"
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
readonly routePattern?: string;
|
|
88
109
|
/**
|
|
89
110
|
* Get a route parameter value
|
|
90
111
|
* @param name - Parameter name (e.g., 'id' for route '/users/:id')
|
|
@@ -291,6 +312,25 @@ export interface GravitoContext<V extends GravitoVariables = GravitoVariables> {
|
|
|
291
312
|
* ```
|
|
292
313
|
*/
|
|
293
314
|
readonly native: unknown;
|
|
315
|
+
/**
|
|
316
|
+
* Access the RequestScopeManager for this request
|
|
317
|
+
* Services resolved through this manager are scoped to the HTTP request lifetime.
|
|
318
|
+
*/
|
|
319
|
+
requestScope(): any;
|
|
320
|
+
/**
|
|
321
|
+
* Resolve or create a request-scoped service
|
|
322
|
+
*
|
|
323
|
+
* @param key - Service key (string or symbol)
|
|
324
|
+
* @param factory - Factory function to create the service if not cached
|
|
325
|
+
* @returns The cached or newly created service instance
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* // Subsequent calls in the same request return the same instance
|
|
330
|
+
* const cache = ctx.scoped('product:cache', () => new RequestProductCache())
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
scoped<T>(key: string | symbol, factory: () => T): T;
|
|
294
334
|
}
|
|
295
335
|
/**
|
|
296
336
|
* Next function for middleware chain
|
package/dist/core/src/index.d.ts
CHANGED
|
@@ -17,16 +17,32 @@ export type { AdapterConfig, AdapterFactory, HttpAdapter, RouteDefinition } from
|
|
|
17
17
|
export { isHttpAdapter } from './adapters/types';
|
|
18
18
|
export type { ContentfulStatusCode, GravitoContext, GravitoErrorHandler, GravitoHandler, GravitoMiddleware, GravitoNext, GravitoNotFoundHandler, GravitoRequest, GravitoVariables, HttpMethod, StatusCode, ValidationTarget, } from './http/types';
|
|
19
19
|
export { Application, type ApplicationConfig } from './Application';
|
|
20
|
+
export { type CommandHandler, CommandKernel } from './CommandKernel';
|
|
20
21
|
export { ConfigManager } from './ConfigManager';
|
|
21
|
-
export { Container, type Factory } from './Container';
|
|
22
|
+
export { Container, type Factory, type ServiceKey, type ServiceMap } from './Container';
|
|
23
|
+
export { RequestScopeManager } from './Container/RequestScopeManager';
|
|
24
|
+
export { RequestScopeMetrics, RequestScopeMetricsCollector, type RequestScopeObserver, } from './Container/RequestScopeMetrics';
|
|
25
|
+
export { registerQueueCommands } from './cli/queue-commands';
|
|
22
26
|
export { codeFromStatus, ErrorHandler, type ErrorHandlerDeps, messageFromStatus, } from './ErrorHandler';
|
|
23
27
|
export { EventManager } from './EventManager';
|
|
28
|
+
export { cleanupRequestScopeOnError, detectRequestScopeLeaks, extractRequestScopeErrorContext, RequestScopeCleanupError, type RequestScopeErrorContext, withRequestScopeCleanup, } from './error-handling/RequestScopeErrorContext';
|
|
29
|
+
export type { CircuitBreakerOptions, DLQEntry, DLQFilter, EventBackend, EventOptions, EventTask, } from './events';
|
|
30
|
+
export { CircuitBreaker, CircuitBreakerState, DEFAULT_EVENT_OPTIONS, DeadLetterQueue, EventPriorityQueue, } from './events';
|
|
31
|
+
export type { EventTracingConfig, ObservabilityConfig, QueueDepthCallback, } from './events/observability';
|
|
32
|
+
export { EventMetrics, EventTracer, EventTracing, getEventTracing, ObservableHookManager, OTelEventMetrics, } from './events/observability';
|
|
33
|
+
export { type DashboardSnapshot, type ErrorStats, type JobEvent, QueueDashboard, type QueueDashboardConfig, type QueueMetrics, type WorkerMetrics as QueueWorkerMetrics, } from './observability/QueueDashboard';
|
|
24
34
|
export * from './exceptions';
|
|
25
35
|
export { type GlobalErrorHandlersMode, type GlobalProcessErrorHandlerContext, type GlobalProcessErrorKind, type RegisterGlobalErrorHandlersOptions, registerGlobalErrorHandlers, } from './GlobalErrorHandlers';
|
|
26
36
|
export { type GravitoManifest, GravitoServer } from './GravitoServer';
|
|
27
|
-
export type { ActionCallback, FilterCallback } from './HookManager';
|
|
28
|
-
export { HookManager } from './HookManager';
|
|
29
|
-
export
|
|
37
|
+
export type { ActionCallback, FilterCallback, ListenerInfo, ListenerOptions } from './HookManager';
|
|
38
|
+
export { HookManager, type HookManagerConfig } from './HookManager';
|
|
39
|
+
export type { HealthCheck, HealthCheckResult } from './health/HealthProvider';
|
|
40
|
+
export { HealthProvider } from './health/HealthProvider';
|
|
41
|
+
export type { DumpOptions } from './helpers';
|
|
42
|
+
export { Arr, abort, abortIf, abortUnless, app, blank, config, DumpDieError, dd, dump, env, filled, hasApp, logger, router, Str, setApp, tap, throwIf, throwUnless, value, } from './helpers';
|
|
43
|
+
export * from './helpers/data';
|
|
44
|
+
export * from './helpers/errors';
|
|
45
|
+
export * from './helpers/response';
|
|
30
46
|
export { CookieJar, type CookieOptions } from './http/CookieJar';
|
|
31
47
|
export { deleteCookie, getCookie, setCookie } from './http/cookie';
|
|
32
48
|
export { type BodySizeLimitOptions, bodySizeLimit } from './http/middleware/BodySizeLimit';
|
|
@@ -35,12 +51,17 @@ export { type CsrfOptions, csrfProtection, getCsrfToken } from './http/middlewar
|
|
|
35
51
|
export { createHeaderGate, type HeaderTokenGateOptions, type RequireHeaderTokenOptions, requireHeaderToken, } from './http/middleware/HeaderTokenGate';
|
|
36
52
|
export { type HstsOptions, type SecurityHeadersOptions, securityHeaders, } from './http/middleware/SecurityHeaders';
|
|
37
53
|
export { ThrottleRequests } from './http/middleware/ThrottleRequests';
|
|
54
|
+
export * as instrumentation from './instrumentation';
|
|
55
|
+
export { DEFAULT_CONFIG as OTEL_DEFAULT_CONFIG, getMeter, getOpenTelemetrySDK, getTracer as getOtelTracer, isOpenTelemetryInitialized, type MetricsConfig as OtelMetricsConfig, type MetricsExporter, type OpenTelemetryConfig, type OpenTelemetrySDK, OTEL_ENV_VARS, resetOpenTelemetry, setupOpenTelemetry, shutdownOpenTelemetry, type TracingConfig as OtelTracingConfig, type TracingExporter, } from './instrumentation';
|
|
38
56
|
export type { Listener, ShouldQueue } from './Listener';
|
|
39
57
|
export type { Logger } from './Logger';
|
|
40
58
|
export { ConsoleLogger } from './Logger';
|
|
41
59
|
export { type CacheService, type ErrorHandlerContext, type GravitoConfig, type GravitoOrbit, PlanetCore, type ViewService, } from './PlanetCore';
|
|
60
|
+
export { RequestContext, type RequestContextData, } from './RequestContext';
|
|
42
61
|
export { Route } from './Route';
|
|
43
62
|
export { type ControllerClass, FORM_REQUEST_SYMBOL, type FormRequestClass, type FormRequestLike, RouteGroup, type RouteHandler, type RouteOptions, Router, } from './Router';
|
|
63
|
+
export type { DLQManagerFilter, DLQRecord, DLQStats, RetryPolicy } from './reliability';
|
|
64
|
+
export { DeadLetterQueueManager, getDefaultRetryPolicy, getPresetRetryPolicy, RetryEngine, } from './reliability';
|
|
44
65
|
export { ServiceProvider } from './ServiceProvider';
|
|
45
66
|
export { Encrypter, type EncrypterOptions } from './security/Encrypter';
|
|
46
67
|
export type { Channel, ShouldBroadcast } from './types/events';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/core - Instrumentation Module
|
|
3
|
+
*
|
|
4
|
+
* 提供 OpenTelemetry SDK 集成功能,包括分佈式追蹤與指標收集。
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import {
|
|
9
|
+
* setupOpenTelemetry,
|
|
10
|
+
* getOpenTelemetrySDK,
|
|
11
|
+
* getTracer,
|
|
12
|
+
* getMeter
|
|
13
|
+
* } from '@gravito/core'
|
|
14
|
+
*
|
|
15
|
+
* // 初始化 SDK
|
|
16
|
+
* await setupOpenTelemetry({
|
|
17
|
+
* serviceName: 'my-service',
|
|
18
|
+
* tracing: { enabled: true, exporter: 'jaeger' },
|
|
19
|
+
* metrics: { enabled: true, exporter: 'prometheus' }
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* // 獲取 Tracer
|
|
23
|
+
* const tracer = await getTracer('my-module')
|
|
24
|
+
* const span = tracer.startSpan('my-operation')
|
|
25
|
+
*
|
|
26
|
+
* // 獲取 Meter
|
|
27
|
+
* const meter = await getMeter('my-module')
|
|
28
|
+
* const counter = meter.createCounter('request_count')
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @packageDocumentation
|
|
32
|
+
*/
|
|
33
|
+
export { getMeter, getOpenTelemetrySDK, getTracer, isOpenTelemetryInitialized, resetOpenTelemetry, setupOpenTelemetry, shutdownOpenTelemetry, } from './opentelemetry';
|
|
34
|
+
export type { MetricsConfig, MetricsExporter, OpenTelemetryConfig, OpenTelemetrySDK, TracingConfig, TracingExporter, } from './types';
|
|
35
|
+
export { DEFAULT_CONFIG, OTEL_ENV_VARS } from './types';
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gravito/core - OpenTelemetry SDK 集成
|
|
3
|
+
*
|
|
4
|
+
* 提供 OpenTelemetry 的初始化、配置與管理功能。
|
|
5
|
+
* 支援動態導入以實現可選依賴的優雅降級。
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { setupOpenTelemetry } from '@gravito/core'
|
|
10
|
+
*
|
|
11
|
+
* const sdk = await setupOpenTelemetry({
|
|
12
|
+
* serviceName: 'my-service',
|
|
13
|
+
* serviceVersion: '1.0.0',
|
|
14
|
+
* tracing: {
|
|
15
|
+
* enabled: true,
|
|
16
|
+
* exporter: 'jaeger',
|
|
17
|
+
* samplingRate: 0.1
|
|
18
|
+
* },
|
|
19
|
+
* metrics: {
|
|
20
|
+
* enabled: true,
|
|
21
|
+
* exporter: 'prometheus',
|
|
22
|
+
* prometheusPort: 9090
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @packageDocumentation
|
|
28
|
+
*/
|
|
29
|
+
import { type MetricsConfig, type OpenTelemetryConfig, type OpenTelemetrySDK, type TracingConfig } from './types';
|
|
30
|
+
export type { MetricsConfig, OpenTelemetryConfig, OpenTelemetrySDK, TracingConfig };
|
|
31
|
+
/**
|
|
32
|
+
* 初始化 OpenTelemetry SDK
|
|
33
|
+
*
|
|
34
|
+
* @param userConfig - 用戶配置
|
|
35
|
+
* @returns OpenTelemetry SDK 實例或 null(如果禁用或初始化失敗)
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // 基本用法
|
|
40
|
+
* const sdk = await setupOpenTelemetry({
|
|
41
|
+
* serviceName: 'my-service'
|
|
42
|
+
* })
|
|
43
|
+
*
|
|
44
|
+
* // 完整配置
|
|
45
|
+
* const sdk = await setupOpenTelemetry({
|
|
46
|
+
* serviceName: 'my-service',
|
|
47
|
+
* serviceVersion: '2.0.0',
|
|
48
|
+
* environment: 'production',
|
|
49
|
+
* tracing: {
|
|
50
|
+
* enabled: true,
|
|
51
|
+
* exporter: 'jaeger',
|
|
52
|
+
* jaegerEndpoint: 'http://jaeger:14268/api/traces',
|
|
53
|
+
* samplingRate: 0.1
|
|
54
|
+
* },
|
|
55
|
+
* metrics: {
|
|
56
|
+
* enabled: true,
|
|
57
|
+
* exporter: 'prometheus',
|
|
58
|
+
* prometheusPort: 9090
|
|
59
|
+
* }
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare function setupOpenTelemetry(userConfig?: OpenTelemetryConfig): Promise<OpenTelemetrySDK | null>;
|
|
66
|
+
/**
|
|
67
|
+
* 獲取全局 OpenTelemetry SDK 實例
|
|
68
|
+
*
|
|
69
|
+
* @returns SDK 實例或 null
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const sdk = getOpenTelemetrySDK()
|
|
74
|
+
* if (sdk) {
|
|
75
|
+
* console.log('Service:', sdk.serviceName)
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export declare function getOpenTelemetrySDK(): OpenTelemetrySDK | null;
|
|
82
|
+
/**
|
|
83
|
+
* 檢查 OpenTelemetry 是否已初始化
|
|
84
|
+
*
|
|
85
|
+
* @returns 初始化狀態
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function isOpenTelemetryInitialized(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* 關閉 OpenTelemetry SDK
|
|
92
|
+
*
|
|
93
|
+
* 應在應用程序關閉時調用,確保所有 spans 和 metrics 都被導出。
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // 在應用程序退出前
|
|
98
|
+
* process.on('SIGTERM', async () => {
|
|
99
|
+
* await shutdownOpenTelemetry()
|
|
100
|
+
* process.exit(0)
|
|
101
|
+
* })
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
*/
|
|
106
|
+
export declare function shutdownOpenTelemetry(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* 重置 OpenTelemetry SDK(主要用於測試)
|
|
109
|
+
*
|
|
110
|
+
* 關閉現有 SDK 並重置所有狀態,允許重新初始化。
|
|
111
|
+
*
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export declare function resetOpenTelemetry(): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* 獲取 Tracer 實例
|
|
117
|
+
*
|
|
118
|
+
* @param name - Tracer 名稱(預設:@gravito/core)
|
|
119
|
+
* @param version - Tracer 版本
|
|
120
|
+
* @returns Tracer 實例
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const tracer = getTracer('my-module')
|
|
125
|
+
* const span = tracer.startSpan('my-operation')
|
|
126
|
+
* // ... 執行操作
|
|
127
|
+
* span.end()
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
export declare function getTracer(name?: string, version?: string): Promise<import("@opentelemetry/api").Tracer | {
|
|
133
|
+
startSpan: () => {
|
|
134
|
+
end: () => void;
|
|
135
|
+
setAttribute: () => void;
|
|
136
|
+
setStatus: () => void;
|
|
137
|
+
recordException: () => void;
|
|
138
|
+
addEvent: () => void;
|
|
139
|
+
isRecording: () => boolean;
|
|
140
|
+
};
|
|
141
|
+
startActiveSpan: (_name: string, fn: (span: any) => any) => any;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* 獲取 Meter 實例
|
|
145
|
+
*
|
|
146
|
+
* @param name - Meter 名稱(預設:@gravito/core)
|
|
147
|
+
* @param version - Meter 版本
|
|
148
|
+
* @returns Meter 實例
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* const meter = getMeter('my-module')
|
|
153
|
+
* const counter = meter.createCounter('my_counter')
|
|
154
|
+
* counter.add(1, { key: 'value' })
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare function getMeter(name?: string, version?: string): Promise<import("@opentelemetry/api").Meter | {
|
|
160
|
+
createCounter: () => {
|
|
161
|
+
add: () => void;
|
|
162
|
+
};
|
|
163
|
+
createHistogram: () => {
|
|
164
|
+
record: () => void;
|
|
165
|
+
};
|
|
166
|
+
createUpDownCounter: () => {
|
|
167
|
+
add: () => void;
|
|
168
|
+
};
|
|
169
|
+
createObservableCounter: () => {
|
|
170
|
+
addCallback: () => void;
|
|
171
|
+
};
|
|
172
|
+
createObservableGauge: () => {
|
|
173
|
+
addCallback: () => void;
|
|
174
|
+
};
|
|
175
|
+
createObservableUpDownCounter: () => {
|
|
176
|
+
addCallback: () => void;
|
|
177
|
+
};
|
|
178
|
+
}>;
|