@equipe-tech/observability 0.2.1 → 0.3.5
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 +11 -9
- package/dist/BrowserEvents.d.ts +89 -12
- package/dist/BrowserEvents.js +67 -13
- package/dist/Correlation.d.ts +51 -0
- package/dist/Correlation.js +95 -0
- package/dist/Metrics.d.ts +19 -3
- package/dist/Metrics.js +16 -0
- package/dist/MetricsRuntime.d.ts +45 -3
- package/dist/MetricsRuntime.js +478 -120
- package/dist/PolicyOtlpLogger.d.ts +18 -0
- package/dist/PolicyOtlpLogger.js +142 -0
- package/dist/RedactionPolicy.d.ts +2 -9
- package/dist/RedactionPolicy.js +2 -246
- package/dist/ResourceIdentity.d.ts +47 -0
- package/dist/ResourceIdentity.js +82 -0
- package/dist/Telemetry.d.ts +18 -3
- package/dist/Telemetry.js +43 -25
- package/dist/TelemetryConfig.d.ts +11 -4
- package/dist/TelemetryConfig.js +38 -10
- package/dist/audit/AuditCommitDocument.d.ts +41 -0
- package/dist/audit/AuditCommitDocument.js +58 -0
- package/dist/audit/AuditDigest.d.ts +11 -0
- package/dist/audit/AuditDigest.js +25 -0
- package/dist/audit/AuditOutbox.d.ts +75 -0
- package/dist/audit/AuditOutbox.js +104 -0
- package/dist/audit/AuditPublisher.d.ts +49 -0
- package/dist/audit/AuditPublisher.js +60 -0
- package/dist/audit/AuditRecord.d.ts +128 -0
- package/dist/audit/AuditRecord.js +172 -0
- package/dist/audit/CommittedAuditRecordInternal.d.ts +11 -0
- package/dist/audit/CommittedAuditRecordInternal.js +13 -0
- package/dist/audit/InvalidAuditRecord.d.ts +12 -0
- package/dist/audit/InvalidAuditRecord.js +16 -0
- package/dist/audit/index.d.ts +7 -0
- package/dist/audit/index.js +7 -0
- package/dist/browser/BrowserClient.d.ts +82 -3
- package/dist/browser/BrowserClient.js +322 -28
- package/dist/browser/BrowserEventLimits.d.ts +8 -0
- package/dist/browser/BrowserEventLimits.js +8 -0
- package/dist/browser/BrowserMetricRecorder.d.ts +17 -0
- package/dist/browser/BrowserMetricRecorder.js +35 -0
- package/dist/browser/BrowserTelemetry.d.ts +40 -0
- package/dist/browser/BrowserTelemetry.js +105 -0
- package/dist/browser/ClientPolicy.d.ts +3 -0
- package/dist/browser/ClientPolicy.js +52 -0
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.js +2 -1
- package/dist/browser/index.d.ts +4 -37
- package/dist/browser/index.js +3 -95
- package/dist/contract/ContractCompatibility.d.ts +31 -0
- package/dist/contract/ContractCompatibility.js +274 -0
- package/dist/contract/ContractIndex.d.ts +54 -0
- package/dist/contract/ContractIndex.js +178 -0
- package/dist/contract/ContractSurface.d.ts +111 -0
- package/dist/contract/ContractSurface.js +116 -0
- package/dist/contract/EventName.d.ts +6 -0
- package/dist/contract/EventName.js +55 -0
- package/dist/contract/EventProducer.d.ts +123 -0
- package/dist/contract/EventProducer.js +209 -0
- package/dist/contract/MetricContractError.d.ts +19 -0
- package/dist/contract/MetricContractError.js +19 -0
- package/dist/contract/MetricDefinition.d.ts +61 -0
- package/dist/contract/MetricDefinition.js +91 -0
- package/dist/contract/MetricProducer.d.ts +42 -0
- package/dist/contract/MetricProducer.js +123 -0
- package/dist/contract/OrganizationEvents.d.ts +165 -0
- package/dist/contract/OrganizationEvents.js +97 -0
- package/dist/contract/TelemetryContract.d.ts +95 -0
- package/dist/contract/TelemetryContract.js +451 -0
- package/dist/contract/TelemetryContractError.d.ts +44 -0
- package/dist/contract/TelemetryContractError.js +64 -0
- package/dist/contract/TelemetryEvent.d.ts +59 -0
- package/dist/contract/TelemetryEvent.js +54 -0
- package/dist/contract/index.d.ts +11 -0
- package/dist/contract/index.js +11 -0
- package/dist/effect/WideEvent.d.ts +3 -0
- package/dist/effect/WideEvent.js +20 -0
- package/dist/effect/WideEventSink.d.ts +3 -0
- package/dist/effect/WideEventSink.js +79 -0
- package/dist/effect/index.d.ts +2 -0
- package/dist/effect/index.js +2 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +11 -2
- package/dist/metrics/InstrumentGrammar.d.ts +5 -0
- package/dist/metrics/InstrumentGrammar.js +12 -0
- package/dist/metrics/MetricScalar.d.ts +3 -0
- package/dist/metrics/MetricScalar.js +5 -0
- package/dist/node/AuditDigest.d.ts +3 -0
- package/dist/node/AuditDigest.js +6 -0
- package/dist/node/BrowserEventIngest.d.ts +7 -2
- package/dist/node/BrowserEventIngest.js +111 -19
- package/dist/node/LocalCollector.d.ts +20 -0
- package/dist/node/LocalCollector.js +188 -0
- package/dist/node/Observability.d.ts +49 -0
- package/dist/node/Observability.js +190 -0
- package/dist/node/Runtime.d.ts +4 -1
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.js +3 -0
- package/dist/policy/BrowserFieldPolicy.d.ts +7 -0
- package/dist/policy/BrowserFieldPolicy.js +298 -0
- package/dist/policy/DataPolicy.d.ts +19 -0
- package/dist/policy/DataPolicy.js +254 -0
- package/dist/policy/DataPolicyError.d.ts +22 -0
- package/dist/policy/DataPolicyError.js +25 -0
- package/dist/policy/Deduplication.d.ts +13 -0
- package/dist/policy/Deduplication.js +44 -0
- package/dist/policy/DefectEnvelope.d.ts +25 -0
- package/dist/policy/DefectEnvelope.js +52 -0
- package/dist/policy/MetricLabelPolicy.d.ts +5 -0
- package/dist/policy/MetricLabelPolicy.js +65 -0
- package/dist/policy/PolicyTransform.d.ts +16 -0
- package/dist/policy/PolicyTransform.js +136 -0
- package/dist/policy/PolicyVocabulary.d.ts +10 -0
- package/dist/policy/PolicyVocabulary.js +84 -0
- package/dist/policy/ResourceAttributePolicy.d.ts +9 -0
- package/dist/policy/ResourceAttributePolicy.js +33 -0
- package/dist/policy/entrypoint.d.ts +2 -0
- package/dist/policy/entrypoint.js +2 -0
- package/dist/policy/index.d.ts +17 -0
- package/dist/policy/index.js +9 -0
- package/dist/profile/DataPolicy.d.ts +2 -0
- package/dist/profile/DataPolicy.js +1 -0
- package/dist/profile/EnvironmentPolicy.d.ts +22 -0
- package/dist/profile/EnvironmentPolicy.js +41 -0
- package/dist/profile/LifecycleRegistry.d.ts +24 -0
- package/dist/profile/LifecycleRegistry.js +240 -0
- package/dist/profile/ObservabilityAdapter.d.ts +115 -0
- package/dist/profile/ObservabilityAdapter.js +50 -0
- package/dist/profile/ObservabilityConfig.d.ts +68 -0
- package/dist/profile/ObservabilityConfig.js +125 -0
- package/dist/profile/ObservabilityConfigError.d.ts +23 -0
- package/dist/profile/ObservabilityConfigError.js +39 -0
- package/dist/profile/ObservabilityProfile.d.ts +49 -0
- package/dist/profile/ObservabilityProfile.js +121 -0
- package/dist/profile/ReactWebProfile.d.ts +8 -0
- package/dist/profile/ReactWebProfile.js +7 -0
- package/dist/profile/index.d.ts +5 -0
- package/dist/profile/index.js +5 -0
- package/dist/testing/conformance/ConformanceAssertions.d.ts +5 -0
- package/dist/testing/conformance/ConformanceAssertions.js +31 -0
- package/dist/testing/conformance/ConformanceFailure.d.ts +35 -0
- package/dist/testing/conformance/ConformanceFailure.js +56 -0
- package/dist/testing/conformance/ConformanceModel.d.ts +97 -0
- package/dist/testing/conformance/ConformanceModel.js +8 -0
- package/dist/testing/conformance/ConformanceRegistry.d.ts +13 -0
- package/dist/testing/conformance/ConformanceRegistry.js +190 -0
- package/dist/testing/conformance/ConformanceRunner.d.ts +5 -0
- package/dist/testing/conformance/ConformanceRunner.js +198 -0
- package/dist/testing/conformance/TelemetryEvidence.d.ts +91 -0
- package/dist/testing/conformance/TelemetryEvidence.js +370 -0
- package/dist/testing/conformance/index.d.ts +10 -0
- package/dist/testing/conformance/index.js +6 -0
- package/dist/testing/contract.d.ts +81 -0
- package/dist/testing/contract.js +93 -0
- package/dist/testing/deployedCanary.d.ts +1 -0
- package/dist/testing/deployedCanary.js +1 -0
- package/dist/testing/index.d.ts +40 -3
- package/dist/testing/index.js +122 -5
- package/dist/trace/HttpServerOtlpTracer.d.ts +42 -0
- package/dist/trace/HttpServerOtlpTracer.js +301 -0
- package/package.json +16 -29
- package/dist/WideEvent.d.ts +0 -5
- package/dist/WideEvent.js +0 -6
- package/dist/nestjs/BrowserEventsController.d.ts +0 -21
- package/dist/nestjs/BrowserEventsController.js +0 -52
- package/dist/nestjs/HttpRoutePolicy.d.ts +0 -23
- package/dist/nestjs/HttpRoutePolicy.js +0 -179
- package/dist/nestjs/HttpServerOtlpTracer.d.ts +0 -15
- package/dist/nestjs/HttpServerOtlpTracer.js +0 -154
- package/dist/nestjs/RequestWideEventTraceCorrelation.d.ts +0 -15
- package/dist/nestjs/RequestWideEventTraceCorrelation.js +0 -13
- package/dist/nestjs/TelemetryInterceptor.d.ts +0 -31
- package/dist/nestjs/TelemetryInterceptor.js +0 -268
- package/dist/nestjs/TelemetryModule.d.ts +0 -53
- package/dist/nestjs/TelemetryModule.js +0 -428
- package/dist/nestjs/index.d.ts +0 -5
- package/dist/nestjs/index.js +0 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @equipe-tech/observability
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Núcleo neutro de observabilidade da Equipe Tech para OpenTelemetry, contratos, políticas e ciclo de vida.
|
|
4
4
|
|
|
5
5
|
## Instalação
|
|
6
6
|
|
|
@@ -8,17 +8,19 @@ Biblioteca OpenTelemetry da Equipe Tech para aplicações Effect, Node.js, NestJ
|
|
|
8
8
|
npm install @equipe-tech/observability effect
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
`effect@4.0.0-rc.111` é um peer obrigatório. O consumidor e os adapters compartilham a mesma cópia do runtime.
|
|
12
|
+
|
|
11
13
|
## Entrypoints
|
|
12
14
|
|
|
13
|
-
- `@equipe-tech/observability
|
|
14
|
-
- `@equipe-tech/observability/
|
|
15
|
-
- `@equipe-tech/observability/
|
|
16
|
-
- `@equipe-tech/observability/
|
|
17
|
-
- `@equipe-tech/observability/browser
|
|
18
|
-
- `@equipe-tech/observability/browser/client
|
|
19
|
-
- `@equipe-tech/observability/testing
|
|
15
|
+
- `@equipe-tech/observability` contém configuração, contratos, identidade, política e composição neutra.
|
|
16
|
+
- `@equipe-tech/observability/effect` contém `WideEvent` e `layerWideEvent`.
|
|
17
|
+
- `@equipe-tech/observability/metrics` contém métricas imperativas sem tipos Effect na API pública.
|
|
18
|
+
- `@equipe-tech/observability/node` contém o runtime OTLP para Node.js e a ingestão de eventos do browser.
|
|
19
|
+
- `@equipe-tech/observability/browser` contém o serviço Effect de telemetria do browser.
|
|
20
|
+
- `@equipe-tech/observability/browser/client` contém o cliente imperativo sem tipos Effect na API pública.
|
|
21
|
+
- `@equipe-tech/observability/testing` contém captura OTLP em memória para testes.
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
A integração NestJS pertence a `@equipe-tech/observability-nestjs`. O núcleo não importa NestJS, RxJS, reflect-metadata, evlog, React ou Sentry.
|
|
22
24
|
|
|
23
25
|
Consulte a [documentação completa](https://github.com/equipe-tech/observability#readme) para configuração, política de dados, semântica HTTP e exemplos.
|
|
24
26
|
|
package/dist/BrowserEvents.d.ts
CHANGED
|
@@ -1,28 +1,78 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
export
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const maxFieldKeyLength = 128;
|
|
5
|
-
export declare const maxFieldValueLength = 1024;
|
|
6
|
-
export declare const maxEventNameLength = 128;
|
|
7
|
-
export declare const maxEventIdLength = 64;
|
|
2
|
+
export { browserEnvelopeVersion, browserRequestByteBudget, maxEventIdLength, maxEventNameLength, maxEventsPerBatch, maxFieldKeyLength, maxFieldsPerEvent, maxFieldValueLength, } from "./browser/BrowserEventLimits.js";
|
|
3
|
+
export declare const maxBrowserEventOccurredAt = 18446744073709;
|
|
8
4
|
declare const BrowserEventFields: Schema.$Record<Schema.NonEmptyString, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
9
5
|
export type BrowserEventFields = typeof BrowserEventFields.Type;
|
|
10
|
-
declare const
|
|
11
|
-
readonly
|
|
6
|
+
declare const BrowserResourceIdentity_base: Schema.Class<BrowserResourceIdentity, Schema.Struct<{
|
|
7
|
+
readonly serviceName: Schema.NonEmptyString;
|
|
8
|
+
readonly serviceVersion: Schema.NonEmptyString;
|
|
9
|
+
readonly environment: Schema.NonEmptyString;
|
|
10
|
+
}>, {}>;
|
|
11
|
+
export declare class BrowserResourceIdentity extends BrowserResourceIdentity_base {
|
|
12
|
+
}
|
|
13
|
+
declare const BrowserTraceContext_base: Schema.Class<BrowserTraceContext, Schema.Struct<{
|
|
14
|
+
readonly traceId: Schema.String;
|
|
15
|
+
readonly spanId: Schema.String;
|
|
16
|
+
}>, {}>;
|
|
17
|
+
export declare class BrowserTraceContext extends BrowserTraceContext_base {
|
|
18
|
+
}
|
|
19
|
+
declare const BrowserTraceSpan_base: Schema.Class<BrowserTraceSpan, Schema.Struct<{
|
|
20
|
+
readonly traceId: Schema.String;
|
|
21
|
+
readonly spanId: Schema.String;
|
|
22
|
+
readonly parentSpanId: Schema.optional<Schema.String>;
|
|
23
|
+
readonly name: Schema.NonEmptyString;
|
|
24
|
+
readonly startedAt: Schema.Number;
|
|
25
|
+
readonly endedAt: Schema.Number;
|
|
26
|
+
readonly fields: Schema.$Record<Schema.NonEmptyString, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
27
|
+
}>, {}>;
|
|
28
|
+
export declare class BrowserTraceSpan extends BrowserTraceSpan_base {
|
|
29
|
+
}
|
|
30
|
+
declare const BrowserMetricPoint_base: Schema.Class<BrowserMetricPoint, Schema.Struct<{
|
|
12
31
|
readonly name: Schema.NonEmptyString;
|
|
32
|
+
readonly value: Schema.Number;
|
|
13
33
|
readonly occurredAt: Schema.Number;
|
|
14
34
|
readonly fields: Schema.$Record<Schema.NonEmptyString, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
15
35
|
}>, {}>;
|
|
36
|
+
export declare class BrowserMetricPoint extends BrowserMetricPoint_base {
|
|
37
|
+
}
|
|
38
|
+
declare const BrowserEventError_base: Schema.Class<BrowserEventError, Schema.Struct<{
|
|
39
|
+
readonly type: Schema.NonEmptyString;
|
|
40
|
+
readonly message: Schema.String;
|
|
41
|
+
readonly retryable: Schema.Boolean;
|
|
42
|
+
}>, {}>;
|
|
43
|
+
export declare class BrowserEventError extends BrowserEventError_base {
|
|
44
|
+
}
|
|
45
|
+
declare const BrowserEvent_base: Schema.Class<BrowserEvent, Schema.Struct<{
|
|
46
|
+
id: Schema.NonEmptyString;
|
|
47
|
+
name: Schema.NonEmptyString;
|
|
48
|
+
occurredAt: Schema.Number;
|
|
49
|
+
fields: Schema.$Record<Schema.NonEmptyString, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean]>>;
|
|
50
|
+
error: Schema.optional<typeof BrowserEventError>;
|
|
51
|
+
trace: Schema.optional<typeof BrowserTraceContext>;
|
|
52
|
+
}>, {}>;
|
|
16
53
|
export declare class BrowserEvent extends BrowserEvent_base {
|
|
17
54
|
}
|
|
18
55
|
declare const BrowserEventBatch_base: Schema.Class<BrowserEventBatch, Schema.Struct<{
|
|
19
|
-
|
|
20
|
-
|
|
56
|
+
version: Schema.Int;
|
|
57
|
+
resource: Schema.optional<typeof BrowserResourceIdentity>;
|
|
58
|
+
events: Schema.$Array<typeof BrowserEvent>;
|
|
59
|
+
spans: Schema.optional<Schema.$Array<typeof BrowserTraceSpan>>;
|
|
60
|
+
metrics: Schema.optional<Schema.$Array<typeof BrowserMetricPoint>>;
|
|
21
61
|
}>, {}>;
|
|
22
62
|
export declare class BrowserEventBatch extends BrowserEventBatch_base {
|
|
23
63
|
}
|
|
64
|
+
export declare const browserEnvelopeMetadata: {
|
|
65
|
+
version: number;
|
|
66
|
+
batchFields: string[];
|
|
67
|
+
eventFields: string[];
|
|
68
|
+
};
|
|
24
69
|
export declare const encodeBrowserEventBatch: (input: BrowserEventBatch, options?: import("effect/SchemaAST").ParseOptions) => import("effect/Effect").Effect<{
|
|
25
|
-
readonly version:
|
|
70
|
+
readonly version: number;
|
|
71
|
+
readonly resource?: {
|
|
72
|
+
readonly serviceName: string;
|
|
73
|
+
readonly serviceVersion: string;
|
|
74
|
+
readonly environment: string;
|
|
75
|
+
} | undefined;
|
|
26
76
|
readonly events: readonly {
|
|
27
77
|
readonly id: string;
|
|
28
78
|
readonly name: string;
|
|
@@ -30,6 +80,33 @@ export declare const encodeBrowserEventBatch: (input: BrowserEventBatch, options
|
|
|
30
80
|
readonly fields: {
|
|
31
81
|
readonly [x: string]: string | number | boolean;
|
|
32
82
|
};
|
|
83
|
+
readonly error?: {
|
|
84
|
+
readonly type: string;
|
|
85
|
+
readonly message: string;
|
|
86
|
+
readonly retryable: boolean;
|
|
87
|
+
} | undefined;
|
|
88
|
+
readonly trace?: {
|
|
89
|
+
readonly traceId: string;
|
|
90
|
+
readonly spanId: string;
|
|
91
|
+
} | undefined;
|
|
33
92
|
}[];
|
|
93
|
+
readonly spans?: readonly {
|
|
94
|
+
readonly traceId: string;
|
|
95
|
+
readonly spanId: string;
|
|
96
|
+
readonly parentSpanId?: string | undefined;
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly startedAt: number;
|
|
99
|
+
readonly endedAt: number;
|
|
100
|
+
readonly fields: {
|
|
101
|
+
readonly [x: string]: string | number | boolean;
|
|
102
|
+
};
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
readonly metrics?: readonly {
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly value: number;
|
|
107
|
+
readonly occurredAt: number;
|
|
108
|
+
readonly fields: {
|
|
109
|
+
readonly [x: string]: string | number | boolean;
|
|
110
|
+
};
|
|
111
|
+
}[] | undefined;
|
|
34
112
|
}, Schema.SchemaError, never>;
|
|
35
|
-
export {};
|
package/dist/BrowserEvents.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export const
|
|
6
|
-
export const maxEventNameLength = 128;
|
|
7
|
-
export const maxEventIdLength = 64;
|
|
2
|
+
import { maxOtlpUnixTimestampMillis } from "./contract/TelemetryEvent.js";
|
|
3
|
+
import { browserEnvelopeVersion, maxEventIdLength, maxEventNameLength, maxEventsPerBatch, maxFieldKeyLength, maxFieldsPerEvent, maxFieldValueLength, } from "./browser/BrowserEventLimits.js";
|
|
4
|
+
export { browserEnvelopeVersion, browserRequestByteBudget, maxEventIdLength, maxEventNameLength, maxEventsPerBatch, maxFieldKeyLength, maxFieldsPerEvent, maxFieldValueLength, } from "./browser/BrowserEventLimits.js";
|
|
5
|
+
export const maxBrowserEventOccurredAt = maxOtlpUnixTimestampMillis;
|
|
8
6
|
const BoundedFieldValue = Schema.Union([
|
|
9
7
|
Schema.String.check(Schema.isMaxLength(maxFieldValueLength)),
|
|
10
8
|
Schema.Number.check(Schema.isFinite()),
|
|
@@ -14,20 +12,76 @@ const BoundedFieldKey = Schema.NonEmptyString.check(Schema.isMaxLength(maxFieldK
|
|
|
14
12
|
const BrowserEventFields = Schema.Record(BoundedFieldKey, BoundedFieldValue).check(Schema.makeFilter((fields) => Object.keys(fields).length <= maxFieldsPerEvent, {
|
|
15
13
|
expected: `at most ${maxFieldsPerEvent} fields per event`,
|
|
16
14
|
}));
|
|
17
|
-
|
|
15
|
+
const BrowserTraceId = Schema.String.check(Schema.isPattern(/^[0-9a-f]{32}$/), Schema.makeFilter((value) => value !== "00000000000000000000000000000000", {
|
|
16
|
+
expected: "a non-zero W3C trace identifier",
|
|
17
|
+
}));
|
|
18
|
+
const BrowserSpanId = Schema.String.check(Schema.isPattern(/^[0-9a-f]{16}$/), Schema.makeFilter((value) => value !== "0000000000000000", {
|
|
19
|
+
expected: "a non-zero W3C span identifier",
|
|
20
|
+
}));
|
|
21
|
+
export class BrowserResourceIdentity extends Schema.Class("@equipe-tech/observability/BrowserResourceIdentity")({
|
|
22
|
+
serviceName: Schema.NonEmptyString,
|
|
23
|
+
serviceVersion: Schema.NonEmptyString,
|
|
24
|
+
environment: Schema.NonEmptyString,
|
|
25
|
+
}) {
|
|
26
|
+
}
|
|
27
|
+
export class BrowserTraceContext extends Schema.Class("@equipe-tech/observability/BrowserTraceContext")({
|
|
28
|
+
traceId: BrowserTraceId,
|
|
29
|
+
spanId: BrowserSpanId,
|
|
30
|
+
}) {
|
|
31
|
+
}
|
|
32
|
+
export class BrowserTraceSpan extends Schema.Class("@equipe-tech/observability/BrowserTraceSpan")({
|
|
33
|
+
traceId: BrowserTraceId,
|
|
34
|
+
spanId: BrowserSpanId,
|
|
35
|
+
parentSpanId: Schema.optional(BrowserSpanId),
|
|
36
|
+
name: Schema.NonEmptyString.check(Schema.isMaxLength(maxEventNameLength)),
|
|
37
|
+
startedAt: Schema.Number.check(Schema.isFinite(), Schema.isBetween({ minimum: 0, maximum: maxBrowserEventOccurredAt })),
|
|
38
|
+
endedAt: Schema.Number.check(Schema.isFinite(), Schema.isBetween({ minimum: 0, maximum: maxBrowserEventOccurredAt })),
|
|
39
|
+
fields: BrowserEventFields,
|
|
40
|
+
}) {
|
|
41
|
+
}
|
|
42
|
+
export class BrowserMetricPoint extends Schema.Class("@equipe-tech/observability/BrowserMetricPoint")({
|
|
43
|
+
name: Schema.NonEmptyString.check(Schema.isMaxLength(maxEventNameLength)),
|
|
44
|
+
value: Schema.Number.check(Schema.isFinite(), Schema.isGreaterThanOrEqualTo(0)),
|
|
45
|
+
occurredAt: Schema.Number.check(Schema.isFinite(), Schema.isBetween({ minimum: 0, maximum: maxBrowserEventOccurredAt })),
|
|
46
|
+
fields: BrowserEventFields,
|
|
47
|
+
}) {
|
|
48
|
+
}
|
|
49
|
+
export class BrowserEventError extends Schema.Class("@equipe-tech/observability/BrowserEventError")({
|
|
50
|
+
type: Schema.NonEmptyString.check(Schema.isMaxLength(maxFieldValueLength)),
|
|
51
|
+
message: Schema.String.check(Schema.isMaxLength(maxFieldValueLength)),
|
|
52
|
+
retryable: Schema.Boolean,
|
|
53
|
+
}) {
|
|
54
|
+
}
|
|
55
|
+
const BrowserEventDocument = {
|
|
18
56
|
id: Schema.NonEmptyString.check(Schema.isMaxLength(maxEventIdLength)),
|
|
19
57
|
name: Schema.NonEmptyString.check(Schema.isMaxLength(maxEventNameLength)),
|
|
20
|
-
occurredAt: Schema.Number.check(Schema.isFinite(), Schema.makeFilter((millis) => millis >= 0, {
|
|
21
|
-
expected:
|
|
58
|
+
occurredAt: Schema.Number.check(Schema.isFinite(), Schema.makeFilter((millis) => millis >= 0 && millis <= maxBrowserEventOccurredAt, {
|
|
59
|
+
expected: `an epoch timestamp in milliseconds from 0 through ${maxBrowserEventOccurredAt}`,
|
|
22
60
|
})),
|
|
23
61
|
fields: BrowserEventFields,
|
|
24
|
-
|
|
62
|
+
error: Schema.optional(BrowserEventError),
|
|
63
|
+
trace: Schema.optional(BrowserTraceContext),
|
|
64
|
+
};
|
|
65
|
+
export class BrowserEvent extends Schema.Class("@equipe-tech/observability/BrowserEvent")(BrowserEventDocument) {
|
|
25
66
|
}
|
|
26
|
-
|
|
27
|
-
version: Schema.
|
|
67
|
+
const BrowserEventBatchDocument = {
|
|
68
|
+
version: Schema.Int.check(Schema.isGreaterThan(0), Schema.makeFilter(Number.isSafeInteger, { expected: "a positive safe integer" })),
|
|
69
|
+
resource: Schema.optional(BrowserResourceIdentity),
|
|
28
70
|
events: Schema.Array(BrowserEvent).check(Schema.makeFilter((events) => events.length <= maxEventsPerBatch, {
|
|
29
71
|
expected: `at most ${maxEventsPerBatch} events per batch`,
|
|
30
72
|
})),
|
|
31
|
-
|
|
73
|
+
spans: Schema.optional(Schema.Array(BrowserTraceSpan).check(Schema.makeFilter((spans) => spans.length <= maxEventsPerBatch, {
|
|
74
|
+
expected: `at most ${maxEventsPerBatch} spans per batch`,
|
|
75
|
+
}))),
|
|
76
|
+
metrics: Schema.optional(Schema.Array(BrowserMetricPoint).check(Schema.makeFilter((metrics) => metrics.length <= maxEventsPerBatch, {
|
|
77
|
+
expected: `at most ${maxEventsPerBatch} metric points per batch`,
|
|
78
|
+
}))),
|
|
79
|
+
};
|
|
80
|
+
export class BrowserEventBatch extends Schema.Class("@equipe-tech/observability/BrowserEventBatch")(BrowserEventBatchDocument) {
|
|
32
81
|
}
|
|
82
|
+
export const browserEnvelopeMetadata = {
|
|
83
|
+
version: browserEnvelopeVersion,
|
|
84
|
+
batchFields: Object.keys(BrowserEventBatchDocument).sort(),
|
|
85
|
+
eventFields: Object.keys(BrowserEventDocument).sort(),
|
|
86
|
+
};
|
|
33
87
|
export const encodeBrowserEventBatch = Schema.encodeEffect(BrowserEventBatch);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Context, Effect, Option, Schema } from "effect";
|
|
2
|
+
export declare const TraceId: Schema.brand<Schema.String, "TraceId">;
|
|
3
|
+
export type TraceId = typeof TraceId.Type;
|
|
4
|
+
export declare const SpanId: Schema.brand<Schema.String, "SpanId">;
|
|
5
|
+
export type SpanId = typeof SpanId.Type;
|
|
6
|
+
export declare const RequestId: Schema.brand<Schema.NonEmptyString, "RequestId">;
|
|
7
|
+
export type RequestId = typeof RequestId.Type;
|
|
8
|
+
export declare const RunId: Schema.brand<Schema.NonEmptyString, "RunId">;
|
|
9
|
+
export type RunId = typeof RunId.Type;
|
|
10
|
+
export declare const TraceLinkage: Schema.Union<readonly [Schema.Struct<{
|
|
11
|
+
readonly _tag: Schema.Literal<"Untraced">;
|
|
12
|
+
}>, Schema.Struct<{
|
|
13
|
+
readonly _tag: Schema.Literal<"Traced">;
|
|
14
|
+
readonly traceId: Schema.brand<Schema.String, "TraceId">;
|
|
15
|
+
readonly spanId: Schema.brand<Schema.String, "SpanId">;
|
|
16
|
+
}>]>;
|
|
17
|
+
export type TraceLinkage = typeof TraceLinkage.Type;
|
|
18
|
+
declare const CorrelationContext_base: Schema.Class<CorrelationContext, Schema.Struct<{
|
|
19
|
+
readonly trace: Schema.withConstructorDefault<Schema.Union<readonly [Schema.Struct<{
|
|
20
|
+
readonly _tag: Schema.Literal<"Untraced">;
|
|
21
|
+
}>, Schema.Struct<{
|
|
22
|
+
readonly _tag: Schema.Literal<"Traced">;
|
|
23
|
+
readonly traceId: Schema.brand<Schema.String, "TraceId">;
|
|
24
|
+
readonly spanId: Schema.brand<Schema.String, "SpanId">;
|
|
25
|
+
}>]>>;
|
|
26
|
+
readonly requestId: Schema.withConstructorDefault<Schema.Option<Schema.brand<Schema.NonEmptyString, "RequestId">>>;
|
|
27
|
+
readonly runId: Schema.withConstructorDefault<Schema.Option<Schema.brand<Schema.NonEmptyString, "RunId">>>;
|
|
28
|
+
}>, {}>;
|
|
29
|
+
export declare class CorrelationContext extends CorrelationContext_base {
|
|
30
|
+
get traceId(): Option.Option<TraceId>;
|
|
31
|
+
get spanId(): Option.Option<SpanId>;
|
|
32
|
+
}
|
|
33
|
+
export declare const CorrelationField: Schema.Literals<readonly ["traceId", "spanId", "requestId", "runId"]>;
|
|
34
|
+
export type CorrelationField = typeof CorrelationField.Type;
|
|
35
|
+
declare const InvalidCorrelationContext_base: Schema.Class<InvalidCorrelationContext, Schema.TaggedStruct<"InvalidCorrelationContext", {
|
|
36
|
+
readonly code: Schema.Literal<"OBS_CORRELATION_INVALID">;
|
|
37
|
+
readonly message: Schema.String;
|
|
38
|
+
readonly field: Schema.Literals<readonly ["traceId", "spanId", "requestId", "runId"]>;
|
|
39
|
+
readonly rule: Schema.String;
|
|
40
|
+
}>, import("effect/Cause").YieldableError>;
|
|
41
|
+
export declare class InvalidCorrelationContext extends InvalidCorrelationContext_base {
|
|
42
|
+
}
|
|
43
|
+
export declare const parseTraceId: (value: string) => Effect.Effect<TraceId, InvalidCorrelationContext>;
|
|
44
|
+
export declare const parseSpanId: (value: string) => Effect.Effect<SpanId, InvalidCorrelationContext>;
|
|
45
|
+
export declare const parseRequestId: (value: string) => Effect.Effect<RequestId, InvalidCorrelationContext>;
|
|
46
|
+
export declare const parseRunId: (value: string) => Effect.Effect<RunId, InvalidCorrelationContext>;
|
|
47
|
+
export declare const generateRunId: (kind: "canary" | "job", label: string) => Effect.Effect<string & import("effect/Brand").Brand<"RunId">, never, never>;
|
|
48
|
+
export declare const CurrentCorrelation: Context.Reference<CorrelationContext>;
|
|
49
|
+
export declare const withCorrelation: (correlation: CorrelationContext) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
50
|
+
export declare const withBackgroundCorrelation: (correlation: CorrelationContext, spanName: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Clock, Context, Effect, Option, Random, Schema, Tracer } from "effect";
|
|
2
|
+
const containsControlCharacter = (value) => {
|
|
3
|
+
for (const character of value) {
|
|
4
|
+
const codePoint = character.codePointAt(0);
|
|
5
|
+
if (codePoint !== undefined && (codePoint <= 31 || codePoint === 127)) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
export const TraceId = Schema.String.check(Schema.isPattern(/^[0-9a-f]{32}$/), Schema.makeFilter((value) => value !== "0".repeat(32), { expected: "a non-zero trace ID" })).pipe(Schema.brand("TraceId"));
|
|
12
|
+
export const SpanId = Schema.String.check(Schema.isPattern(/^[0-9a-f]{16}$/), Schema.makeFilter((value) => value !== "0".repeat(16), { expected: "a non-zero span ID" })).pipe(Schema.brand("SpanId"));
|
|
13
|
+
export const RequestId = Schema.NonEmptyString.check(Schema.makeFilter((value) => !containsControlCharacter(value), {
|
|
14
|
+
expected: "a value without control characters",
|
|
15
|
+
}), Schema.isMaxLength(128)).pipe(Schema.brand("RequestId"));
|
|
16
|
+
export const RunId = Schema.NonEmptyString.check(Schema.makeFilter((value) => !containsControlCharacter(value), {
|
|
17
|
+
expected: "a value without control characters",
|
|
18
|
+
}), Schema.isMaxLength(128)).pipe(Schema.brand("RunId"));
|
|
19
|
+
export const TraceLinkage = Schema.Union([
|
|
20
|
+
Schema.Struct({ _tag: Schema.Literal("Untraced") }),
|
|
21
|
+
Schema.Struct({ _tag: Schema.Literal("Traced"), traceId: TraceId, spanId: SpanId }),
|
|
22
|
+
]);
|
|
23
|
+
export class CorrelationContext extends Schema.Class("@equipe-tech/observability/CorrelationContext")({
|
|
24
|
+
trace: TraceLinkage.pipe(Schema.withConstructorDefault(Effect.succeed({ _tag: "Untraced" }))),
|
|
25
|
+
requestId: Schema.Option(RequestId).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
|
|
26
|
+
runId: Schema.Option(RunId).pipe(Schema.withConstructorDefault(Effect.succeed(Option.none()))),
|
|
27
|
+
}) {
|
|
28
|
+
get traceId() {
|
|
29
|
+
return this.trace._tag === "Traced" ? Option.some(this.trace.traceId) : Option.none();
|
|
30
|
+
}
|
|
31
|
+
get spanId() {
|
|
32
|
+
return this.trace._tag === "Traced" ? Option.some(this.trace.spanId) : Option.none();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const CorrelationField = Schema.Literals(["traceId", "spanId", "requestId", "runId"]);
|
|
36
|
+
export class InvalidCorrelationContext extends Schema.TaggedError()("InvalidCorrelationContext", {
|
|
37
|
+
code: Schema.Literal("OBS_CORRELATION_INVALID"),
|
|
38
|
+
message: Schema.String,
|
|
39
|
+
field: CorrelationField,
|
|
40
|
+
rule: Schema.String,
|
|
41
|
+
}) {
|
|
42
|
+
}
|
|
43
|
+
const invalidCorrelation = (field, rule) => new InvalidCorrelationContext({
|
|
44
|
+
code: "OBS_CORRELATION_INVALID",
|
|
45
|
+
field,
|
|
46
|
+
rule,
|
|
47
|
+
message: `Correlation field ${field} is invalid. Use ${rule}.`,
|
|
48
|
+
});
|
|
49
|
+
const traceIdRule = "32 lowercase hexadecimal characters and a non-zero value";
|
|
50
|
+
const spanIdRule = "16 lowercase hexadecimal characters and a non-zero value";
|
|
51
|
+
const opaqueIdentifierRule = "1 to 128 characters without control characters";
|
|
52
|
+
const decodeTraceId = Schema.decodeUnknownEffect(TraceId);
|
|
53
|
+
const decodeSpanId = Schema.decodeUnknownEffect(SpanId);
|
|
54
|
+
const decodeRequestId = Schema.decodeUnknownEffect(RequestId);
|
|
55
|
+
const decodeRunId = Schema.decodeUnknownEffect(RunId);
|
|
56
|
+
export const parseTraceId = (value) => decodeTraceId(value).pipe(Effect.mapError(() => invalidCorrelation("traceId", traceIdRule)));
|
|
57
|
+
export const parseSpanId = (value) => decodeSpanId(value).pipe(Effect.mapError(() => invalidCorrelation("spanId", spanIdRule)));
|
|
58
|
+
export const parseRequestId = (value) => decodeRequestId(value).pipe(Effect.mapError(() => invalidCorrelation("requestId", opaqueIdentifierRule)));
|
|
59
|
+
export const parseRunId = (value) => decodeRunId(value).pipe(Effect.mapError(() => invalidCorrelation("runId", opaqueIdentifierRule)));
|
|
60
|
+
const dnsSafeLabel = (label) => {
|
|
61
|
+
const normalized = label
|
|
62
|
+
.toLowerCase()
|
|
63
|
+
.replaceAll(/[^a-z0-9-]+/g, "-")
|
|
64
|
+
.replaceAll(/-+/g, "-")
|
|
65
|
+
.replaceAll(/^-+|-+$/g, "");
|
|
66
|
+
return normalized === "" ? "run" : normalized;
|
|
67
|
+
};
|
|
68
|
+
export const generateRunId = Effect.fn("generateRunId")(function* (kind, label) {
|
|
69
|
+
const prefix = kind === "canary" ? "test" : "job";
|
|
70
|
+
const timestamp = yield* Clock.currentTimeMillis;
|
|
71
|
+
const entropy = Math.floor((yield* Random.next) * 2_821_109_907_456)
|
|
72
|
+
.toString(36)
|
|
73
|
+
.padStart(8, "0");
|
|
74
|
+
const suffix = `-${timestamp}-${entropy}`;
|
|
75
|
+
const truncatedLabel = dnsSafeLabel(label)
|
|
76
|
+
.slice(0, 128 - prefix.length - suffix.length - 1)
|
|
77
|
+
.replaceAll(/-+$/g, "");
|
|
78
|
+
const boundedLabel = truncatedLabel === "" ? "run" : truncatedLabel;
|
|
79
|
+
return yield* decodeRunId(`${prefix}-${boundedLabel}${suffix}`).pipe(Effect.orDie);
|
|
80
|
+
});
|
|
81
|
+
const emptyCorrelation = new CorrelationContext({});
|
|
82
|
+
export const CurrentCorrelation = Context.Reference("@equipe-tech/observability/CurrentCorrelation", { defaultValue: () => emptyCorrelation });
|
|
83
|
+
export const withCorrelation = (correlation) => (effect) => Effect.provideService(effect, CurrentCorrelation, correlation);
|
|
84
|
+
export const withBackgroundCorrelation = (correlation, spanName) => (effect) => {
|
|
85
|
+
const correlated = Effect.provideService(effect, CurrentCorrelation, correlation);
|
|
86
|
+
if (correlation.trace._tag === "Traced") {
|
|
87
|
+
return correlated.pipe(Effect.withSpan(spanName, {
|
|
88
|
+
parent: Tracer.externalSpan({
|
|
89
|
+
traceId: correlation.trace.traceId,
|
|
90
|
+
spanId: correlation.trace.spanId,
|
|
91
|
+
}),
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
return correlated.pipe(Effect.withSpan(spanName, { root: true }));
|
|
95
|
+
};
|
package/dist/Metrics.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import type { MetricMeasurementErrorCode } from "./contract/MetricContractError.js";
|
|
2
|
+
import type { EnvironmentAliasPolicy, ResourceIdentityField } from "./ResourceIdentity.js";
|
|
3
|
+
import type { DataPolicy } from "./policy/DataPolicy.js";
|
|
4
|
+
import type { MetricLabelRejection } from "./policy/MetricLabelPolicy.js";
|
|
5
|
+
export type { MetricLabelRejection } from "./policy/MetricLabelPolicy.js";
|
|
1
6
|
export type MetricAttributeValue = string | number | boolean;
|
|
2
7
|
export interface MetricAttribute {
|
|
3
8
|
readonly key: string;
|
|
@@ -28,11 +33,13 @@ export interface ObservableGaugeRegistration {
|
|
|
28
33
|
unregister(): void;
|
|
29
34
|
[Symbol.dispose](): void;
|
|
30
35
|
}
|
|
31
|
-
export type GaugeCollectionFailureCode = "CALLBACK_FAILED" | "INVALID_OBSERVATION" | "ATTRIBUTE_LIMIT_EXCEEDED" | "SERIES_LIMIT_EXCEEDED";
|
|
36
|
+
export type GaugeCollectionFailureCode = "CALLBACK_FAILED" | "INVALID_OBSERVATION" | "ATTRIBUTE_LIMIT_EXCEEDED" | "SERIES_LIMIT_EXCEEDED" | "POLICY_BLOCKED" | "CONTRACT_REJECTED";
|
|
32
37
|
export interface GaugeCollectionFailure {
|
|
33
38
|
readonly instrumentName: string;
|
|
34
39
|
readonly code: GaugeCollectionFailureCode;
|
|
35
40
|
readonly message: string;
|
|
41
|
+
readonly policyReason?: MetricLabelRejection;
|
|
42
|
+
readonly contractReason?: MetricMeasurementErrorCode;
|
|
36
43
|
}
|
|
37
44
|
export interface FlushResult {
|
|
38
45
|
readonly gaugeFailures: ReadonlyArray<GaugeCollectionFailure>;
|
|
@@ -49,16 +56,22 @@ export interface MetricsOptions {
|
|
|
49
56
|
readonly serviceName: string;
|
|
50
57
|
readonly serviceVersion: string;
|
|
51
58
|
readonly environment: string;
|
|
59
|
+
readonly deploymentEnvironmentAlias?: EnvironmentAliasPolicy | undefined;
|
|
52
60
|
readonly otlpEndpoint: string;
|
|
53
61
|
readonly exportIntervalMilliseconds?: number;
|
|
54
62
|
readonly flushTimeoutMilliseconds?: number;
|
|
63
|
+
readonly policy?: DataPolicy;
|
|
55
64
|
}
|
|
56
|
-
export type MetricsErrorCode = "INVALID_CONFIGURATION" | "INVALID_INSTRUMENT" | "INVALID_MEASUREMENT" | "INSTRUMENT_CONFLICT" | "LIMIT_EXCEEDED" | "EXPORT_FAILED" | "FLUSH_TIMED_OUT" | "CLOSED";
|
|
65
|
+
export type MetricsErrorCode = "INVALID_CONFIGURATION" | "INVALID_INSTRUMENT" | "INVALID_MEASUREMENT" | "INSTRUMENT_CONFLICT" | "LIMIT_EXCEEDED" | "EXPORT_FAILED" | "FLUSH_TIMED_OUT" | "POLICY_BLOCKED" | "CLOSED";
|
|
57
66
|
interface MetricsErrorOptions {
|
|
58
67
|
readonly code: MetricsErrorCode;
|
|
59
68
|
readonly operation: string;
|
|
60
69
|
readonly message: string;
|
|
61
70
|
readonly instrumentName?: string;
|
|
71
|
+
readonly attributeKey?: string;
|
|
72
|
+
readonly policyReason?: MetricLabelRejection;
|
|
73
|
+
readonly field?: ResourceIdentityField;
|
|
74
|
+
readonly rule?: string;
|
|
62
75
|
readonly retryable: boolean;
|
|
63
76
|
readonly cause?: unknown;
|
|
64
77
|
}
|
|
@@ -66,9 +79,12 @@ export declare class MetricsError extends Error {
|
|
|
66
79
|
readonly code: MetricsErrorCode;
|
|
67
80
|
readonly operation: string;
|
|
68
81
|
readonly instrumentName?: string;
|
|
82
|
+
readonly attributeKey?: string;
|
|
83
|
+
readonly policyReason?: MetricLabelRejection;
|
|
84
|
+
readonly field?: ResourceIdentityField;
|
|
85
|
+
readonly rule?: string;
|
|
69
86
|
readonly retryable: boolean;
|
|
70
87
|
readonly cause?: unknown;
|
|
71
88
|
constructor(options: MetricsErrorOptions);
|
|
72
89
|
}
|
|
73
90
|
export declare const createMetrics: (options: MetricsOptions) => Promise<Metrics>;
|
|
74
|
-
export {};
|
package/dist/Metrics.js
CHANGED
|
@@ -3,6 +3,10 @@ export class MetricsError extends Error {
|
|
|
3
3
|
code;
|
|
4
4
|
operation;
|
|
5
5
|
instrumentName;
|
|
6
|
+
attributeKey;
|
|
7
|
+
policyReason;
|
|
8
|
+
field;
|
|
9
|
+
rule;
|
|
6
10
|
retryable;
|
|
7
11
|
cause;
|
|
8
12
|
constructor(options) {
|
|
@@ -13,6 +17,18 @@ export class MetricsError extends Error {
|
|
|
13
17
|
if (options.instrumentName !== undefined) {
|
|
14
18
|
this.instrumentName = options.instrumentName;
|
|
15
19
|
}
|
|
20
|
+
if (options.attributeKey !== undefined) {
|
|
21
|
+
this.attributeKey = options.attributeKey;
|
|
22
|
+
}
|
|
23
|
+
if (options.policyReason !== undefined) {
|
|
24
|
+
this.policyReason = options.policyReason;
|
|
25
|
+
}
|
|
26
|
+
if (options.field !== undefined) {
|
|
27
|
+
this.field = options.field;
|
|
28
|
+
}
|
|
29
|
+
if (options.rule !== undefined) {
|
|
30
|
+
this.rule = options.rule;
|
|
31
|
+
}
|
|
16
32
|
this.retryable = options.retryable;
|
|
17
33
|
this.cause = options.cause;
|
|
18
34
|
}
|
package/dist/MetricsRuntime.d.ts
CHANGED
|
@@ -1,11 +1,53 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
2
|
import { HttpClient } from "effect/unstable/http";
|
|
3
3
|
import { OtlpExporter } from "effect/unstable/observability";
|
|
4
|
-
import type { Metrics, MetricsOptions } from "./Metrics.js";
|
|
4
|
+
import type { CounterDefinition, GaugeObservation, MetricAttribute, MetricAttributeValue, Metrics, MetricsOptions } from "./Metrics.js";
|
|
5
5
|
import type { TelemetryConfig } from "./TelemetryConfig.js";
|
|
6
|
+
import { type DataPolicy } from "./policy/DataPolicy.js";
|
|
7
|
+
type ContractCardinalityLimit = {
|
|
8
|
+
readonly attributeName: string;
|
|
9
|
+
readonly maximumCardinality: number;
|
|
10
|
+
};
|
|
11
|
+
type ContractMetricDefinitionIdentity = {
|
|
12
|
+
readonly alias: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly kind: "counter" | "histogram" | "observable_gauge";
|
|
15
|
+
};
|
|
16
|
+
type ContractMetricAttribute = {
|
|
17
|
+
readonly key: string;
|
|
18
|
+
readonly value: MetricAttributeValue;
|
|
19
|
+
};
|
|
20
|
+
export type ContractMetricAdmission = {
|
|
21
|
+
readonly metrics: Metrics;
|
|
22
|
+
readonly metricAlias: string;
|
|
23
|
+
readonly metricName: string;
|
|
24
|
+
readonly definitionIdentity: ContractMetricDefinitionIdentity;
|
|
25
|
+
readonly attributes: ReadonlyArray<ContractMetricAttribute>;
|
|
26
|
+
readonly limits: ReadonlyArray<ContractCardinalityLimit>;
|
|
27
|
+
};
|
|
28
|
+
type ContractGaugeObservation = ContractMetricAdmission;
|
|
29
|
+
export declare const registerContractGaugeObservation: (observation: GaugeObservation, contract: ContractGaugeObservation) => GaugeObservation;
|
|
30
|
+
export type MetricCounterBatchMeasurement = {
|
|
31
|
+
readonly definition: CounterDefinition;
|
|
32
|
+
readonly value: number;
|
|
33
|
+
readonly attributes: ReadonlyArray<MetricAttribute>;
|
|
34
|
+
readonly admission: ContractMetricAdmission;
|
|
35
|
+
};
|
|
36
|
+
export declare const reserveMetricCounterBatch: (metrics: Metrics, measurements: ReadonlyArray<MetricCounterBatchMeasurement>) => (() => void);
|
|
37
|
+
export declare const prepareContractMetricBatch: (admissions: ReadonlyArray<ContractMetricAdmission>) => (() => void);
|
|
38
|
+
export declare const prepareContractMetricAttributes: (metrics: Metrics, metricAlias: string, metricName: string, definitionIdentity: ContractMetricDefinitionIdentity, attributes: ReadonlyArray<ContractMetricAttribute>, limits: ReadonlyArray<ContractCardinalityLimit>) => (() => void);
|
|
39
|
+
export declare const releaseMetricsLease: (metrics: Metrics) => Promise<void>;
|
|
40
|
+
export declare const createDisabledMetrics: (policy?: DataPolicy) => Metrics;
|
|
6
41
|
export declare const createStandaloneMetrics: (optionsInput: MetricsOptions) => Promise<Metrics>;
|
|
7
42
|
interface LayerMetricsOptions {
|
|
8
43
|
readonly shutdownTimeoutMilliseconds: number;
|
|
44
|
+
readonly policy: DataPolicy;
|
|
45
|
+
readonly resourceAttributes: ReadonlyMap<string, string>;
|
|
9
46
|
}
|
|
10
|
-
|
|
47
|
+
declare const LayerMetricsRuntime_base: Context.ServiceClass<LayerMetricsRuntime, "@equipe-tech/observability/internal/LayerMetricsRuntime", {
|
|
48
|
+
readonly acquireMetrics: () => Metrics;
|
|
49
|
+
}>;
|
|
50
|
+
export declare class LayerMetricsRuntime extends LayerMetricsRuntime_base {
|
|
51
|
+
}
|
|
52
|
+
export declare const layerMetricsRuntime: (config: TelemetryConfig, options: LayerMetricsOptions) => Layer.Layer<OtlpExporter.Flusher | LayerMetricsRuntime, never, HttpClient.HttpClient>;
|
|
11
53
|
export {};
|