@smthrs/observability 0.35.0 → 1.0.0-rc.13
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 +56 -0
- package/LICENSE +1 -1
- package/README.md +87 -0
- package/dist/cjs/BrowserOtel.d.ts +37 -0
- package/dist/cjs/BrowserOtel.d.ts.map +1 -0
- package/dist/cjs/BrowserOtel.js +47 -0
- package/dist/cjs/BrowserOtel.js.map +7 -0
- package/dist/cjs/Endpoint.d.ts +70 -0
- package/dist/cjs/Endpoint.d.ts.map +1 -0
- package/dist/cjs/Endpoint.js +85 -0
- package/dist/cjs/Endpoint.js.map +7 -0
- package/dist/cjs/JournalLogger.d.ts +232 -0
- package/dist/cjs/JournalLogger.d.ts.map +1 -0
- package/dist/cjs/JournalLogger.js +415 -0
- package/dist/cjs/JournalLogger.js.map +7 -0
- package/dist/cjs/Logger.d.ts +56 -0
- package/dist/cjs/Logger.d.ts.map +1 -0
- package/dist/cjs/Logger.js +72 -0
- package/dist/cjs/Logger.js.map +7 -0
- package/dist/cjs/Metric.d.ts +67 -0
- package/dist/cjs/Metric.d.ts.map +1 -0
- package/dist/cjs/Metric.js +68 -0
- package/dist/cjs/Metric.js.map +7 -0
- package/dist/cjs/NodeOtel.d.ts +42 -0
- package/dist/cjs/NodeOtel.d.ts.map +1 -0
- package/dist/cjs/NodeOtel.js +78 -0
- package/dist/cjs/NodeOtel.js.map +7 -0
- package/dist/cjs/Otel.d.ts +63 -0
- package/dist/cjs/Otel.d.ts.map +1 -0
- package/dist/cjs/Otel.js +75 -0
- package/dist/cjs/Otel.js.map +7 -0
- package/dist/cjs/Otlp.d.ts +203 -0
- package/dist/cjs/Otlp.d.ts.map +1 -0
- package/dist/cjs/Otlp.js +251 -0
- package/dist/cjs/Otlp.js.map +7 -0
- package/dist/cjs/Resource.d.ts +163 -0
- package/dist/cjs/Resource.d.ts.map +1 -0
- package/dist/cjs/Resource.js +186 -0
- package/dist/cjs/Resource.js.map +7 -0
- package/dist/cjs/index.d.ts +61 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/schemaIssuePath.d.ts +31 -0
- package/dist/cjs/internal/schemaIssuePath.d.ts.map +1 -0
- package/dist/cjs/internal/schemaIssuePath.js +49 -0
- package/dist/cjs/internal/schemaIssuePath.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/BrowserOtel.d.ts +37 -0
- package/dist/esm/BrowserOtel.d.ts.map +1 -0
- package/dist/esm/BrowserOtel.js +24 -0
- package/dist/esm/BrowserOtel.js.map +1 -0
- package/dist/esm/Endpoint.d.ts +70 -0
- package/dist/esm/Endpoint.d.ts.map +1 -0
- package/dist/esm/Endpoint.js +110 -0
- package/dist/esm/Endpoint.js.map +1 -0
- package/dist/esm/JournalLogger.d.ts +232 -0
- package/dist/esm/JournalLogger.d.ts.map +1 -0
- package/dist/esm/JournalLogger.js +520 -0
- package/dist/esm/JournalLogger.js.map +1 -0
- package/dist/esm/Logger.d.ts +56 -0
- package/dist/esm/Logger.d.ts.map +1 -0
- package/dist/esm/Logger.js +61 -0
- package/dist/esm/Logger.js.map +1 -0
- package/dist/esm/Metric.d.ts +67 -0
- package/dist/esm/Metric.d.ts.map +1 -0
- package/dist/esm/Metric.js +80 -0
- package/dist/esm/Metric.js.map +1 -0
- package/dist/esm/NodeOtel.d.ts +42 -0
- package/dist/esm/NodeOtel.d.ts.map +1 -0
- package/dist/esm/NodeOtel.js +56 -0
- package/dist/esm/NodeOtel.js.map +1 -0
- package/dist/esm/Otel.d.ts +63 -0
- package/dist/esm/Otel.d.ts.map +1 -0
- package/dist/esm/Otel.js +52 -0
- package/dist/esm/Otel.js.map +1 -0
- package/dist/esm/Otlp.d.ts +203 -0
- package/dist/esm/Otlp.d.ts.map +1 -0
- package/dist/esm/Otlp.js +384 -0
- package/dist/esm/Otlp.js.map +1 -0
- package/dist/esm/Resource.d.ts +163 -0
- package/dist/esm/Resource.d.ts.map +1 -0
- package/dist/esm/Resource.js +238 -0
- package/dist/esm/Resource.js.map +1 -0
- package/dist/esm/index.d.ts +61 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +61 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/schemaIssuePath.d.ts +31 -0
- package/dist/esm/internal/schemaIssuePath.d.ts.map +1 -0
- package/dist/esm/internal/schemaIssuePath.js +59 -0
- package/dist/esm/internal/schemaIssuePath.js.map +1 -0
- package/docs/README.md +164 -0
- package/docs/api.md +780 -0
- package/docs/concepts/instrumentation-and-export.md +98 -0
- package/docs/concepts/layer-map.md +73 -0
- package/docs/concepts/validated-acquisition.md +106 -0
- package/docs/guides/export-to-a-collector.md +190 -0
- package/docs/guides/forward-logs-to-the-journal.md +226 -0
- package/docs/guides/install-a-logger.md +111 -0
- package/docs/guides/read-runtime-metrics.md +83 -0
- package/docs/guides/testing.md +134 -0
- package/docs/guides/wire-an-opentelemetry-sdk.md +226 -0
- package/docs/installation.md +102 -0
- package/docs/quickstart.md +145 -0
- package/docs/troubleshooting.md +168 -0
- package/package.json +221 -32
- package/src/BrowserOtel.ts +51 -0
- package/src/Endpoint.ts +131 -0
- package/src/JournalLogger.ts +635 -0
- package/src/Logger.ts +107 -0
- package/src/Metric.ts +88 -0
- package/src/NodeOtel.ts +90 -0
- package/src/Otel.ts +118 -0
- package/src/Otlp.ts +514 -0
- package/src/Resource.ts +325 -0
- package/src/index.ts +67 -0
- package/src/internal/schemaIssuePath.ts +65 -0
- package/docker-compose.otel.yml +0 -104
- package/grafana/dashboards/smithers-dashboard.json +0 -453
- package/grafana/provisioning/dashboards/dashboards.yml +0 -12
- package/grafana/provisioning/datasources/datasources.yml +0 -49
- package/loki/loki-config.yaml +0 -35
- package/otel-collector-config.yml +0 -38
- package/prometheus/prometheus.yml +0 -8
- package/src/MetricName.ts +0 -1
- package/src/MetricsServiceLive.js +0 -9
- package/src/README.md +0 -28
- package/src/ResolvedSmithersObservabilityOptions.ts +0 -12
- package/src/SmithersEvent.ts +0 -843
- package/src/SmithersLogFormat.ts +0 -1
- package/src/SmithersMetricDefinition.ts +0 -15
- package/src/SmithersMetricType.ts +0 -1
- package/src/SmithersMetricUnit.ts +0 -1
- package/src/SmithersObservability.js +0 -15
- package/src/SmithersObservabilityOptions.ts +0 -12
- package/src/SmithersObservabilityService.ts +0 -13
- package/src/_coreCorrelation/CorrelationContext.ts +0 -10
- package/src/_coreCorrelation/CorrelationContextLive.js +0 -11
- package/src/_coreCorrelation/CorrelationContextService.js +0 -15
- package/src/_coreCorrelation/CorrelationContextServiceShape.ts +0 -12
- package/src/_coreCorrelation/CorrelationPatch.ts +0 -3
- package/src/_coreCorrelation/README.md +0 -20
- package/src/_coreCorrelation/_correlationStorage.js +0 -4
- package/src/_coreCorrelation/correlationContextFiberRef.js +0 -5
- package/src/_coreCorrelation/correlationContextToLogAnnotations.js +0 -18
- package/src/_coreCorrelation/getCurrentCorrelationContext.js +0 -9
- package/src/_coreCorrelation/getCurrentCorrelationContextEffect.js +0 -11
- package/src/_coreCorrelation/index.js +0 -14
- package/src/_coreCorrelation/mergeCorrelationContext.js +0 -51
- package/src/_coreCorrelation/runWithCorrelationContext.js +0 -14
- package/src/_coreCorrelation/updateCurrentCorrelationContext.js +0 -17
- package/src/_coreCorrelation/withCorrelationContext.js +0 -38
- package/src/_coreCorrelation/withCurrentCorrelationContext.js +0 -11
- package/src/_coreMetrics.js +0 -14
- package/src/_coreMetricsShape.ts +0 -44
- package/src/_corePrometheus.js +0 -91
- package/src/_corePrometheusShape.ts +0 -11
- package/src/_coreTracing.js +0 -132
- package/src/_coreTracingShape.ts +0 -17
- package/src/_otelLogBuilders.js +0 -102
- package/src/_sessionFileResolvers.js +0 -164
- package/src/_smithersSpanAttributeAliases.js +0 -19
- package/src/_smithersTraceSpanStorage.js +0 -3
- package/src/_traceEventNormalizers.js +0 -499
- package/src/_traceRedaction.js +0 -162
- package/src/agentSessionEventToOtelLogRecord.js +0 -55
- package/src/agentTrace.ts +0 -144
- package/src/agentTraceCapabilities.js +0 -151
- package/src/annotateSmithersTrace.js +0 -11
- package/src/canonicalTraceEventToOtelLogRecord.js +0 -55
- package/src/correlation.js +0 -56
- package/src/createSmithersObservabilityLayer.js +0 -59
- package/src/createSmithersOtelLayer.js +0 -23
- package/src/createSmithersRuntimeLayer.js +0 -2
- package/src/detectAgentFamily.js +0 -26
- package/src/detectCaptureMode.js +0 -29
- package/src/emitOtelLogRecord.js +0 -19
- package/src/getCurrentSmithersTraceAnnotations.js +0 -14
- package/src/getCurrentSmithersTraceSpan.js +0 -7
- package/src/index.d.ts +0 -1392
- package/src/index.js +0 -137
- package/src/kindPhase.js +0 -17
- package/src/logging.js +0 -264
- package/src/makeSmithersSpanAttributes.js +0 -20
- package/src/metrics/README.md +0 -22
- package/src/metrics/SmithersMetricDefinition.ts +0 -17
- package/src/metrics/SmithersMetricType.ts +0 -1
- package/src/metrics/SmithersMetricUnit.ts +0 -1
- package/src/metrics/_asyncExternalWaitCounts.js +0 -4
- package/src/metrics/_buckets.js +0 -37
- package/src/metrics/_incrementGauge.js +0 -11
- package/src/metrics/_processStartMs.js +0 -1
- package/src/metrics/activeNodes.js +0 -2
- package/src/metrics/activeRuns.js +0 -2
- package/src/metrics/agentActionsTotal.js +0 -2
- package/src/metrics/agentDurationMs.js +0 -3
- package/src/metrics/agentErrorsTotal.js +0 -2
- package/src/metrics/agentEventsTotal.js +0 -2
- package/src/metrics/agentInvocationsTotal.js +0 -2
- package/src/metrics/agentRetriesTotal.js +0 -2
- package/src/metrics/agentSessionsTotal.js +0 -2
- package/src/metrics/agentTokensTotal.js +0 -2
- package/src/metrics/alertDeliveriesAttempted.js +0 -2
- package/src/metrics/alertDeliveriesSuppressed.js +0 -2
- package/src/metrics/alertsAcknowledgedTotal.js +0 -2
- package/src/metrics/alertsActive.js +0 -2
- package/src/metrics/alertsEscalatedTotal.js +0 -2
- package/src/metrics/alertsFiredTotal.js +0 -2
- package/src/metrics/alertsReopenedTotal.js +0 -2
- package/src/metrics/alertsResolvedTotal.js +0 -2
- package/src/metrics/alertsSilencedTotal.js +0 -2
- package/src/metrics/approvalPending.js +0 -2
- package/src/metrics/approvalWaitDuration.js +0 -5
- package/src/metrics/approvalsDenied.js +0 -2
- package/src/metrics/approvalsGranted.js +0 -2
- package/src/metrics/approvalsRequested.js +0 -2
- package/src/metrics/attemptDuration.js +0 -3
- package/src/metrics/attentionBacklog.js +0 -2
- package/src/metrics/cacheHits.js +0 -2
- package/src/metrics/cacheMisses.js +0 -2
- package/src/metrics/dbQueryDuration.js +0 -3
- package/src/metrics/dbRetries.js +0 -2
- package/src/metrics/dbTransactionDuration.js +0 -3
- package/src/metrics/dbTransactionRetries.js +0 -2
- package/src/metrics/dbTransactionRollbacks.js +0 -2
- package/src/metrics/devtoolsActiveSubscribers.js +0 -2
- package/src/metrics/devtoolsBackpressureDisconnectTotal.js +0 -2
- package/src/metrics/devtoolsDeltaBuildMs.js +0 -3
- package/src/metrics/devtoolsEventBytes.js +0 -3
- package/src/metrics/devtoolsEventTotal.js +0 -2
- package/src/metrics/devtoolsSnapshotBuildMs.js +0 -5
- package/src/metrics/devtoolsSubscribeTotal.js +0 -2
- package/src/metrics/errorsTotal.js +0 -2
- package/src/metrics/eventsEmittedTotal.js +0 -2
- package/src/metrics/externalWaitAsyncPending.js +0 -2
- package/src/metrics/gatewayApprovalDecisionsTotal.js +0 -2
- package/src/metrics/gatewayAuthEventsTotal.js +0 -2
- package/src/metrics/gatewayConnectionsActive.js +0 -2
- package/src/metrics/gatewayConnectionsClosedTotal.js +0 -2
- package/src/metrics/gatewayConnectionsTotal.js +0 -2
- package/src/metrics/gatewayCronTriggersTotal.js +0 -2
- package/src/metrics/gatewayErrorsTotal.js +0 -2
- package/src/metrics/gatewayHeartbeatTicksTotal.js +0 -2
- package/src/metrics/gatewayMessagesReceivedTotal.js +0 -2
- package/src/metrics/gatewayMessagesSentTotal.js +0 -2
- package/src/metrics/gatewayRpcCallsTotal.js +0 -2
- package/src/metrics/gatewayRpcDuration.js +0 -3
- package/src/metrics/gatewayRunEventBackpressureDisconnectTotal.js +0 -4
- package/src/metrics/gatewayRunsCompletedTotal.js +0 -2
- package/src/metrics/gatewayRunsStartedTotal.js +0 -2
- package/src/metrics/gatewaySignalsTotal.js +0 -2
- package/src/metrics/gatewayWebhooksReceivedTotal.js +0 -2
- package/src/metrics/gatewayWebhooksRejectedTotal.js +0 -2
- package/src/metrics/gatewayWebhooksVerifiedTotal.js +0 -2
- package/src/metrics/heartbeatDataSizeBytes.js +0 -5
- package/src/metrics/heartbeatIntervalMs.js +0 -3
- package/src/metrics/hotReloadDuration.js +0 -3
- package/src/metrics/hotReloadFailures.js +0 -2
- package/src/metrics/hotReloads.js +0 -2
- package/src/metrics/httpRequestDuration.js +0 -3
- package/src/metrics/httpRequests.js +0 -2
- package/src/metrics/index.d.ts +0 -1222
- package/src/metrics/index.js +0 -168
- package/src/metrics/memoryFactReads.js +0 -3
- package/src/metrics/memoryFactWrites.js +0 -3
- package/src/metrics/memoryMessageSaves.js +0 -3
- package/src/metrics/memoryRecallDuration.js +0 -11
- package/src/metrics/memoryRecallQueries.js +0 -3
- package/src/metrics/metricsServiceAdapter.js +0 -181
- package/src/metrics/nodeDuration.js +0 -3
- package/src/metrics/nodeRetriesTotal.js +0 -2
- package/src/metrics/nodesFailed.js +0 -2
- package/src/metrics/nodesFinished.js +0 -2
- package/src/metrics/nodesStarted.js +0 -2
- package/src/metrics/openApiToolCallErrorsTotal.js +0 -3
- package/src/metrics/openApiToolCallsTotal.js +0 -3
- package/src/metrics/openApiToolDuration.js +0 -9
- package/src/metrics/processHeapUsedBytes.js +0 -2
- package/src/metrics/processMemoryRssBytes.js +0 -2
- package/src/metrics/processUptimeSeconds.js +0 -2
- package/src/metrics/promptSizeBytes.js +0 -3
- package/src/metrics/replaysStarted.js +0 -3
- package/src/metrics/responseSizeBytes.js +0 -3
- package/src/metrics/rewindDurationMs.js +0 -3
- package/src/metrics/rewindFramesDeleted.js +0 -3
- package/src/metrics/rewindRollbackTotal.js +0 -2
- package/src/metrics/rewindSandboxesReverted.js +0 -3
- package/src/metrics/rewindTotal.js +0 -2
- package/src/metrics/runDuration.js +0 -3
- package/src/metrics/runForksCreated.js +0 -3
- package/src/metrics/runsAncestryDepth.js +0 -3
- package/src/metrics/runsCancelledTotal.js +0 -2
- package/src/metrics/runsCarriedStateBytes.js +0 -5
- package/src/metrics/runsContinuedTotal.js +0 -2
- package/src/metrics/runsFailedTotal.js +0 -2
- package/src/metrics/runsFinishedTotal.js +0 -2
- package/src/metrics/runsResumedTotal.js +0 -2
- package/src/metrics/runsTotal.js +0 -2
- package/src/metrics/sandboxActive.js +0 -2
- package/src/metrics/sandboxBundleSizeBytes.js +0 -5
- package/src/metrics/sandboxCompletedTotal.js +0 -2
- package/src/metrics/sandboxCreatedTotal.js +0 -2
- package/src/metrics/sandboxDurationMs.js +0 -3
- package/src/metrics/sandboxPatchCount.js +0 -3
- package/src/metrics/sandboxTransportDurationMs.js +0 -5
- package/src/metrics/schedulerConcurrencyUtilization.js +0 -2
- package/src/metrics/schedulerQueueDepth.js +0 -2
- package/src/metrics/schedulerWaitDuration.js +0 -5
- package/src/metrics/scorerDuration.js +0 -9
- package/src/metrics/scorerEventsFailed.js +0 -2
- package/src/metrics/scorerEventsFinished.js +0 -2
- package/src/metrics/scorerEventsStarted.js +0 -2
- package/src/metrics/scorersFailed.js +0 -3
- package/src/metrics/scorersFinished.js +0 -3
- package/src/metrics/scorersStarted.js +0 -3
- package/src/metrics/smithersMetricCatalog.js +0 -893
- package/src/metrics/smithersMetricCatalogByKey.js +0 -2
- package/src/metrics/smithersMetricCatalogByName.js +0 -2
- package/src/metrics/smithersMetricCatalogByPrometheusName.js +0 -4
- package/src/metrics/snapshotDuration.js +0 -9
- package/src/metrics/snapshotsCaptured.js +0 -3
- package/src/metrics/supervisorPollDuration.js +0 -5
- package/src/metrics/supervisorPollsTotal.js +0 -2
- package/src/metrics/supervisorResumeLag.js +0 -5
- package/src/metrics/supervisorResumedTotal.js +0 -2
- package/src/metrics/supervisorSkippedTotal.js +0 -2
- package/src/metrics/supervisorStaleDetected.js +0 -2
- package/src/metrics/taskHeartbeatTimeoutTotal.js +0 -2
- package/src/metrics/taskHeartbeatsTotal.js +0 -2
- package/src/metrics/timerDelayDuration.js +0 -3
- package/src/metrics/timersCancelled.js +0 -2
- package/src/metrics/timersCreated.js +0 -2
- package/src/metrics/timersFired.js +0 -2
- package/src/metrics/timersPending.js +0 -2
- package/src/metrics/toPrometheusMetricName.js +0 -8
- package/src/metrics/tokensCacheReadTotal.js +0 -2
- package/src/metrics/tokensCacheWriteTotal.js +0 -2
- package/src/metrics/tokensContextWindowBucketTotal.js +0 -2
- package/src/metrics/tokensContextWindowPerCall.js +0 -5
- package/src/metrics/tokensInputPerCall.js +0 -3
- package/src/metrics/tokensInputTotal.js +0 -2
- package/src/metrics/tokensOutputPerCall.js +0 -3
- package/src/metrics/tokensOutputTotal.js +0 -2
- package/src/metrics/tokensReasoningTotal.js +0 -2
- package/src/metrics/toolCallErrorsTotal.js +0 -2
- package/src/metrics/toolCallsTotal.js +0 -2
- package/src/metrics/toolDuration.js +0 -3
- package/src/metrics/toolOutputTruncatedTotal.js +0 -2
- package/src/metrics/trackEvent.js +0 -608
- package/src/metrics/updateAsyncExternalWaitPending.js +0 -18
- package/src/metrics/updateProcessMetrics.js +0 -20
- package/src/metrics/vcsDuration.js +0 -3
- package/src/normalizeStructuredEvent.js +0 -15
- package/src/prometheusContentType.js +0 -1
- package/src/renderPrometheusMetrics.js +0 -212
- package/src/resolveAgentTraceCapabilities.js +0 -59
- package/src/resolveSmithersObservabilityOptions.js +0 -109
- package/src/smithersMetrics.js +0 -2
- package/src/smithersSpanNames.js +0 -6
- package/src/unsupportedKindsForCapabilities.js +0 -32
- package/src/withSmithersSpan.js +0 -17
- package/tempo/tempo.yml +0 -17
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit, validated OpenTelemetry resource metadata for Smithers.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
import * as OtelResource from "@effect/opentelemetry/Resource";
|
|
7
|
+
import type { Attributes as OtelAttributes } from "@opentelemetry/api";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
/**
|
|
12
|
+
* Largest service-name or service-version field accepted by a resource.
|
|
13
|
+
*
|
|
14
|
+
* @category constants
|
|
15
|
+
* @since 1.0.0-rc.0
|
|
16
|
+
*/
|
|
17
|
+
export declare const maximumIdentityLength = 1024;
|
|
18
|
+
/**
|
|
19
|
+
* Largest attribute key accepted by a resource.
|
|
20
|
+
*
|
|
21
|
+
* @category constants
|
|
22
|
+
* @since 1.0.0-rc.0
|
|
23
|
+
*/
|
|
24
|
+
export declare const maximumAttributeKeyLength = 1024;
|
|
25
|
+
/**
|
|
26
|
+
* Largest string value accepted by one resource attribute.
|
|
27
|
+
*
|
|
28
|
+
* @category constants
|
|
29
|
+
* @since 1.0.0-rc.0
|
|
30
|
+
*/
|
|
31
|
+
export declare const maximumAttributeStringLength = 65536;
|
|
32
|
+
/**
|
|
33
|
+
* Largest number of elements accepted in one array attribute value.
|
|
34
|
+
*
|
|
35
|
+
* @category constants
|
|
36
|
+
* @since 1.0.0-rc.0
|
|
37
|
+
*/
|
|
38
|
+
export declare const maximumAttributeArrayLength = 256;
|
|
39
|
+
/**
|
|
40
|
+
* Largest number of attributes accepted by one resource.
|
|
41
|
+
*
|
|
42
|
+
* @category constants
|
|
43
|
+
* @since 1.0.0-rc.0
|
|
44
|
+
*/
|
|
45
|
+
export declare const maximumAttributes = 256;
|
|
46
|
+
/**
|
|
47
|
+
* Largest OTLP/JSON encoding accepted for one whole resource, in UTF-8 bytes.
|
|
48
|
+
*
|
|
49
|
+
* The measure is the OTLP `Resource` message the exporters place in every
|
|
50
|
+
* request, `{"attributes":[{"key":…,"value":{…}}],"droppedAttributesCount":0}`
|
|
51
|
+
* with service identity and SDK-added `telemetry.sdk.name`,
|
|
52
|
+
* `telemetry.sdk.language` and `telemetry.sdk.version` included, after JSON
|
|
53
|
+
* escaping and UTF-8 encoding. The SDK's own values are reserved even for the
|
|
54
|
+
* default Effect exporter, whose values are shorter. A caller attribute that
|
|
55
|
+
* replaces an SDK field, or that service identity overwrites, is counted
|
|
56
|
+
* beside it. It is the bound the per-field limits cannot express: 256
|
|
57
|
+
* attributes at the string ceiling would encode to 16 MiB, and the resource
|
|
58
|
+
* rides in every export request, so the default transport, which discards a
|
|
59
|
+
* request over 1 MiB, would deliver nothing at all. 128 KiB admits one
|
|
60
|
+
* ASCII attribute at the string ceiling and leaves that transport 888 KiB of every
|
|
61
|
+
* request for the signal batch; see `Otlp.reservedBatchBytes`.
|
|
62
|
+
*
|
|
63
|
+
* @category constants
|
|
64
|
+
* @since 1.0.0-rc.0
|
|
65
|
+
*/
|
|
66
|
+
export declare const maximumResourceBytes = 131072;
|
|
67
|
+
/**
|
|
68
|
+
* Runtime schema for one OpenTelemetry resource attribute value.
|
|
69
|
+
*
|
|
70
|
+
* @category schemas
|
|
71
|
+
* @since 1.0.0-rc.0
|
|
72
|
+
*/
|
|
73
|
+
export declare const AttributeValue: Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.String>, Schema.$Array<Schema.Number>, Schema.$Array<Schema.Boolean>]>;
|
|
74
|
+
/**
|
|
75
|
+
* Runtime schema for OpenTelemetry resource attributes.
|
|
76
|
+
*
|
|
77
|
+
* @category schemas
|
|
78
|
+
* @since 1.0.0-rc.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const Attributes: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.String>, Schema.$Array<Schema.Number>, Schema.$Array<Schema.Boolean>]>>;
|
|
81
|
+
/**
|
|
82
|
+
* Runtime schema for the service identity attached to exported telemetry.
|
|
83
|
+
*
|
|
84
|
+
* @category schemas
|
|
85
|
+
* @since 1.0.0-rc.0
|
|
86
|
+
*/
|
|
87
|
+
export declare const Configuration: Schema.Struct<{
|
|
88
|
+
readonly serviceName: Schema.NonEmptyString;
|
|
89
|
+
readonly serviceVersion: Schema.optional<Schema.NonEmptyString>;
|
|
90
|
+
readonly attributes: Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Number, Schema.Boolean, Schema.$Array<Schema.String>, Schema.$Array<Schema.Number>, Schema.$Array<Schema.Boolean>]>>>;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* Configuration used to identify the service emitting telemetry.
|
|
94
|
+
*
|
|
95
|
+
* @category models
|
|
96
|
+
* @since 1.0.0-rc.0
|
|
97
|
+
*/
|
|
98
|
+
export type Configuration = typeof Configuration.Type;
|
|
99
|
+
declare const InvalidResourceConfiguration_base: Schema.Class<InvalidResourceConfiguration, Schema.TaggedStruct<"@smthrs/observability/InvalidResourceConfiguration", {
|
|
100
|
+
readonly code: Schema.Literal<"invalid_resource_configuration">;
|
|
101
|
+
readonly path: Schema.String;
|
|
102
|
+
readonly message: Schema.String;
|
|
103
|
+
}>, import("effect/Cause").YieldableError>;
|
|
104
|
+
/**
|
|
105
|
+
* Stable resource-configuration refusal shared by every OTEL layer.
|
|
106
|
+
*
|
|
107
|
+
* @category errors
|
|
108
|
+
* @since 1.0.0-rc.0
|
|
109
|
+
*/
|
|
110
|
+
export declare class InvalidResourceConfiguration extends InvalidResourceConfiguration_base {
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Decodes one resource configuration without retaining rejected values.
|
|
114
|
+
*
|
|
115
|
+
* @category decoding
|
|
116
|
+
* @since 1.0.0-rc.0
|
|
117
|
+
*/
|
|
118
|
+
export declare const decode: (configuration: unknown) => Effect.Effect<Configuration, InvalidResourceConfiguration>;
|
|
119
|
+
/**
|
|
120
|
+
* Decodes one resource configuration for the package's pure projection API.
|
|
121
|
+
*
|
|
122
|
+
* @category decoding
|
|
123
|
+
* @since 1.0.0-rc.0
|
|
124
|
+
*/
|
|
125
|
+
export declare const decodeSync: (configuration: unknown) => Configuration;
|
|
126
|
+
/**
|
|
127
|
+
* Projects a decoded resource into the exact optional-property shape expected
|
|
128
|
+
* by the OpenTelemetry SDK.
|
|
129
|
+
*
|
|
130
|
+
* @category conversions
|
|
131
|
+
* @since 1.0.0-rc.0
|
|
132
|
+
*/
|
|
133
|
+
export declare const toOpenTelemetryConfiguration: (configuration: Configuration) => {
|
|
134
|
+
readonly serviceName: string;
|
|
135
|
+
readonly serviceVersion?: string;
|
|
136
|
+
readonly attributes?: OtelAttributes;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Converts explicit service metadata into OpenTelemetry resource attributes.
|
|
140
|
+
*
|
|
141
|
+
* No environment variables are read. Invalid metadata throws the same typed
|
|
142
|
+
* {@link InvalidResourceConfiguration} every layer returns during acquisition.
|
|
143
|
+
*
|
|
144
|
+
* @category conversions
|
|
145
|
+
* @since 1.0.0-rc.0
|
|
146
|
+
*/
|
|
147
|
+
export declare const configToAttributes: (configuration: Configuration) => OtelAttributes;
|
|
148
|
+
/**
|
|
149
|
+
* Provides an explicitly validated OpenTelemetry resource.
|
|
150
|
+
*
|
|
151
|
+
* @category layers
|
|
152
|
+
* @since 1.0.0-rc.0
|
|
153
|
+
*/
|
|
154
|
+
export declare const layer: (configuration: Configuration) => Layer.Layer<OtelResource.Resource, InvalidResourceConfiguration>;
|
|
155
|
+
/**
|
|
156
|
+
* The OpenTelemetry resource service.
|
|
157
|
+
*
|
|
158
|
+
* @category services
|
|
159
|
+
* @since 1.0.0-rc.0
|
|
160
|
+
*/
|
|
161
|
+
export declare const Resource: typeof OtelResource.Resource;
|
|
162
|
+
export {};
|
|
163
|
+
//# sourceMappingURL=Resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../../src/Resource.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,OAAQ,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,OAAQ,CAAA;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,QAAS,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAA;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,oBAAoB,SAAU,CAAA;AAqB3C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,kKAgB1B,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,UAAU,iMAYtB,CAAA;AA0CD;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;EAqBzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAA;;;;;;AAErD;;;;;GAKG;AACH,qBAAa,4BAA6B,SAAQ,iCAOjD;CAAG;AAWJ;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GACjB,eAAe,OAAO,KACrB,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,4BAA4B,CAC6B,CAAA;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,eAAe,OAAO,KAAG,aAMnD,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,eAAe,aAAa,KAC3B;IACD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,CAAA;CAcpC,CAAA;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,eAAe,aAAa,KAAG,cACwB,CAAA;AAE1F;;;;;GAKG;AACH,eAAO,MAAM,KAAK,GAChB,eAAe,aAAa,KAC3B,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,4BAA4B,CAG/D,CAAA;AAEH;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,8BAAwB,CAAA"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Resource_exports = {};
|
|
30
|
+
__export(Resource_exports, {
|
|
31
|
+
AttributeValue: () => AttributeValue,
|
|
32
|
+
Attributes: () => Attributes,
|
|
33
|
+
Configuration: () => Configuration,
|
|
34
|
+
InvalidResourceConfiguration: () => InvalidResourceConfiguration,
|
|
35
|
+
Resource: () => Resource,
|
|
36
|
+
configToAttributes: () => configToAttributes,
|
|
37
|
+
decode: () => decode,
|
|
38
|
+
decodeSync: () => decodeSync,
|
|
39
|
+
layer: () => layer,
|
|
40
|
+
maximumAttributeArrayLength: () => maximumAttributeArrayLength,
|
|
41
|
+
maximumAttributeKeyLength: () => maximumAttributeKeyLength,
|
|
42
|
+
maximumAttributeStringLength: () => maximumAttributeStringLength,
|
|
43
|
+
maximumAttributes: () => maximumAttributes,
|
|
44
|
+
maximumIdentityLength: () => maximumIdentityLength,
|
|
45
|
+
maximumResourceBytes: () => maximumResourceBytes,
|
|
46
|
+
toOpenTelemetryConfiguration: () => toOpenTelemetryConfiguration
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(Resource_exports);
|
|
49
|
+
var OtelResource = __toESM(require("@effect/opentelemetry/Resource"), 1);
|
|
50
|
+
var Effect = __toESM(require("effect/Effect"), 1);
|
|
51
|
+
var Layer = __toESM(require("effect/Layer"), 1);
|
|
52
|
+
var OtlpResource = __toESM(require("effect/observability/OtlpResource"), 1);
|
|
53
|
+
var Schema = __toESM(require("effect/Schema"), 1);
|
|
54
|
+
var import_schemaIssuePath = require("./internal/schemaIssuePath.js");
|
|
55
|
+
const maximumIdentityLength = 1024;
|
|
56
|
+
const maximumAttributeKeyLength = 1024;
|
|
57
|
+
const maximumAttributeStringLength = 65536;
|
|
58
|
+
const maximumAttributeArrayLength = 256;
|
|
59
|
+
const maximumAttributes = 256;
|
|
60
|
+
const maximumResourceBytes = 131072;
|
|
61
|
+
const loneSurrogate = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
62
|
+
const embeddedNul = new RegExp(String.fromCharCode(0));
|
|
63
|
+
const isWellFormed = (value) => !loneSurrogate.test(value) && !embeddedNul.test(value);
|
|
64
|
+
const identity = Schema.NonEmptyString.check(
|
|
65
|
+
Schema.isMaxLength(maximumIdentityLength),
|
|
66
|
+
Schema.makeFilter((value) => isWellFormed(value), { title: "wellFormedResourceIdentity" })
|
|
67
|
+
);
|
|
68
|
+
const attributeString = Schema.String.check(
|
|
69
|
+
Schema.isMaxLength(maximumAttributeStringLength),
|
|
70
|
+
Schema.makeFilter((value) => isWellFormed(value), { title: "wellFormedAttributeString" })
|
|
71
|
+
);
|
|
72
|
+
const attributeNumber = Schema.Number.check(
|
|
73
|
+
Schema.makeFilter((value) => Number.isFinite(value), { title: "finiteAttributeNumber" })
|
|
74
|
+
);
|
|
75
|
+
const AttributeValue = Schema.Union([
|
|
76
|
+
attributeString,
|
|
77
|
+
attributeNumber,
|
|
78
|
+
Schema.Boolean,
|
|
79
|
+
Schema.Array(attributeString),
|
|
80
|
+
Schema.Array(attributeNumber),
|
|
81
|
+
Schema.Array(Schema.Boolean)
|
|
82
|
+
]).check(
|
|
83
|
+
Schema.makeFilter(
|
|
84
|
+
(value) => !Array.isArray(value) || value.length <= maximumAttributeArrayLength || {
|
|
85
|
+
path: [],
|
|
86
|
+
issue: `holds ${value.length} elements, over the ${maximumAttributeArrayLength} element limit`
|
|
87
|
+
},
|
|
88
|
+
{ title: "boundedResourceAttributeArrays" }
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
const Attributes = Schema.Record(Schema.String, AttributeValue).check(
|
|
92
|
+
Schema.makeFilter(
|
|
93
|
+
(attributes) => Object.keys(attributes).length <= maximumAttributes,
|
|
94
|
+
{ title: "boundedResourceAttributes" }
|
|
95
|
+
),
|
|
96
|
+
Schema.makeFilter(
|
|
97
|
+
(attributes) => Object.keys(attributes).every(
|
|
98
|
+
(key) => key.length > 0 && key.length <= maximumAttributeKeyLength && isWellFormed(key)
|
|
99
|
+
),
|
|
100
|
+
{ title: "wellFormedResourceAttributeKeys" }
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
const encoder = new TextEncoder();
|
|
104
|
+
const encodedResourceBytes = (configuration) => {
|
|
105
|
+
const bytes = (value) => encoder.encode(JSON.stringify(value)).byteLength;
|
|
106
|
+
const identityAttributes = OtelResource.configToAttributes({
|
|
107
|
+
serviceName: configuration.serviceName,
|
|
108
|
+
...configuration.serviceVersion === void 0 ? {} : { serviceVersion: configuration.serviceVersion }
|
|
109
|
+
});
|
|
110
|
+
let total = bytes({
|
|
111
|
+
attributes: OtlpResource.entriesToAttributes(Object.entries(identityAttributes)),
|
|
112
|
+
droppedAttributesCount: 0
|
|
113
|
+
});
|
|
114
|
+
for (const [key, value] of Object.entries(configuration.attributes ?? {})) {
|
|
115
|
+
total += 1 + bytes({ key, value: Array.isArray(value) ? { arrayValue: { values: [] } } : null });
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
for (const [index, element] of value.entries()) {
|
|
118
|
+
total += (index === 0 ? 0 : 1) + bytes(OtlpResource.unknownToAttributeValue(element));
|
|
119
|
+
if (total > maximumResourceBytes) return total;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
total += bytes(OtlpResource.unknownToAttributeValue(value)) - 4;
|
|
123
|
+
}
|
|
124
|
+
if (total > maximumResourceBytes) return total;
|
|
125
|
+
}
|
|
126
|
+
return total;
|
|
127
|
+
};
|
|
128
|
+
const Configuration = Schema.Struct({
|
|
129
|
+
serviceName: identity,
|
|
130
|
+
serviceVersion: Schema.optional(identity),
|
|
131
|
+
attributes: Schema.optional(Attributes)
|
|
132
|
+
}).check(
|
|
133
|
+
Schema.makeFilter(
|
|
134
|
+
(configuration) => {
|
|
135
|
+
const bytes = encodedResourceBytes(configuration);
|
|
136
|
+
return bytes <= maximumResourceBytes || {
|
|
137
|
+
path: ["attributes"],
|
|
138
|
+
issue: `bring the resource to at least ${bytes} bytes of OTLP JSON, over the ${maximumResourceBytes} byte limit`
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
{ title: "boundedResourceBytes" }
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
class InvalidResourceConfiguration extends Schema.TaggedError()(
|
|
145
|
+
"@smthrs/observability/InvalidResourceConfiguration",
|
|
146
|
+
{
|
|
147
|
+
code: Schema.Literal("invalid_resource_configuration"),
|
|
148
|
+
path: Schema.String,
|
|
149
|
+
message: Schema.String
|
|
150
|
+
}
|
|
151
|
+
) {
|
|
152
|
+
}
|
|
153
|
+
const invalid = (cause) => {
|
|
154
|
+
const path = (0, import_schemaIssuePath.schemaIssuePath)(cause, "resource");
|
|
155
|
+
return new InvalidResourceConfiguration({
|
|
156
|
+
code: "invalid_resource_configuration",
|
|
157
|
+
path,
|
|
158
|
+
message: `OpenTelemetry resource ${path} ${(0, import_schemaIssuePath.schemaIssueMessage)(cause) ?? "is invalid"}`
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
const decode = (configuration) => Schema.decodeUnknownEffect(Configuration)(configuration).pipe(Effect.mapError(invalid));
|
|
162
|
+
const decodeSync = (configuration) => {
|
|
163
|
+
try {
|
|
164
|
+
return Schema.decodeUnknownSync(Configuration)(configuration);
|
|
165
|
+
} catch (cause) {
|
|
166
|
+
throw invalid(cause);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const toOpenTelemetryConfiguration = (configuration) => ({
|
|
170
|
+
serviceName: configuration.serviceName,
|
|
171
|
+
...configuration.serviceVersion === void 0 ? {} : { serviceVersion: configuration.serviceVersion },
|
|
172
|
+
...configuration.attributes === void 0 ? {} : {
|
|
173
|
+
attributes: Object.fromEntries(
|
|
174
|
+
Object.entries(configuration.attributes).map(([key, value]) => [
|
|
175
|
+
key,
|
|
176
|
+
Array.isArray(value) ? [...value] : value
|
|
177
|
+
])
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
const configToAttributes = (configuration) => OtelResource.configToAttributes(toOpenTelemetryConfiguration(decodeSync(configuration)));
|
|
182
|
+
const layer = (configuration) => Layer.unwrap(
|
|
183
|
+
Effect.map(decode(configuration), (decoded) => OtelResource.layer(toOpenTelemetryConfiguration(decoded)))
|
|
184
|
+
);
|
|
185
|
+
const Resource = OtelResource.Resource;
|
|
186
|
+
//# sourceMappingURL=Resource.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Resource.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Explicit, validated OpenTelemetry resource metadata for Smithers.\n *\n * @since 0.1.0\n */\n\nimport * as OtelResource from \"@effect/opentelemetry/Resource\"\nimport type { Attributes as OtelAttributes } from \"@opentelemetry/api\"\nimport * as Effect from \"effect/Effect\"\nimport * as Layer from \"effect/Layer\"\nimport * as OtlpResource from \"effect/observability/OtlpResource\"\nimport * as Schema from \"effect/Schema\"\nimport { schemaIssueMessage, schemaIssuePath } from \"./internal/schemaIssuePath.ts\"\n\n/**\n * Largest service-name or service-version field accepted by a resource.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumIdentityLength = 1_024\n\n/**\n * Largest attribute key accepted by a resource.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumAttributeKeyLength = 1_024\n\n/**\n * Largest string value accepted by one resource attribute.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumAttributeStringLength = 65_536\n\n/**\n * Largest number of elements accepted in one array attribute value.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumAttributeArrayLength = 256\n\n/**\n * Largest number of attributes accepted by one resource.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumAttributes = 256\n\n/**\n * Largest OTLP/JSON encoding accepted for one whole resource, in UTF-8 bytes.\n *\n * The measure is the OTLP `Resource` message the exporters place in every\n * request, `{\"attributes\":[{\"key\":\u2026,\"value\":{\u2026}}],\"droppedAttributesCount\":0}`\n * with service identity and SDK-added `telemetry.sdk.name`,\n * `telemetry.sdk.language` and `telemetry.sdk.version` included, after JSON\n * escaping and UTF-8 encoding. The SDK's own values are reserved even for the\n * default Effect exporter, whose values are shorter. A caller attribute that\n * replaces an SDK field, or that service identity overwrites, is counted\n * beside it. It is the bound the per-field limits cannot express: 256\n * attributes at the string ceiling would encode to 16 MiB, and the resource\n * rides in every export request, so the default transport, which discards a\n * request over 1 MiB, would deliver nothing at all. 128 KiB admits one\n * ASCII attribute at the string ceiling and leaves that transport 888 KiB of every\n * request for the signal batch; see `Otlp.reservedBatchBytes`.\n *\n * @category constants\n * @since 1.0.0-rc.0\n */\nexport const maximumResourceBytes = 131_072\n\nconst loneSurrogate = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/\nconst embeddedNul = new RegExp(String.fromCharCode(0))\n\nconst isWellFormed = (value: string): boolean => !loneSurrogate.test(value) && !embeddedNul.test(value)\n\nconst identity = Schema.NonEmptyString.check(\n Schema.isMaxLength(maximumIdentityLength),\n Schema.makeFilter((value: string) => isWellFormed(value), { title: \"wellFormedResourceIdentity\" })\n)\n\nconst attributeString = Schema.String.check(\n Schema.isMaxLength(maximumAttributeStringLength),\n Schema.makeFilter((value: string) => isWellFormed(value), { title: \"wellFormedAttributeString\" })\n)\n\nconst attributeNumber = Schema.Number.check(\n Schema.makeFilter((value: number) => Number.isFinite(value), { title: \"finiteAttributeNumber\" })\n)\n\n/**\n * Runtime schema for one OpenTelemetry resource attribute value.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const AttributeValue = Schema.Union([\n attributeString,\n attributeNumber,\n Schema.Boolean,\n Schema.Array(attributeString),\n Schema.Array(attributeNumber),\n Schema.Array(Schema.Boolean)\n]).check(\n Schema.makeFilter(\n (value) =>\n !Array.isArray(value) || value.length <= maximumAttributeArrayLength || {\n path: [],\n issue: `holds ${value.length} elements, over the ${maximumAttributeArrayLength} element limit`\n },\n { title: \"boundedResourceAttributeArrays\" }\n )\n)\n\n/**\n * Runtime schema for OpenTelemetry resource attributes.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Attributes = Schema.Record(Schema.String, AttributeValue).check(\n Schema.makeFilter(\n (attributes: Readonly<Record<string, unknown>>) => Object.keys(attributes).length <= maximumAttributes,\n { title: \"boundedResourceAttributes\" }\n ),\n Schema.makeFilter(\n (attributes: Readonly<Record<string, unknown>>) =>\n Object.keys(attributes).every(\n (key) => key.length > 0 && key.length <= maximumAttributeKeyLength && isWellFormed(key)\n ),\n { title: \"wellFormedResourceAttributeKeys\" }\n )\n)\n\nconst encoder = new TextEncoder()\n\n/**\n * Counts OTLP JSON fragments, including keys, wrappers, escaping and UTF-8.\n * Stops at the first fragment over budget: the refusal reports a lower bound.\n * A configuration may reuse one large string in thousands of array slots, so\n * serializing the whole resource before checking could allocate gigabytes.\n */\nconst encodedResourceBytes = (configuration: {\n readonly serviceName: string\n readonly serviceVersion?: string | undefined\n readonly attributes?: Record<string, unknown> | undefined\n}): number => {\n const bytes = (value: unknown) => encoder.encode(JSON.stringify(value)).byteLength\n const identityAttributes = OtelResource.configToAttributes({\n serviceName: configuration.serviceName,\n ...(configuration.serviceVersion === undefined ? {} : { serviceVersion: configuration.serviceVersion })\n })\n // Use the pinned SDK projection so its added metadata cannot escape the\n // complete-resource ceiling. Both exporters use these OTLP AnyValue shapes.\n let total = bytes({\n attributes: OtlpResource.entriesToAttributes(Object.entries(identityAttributes)),\n droppedAttributesCount: 0\n })\n for (const [key, value] of Object.entries(configuration.attributes ?? {})) {\n // An identity attribute is always present, so every addition needs a comma.\n total += 1 + bytes({ key, value: Array.isArray(value) ? { arrayValue: { values: [] } } : null })\n if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n total += (index === 0 ? 0 : 1) + bytes(OtlpResource.unknownToAttributeValue(element))\n if (total > maximumResourceBytes) return total\n }\n } else {\n total += bytes(OtlpResource.unknownToAttributeValue(value)) - 4 // replace JSON null\n }\n if (total > maximumResourceBytes) return total\n }\n return total\n}\n\n/**\n * Runtime schema for the service identity attached to exported telemetry.\n *\n * @category schemas\n * @since 1.0.0-rc.0\n */\nexport const Configuration = Schema.Struct({\n serviceName: identity,\n serviceVersion: Schema.optional(identity),\n attributes: Schema.optional(Attributes)\n}).check(\n Schema.makeFilter(\n (configuration: {\n readonly serviceName: string\n readonly serviceVersion?: string | undefined\n readonly attributes?: Record<string, unknown> | undefined\n }) => {\n const bytes = encodedResourceBytes(configuration)\n // Only attributes can carry a resource past the budget: the two identity\n // fields encode to at most 6 KiB each, so the refusal points there.\n return bytes <= maximumResourceBytes || {\n path: [\"attributes\"],\n issue: `bring the resource to at least ${bytes} bytes of OTLP JSON, over the ${maximumResourceBytes} byte limit`\n }\n },\n { title: \"boundedResourceBytes\" }\n )\n)\n\n/**\n * Configuration used to identify the service emitting telemetry.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport type Configuration = typeof Configuration.Type\n\n/**\n * Stable resource-configuration refusal shared by every OTEL layer.\n *\n * @category errors\n * @since 1.0.0-rc.0\n */\nexport class InvalidResourceConfiguration extends Schema.TaggedError<InvalidResourceConfiguration>()(\n \"@smthrs/observability/InvalidResourceConfiguration\",\n {\n code: Schema.Literal(\"invalid_resource_configuration\"),\n path: Schema.String,\n message: Schema.String\n }\n) {}\n\nconst invalid = (cause: unknown): InvalidResourceConfiguration => {\n const path = schemaIssuePath(cause, \"resource\")\n return new InvalidResourceConfiguration({\n code: \"invalid_resource_configuration\",\n path,\n message: `OpenTelemetry resource ${path} ${schemaIssueMessage(cause) ?? \"is invalid\"}`\n })\n}\n\n/**\n * Decodes one resource configuration without retaining rejected values.\n *\n * @category decoding\n * @since 1.0.0-rc.0\n */\nexport const decode = (\n configuration: unknown\n): Effect.Effect<Configuration, InvalidResourceConfiguration> =>\n Schema.decodeUnknownEffect(Configuration)(configuration).pipe(Effect.mapError(invalid))\n\n/**\n * Decodes one resource configuration for the package's pure projection API.\n *\n * @category decoding\n * @since 1.0.0-rc.0\n */\nexport const decodeSync = (configuration: unknown): Configuration => {\n try {\n return Schema.decodeUnknownSync(Configuration)(configuration)\n } catch (cause) {\n throw invalid(cause)\n }\n}\n\n/**\n * Projects a decoded resource into the exact optional-property shape expected\n * by the OpenTelemetry SDK.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const toOpenTelemetryConfiguration = (\n configuration: Configuration\n): {\n readonly serviceName: string\n readonly serviceVersion?: string\n readonly attributes?: OtelAttributes\n} => ({\n serviceName: configuration.serviceName,\n ...(configuration.serviceVersion === undefined ? {} : { serviceVersion: configuration.serviceVersion }),\n ...(configuration.attributes === undefined\n ? {}\n : {\n attributes: Object.fromEntries(\n Object.entries(configuration.attributes).map(([key, value]) => [\n key,\n Array.isArray(value) ? [...value] : value\n ])\n ) as OtelAttributes\n })\n})\n\n/**\n * Converts explicit service metadata into OpenTelemetry resource attributes.\n *\n * No environment variables are read. Invalid metadata throws the same typed\n * {@link InvalidResourceConfiguration} every layer returns during acquisition.\n *\n * @category conversions\n * @since 1.0.0-rc.0\n */\nexport const configToAttributes = (configuration: Configuration): OtelAttributes =>\n OtelResource.configToAttributes(toOpenTelemetryConfiguration(decodeSync(configuration)))\n\n/**\n * Provides an explicitly validated OpenTelemetry resource.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (\n configuration: Configuration\n): Layer.Layer<OtelResource.Resource, InvalidResourceConfiguration> =>\n Layer.unwrap(\n Effect.map(decode(configuration), (decoded) => OtelResource.layer(toOpenTelemetryConfiguration(decoded)))\n )\n\n/**\n * The OpenTelemetry resource service.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport const Resource = OtelResource.Resource\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability for flows: the default OTLP export wiring plus the
|
|
3
|
+
* Effect-native logger, metric, and OpenTelemetry resource layers.
|
|
4
|
+
*
|
|
5
|
+
* The store packages define and update their own metric handles
|
|
6
|
+
* (`JournalMetrics`, `RunStoreMetrics`, `CacheStoreMetrics`,
|
|
7
|
+
* `ArtifactStoreMetrics`, `DatabaseMetrics`) and open spans through Effect's
|
|
8
|
+
* tracer; this package is the exporter they deliberately leave out. `Otlp`
|
|
9
|
+
* only composes what `effect` already ships, so it is browser-bundleable. The
|
|
10
|
+
* remaining modules are the fuller stack folded in from the agent workspace:
|
|
11
|
+
* a structured `Logger`, a `JournalLogger` that mirrors log events into the
|
|
12
|
+
* run journal, `Metric` helpers, the `Resource` descriptor, and the `Otel`
|
|
13
|
+
* layer the OpenTelemetry SDK wiring installs behind.
|
|
14
|
+
*
|
|
15
|
+
* `NodeOtel` and `BrowserOtel` are deliberately NOT re-exported here. Each
|
|
16
|
+
* resolves a host-specific OpenTelemetry SDK. `NodeOtel` reaches Node-only
|
|
17
|
+
* host modules through `@effect/opentelemetry/NodeSdk` and
|
|
18
|
+
* `@opentelemetry/sdk-trace-node`, including the bare `async_hooks` specifier
|
|
19
|
+
* `@opentelemetry/context-async-hooks` imports, so re-exporting it would put a
|
|
20
|
+
* module a browser bundler cannot resolve in the root entry and break the
|
|
21
|
+
* browser bundle this package guarantees. Import them by subpath instead:
|
|
22
|
+
* `@smthrs/observability/NodeOtel`.
|
|
23
|
+
*
|
|
24
|
+
* @since 0.1.0
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @category layers
|
|
28
|
+
* @since 0.1.0
|
|
29
|
+
*/
|
|
30
|
+
export * as Otlp from "./Otlp.ts";
|
|
31
|
+
/**
|
|
32
|
+
* @category observability
|
|
33
|
+
* @since 1.0.0-rc.0
|
|
34
|
+
*/
|
|
35
|
+
export * as Endpoint from "./Endpoint.ts";
|
|
36
|
+
/**
|
|
37
|
+
* @category observability
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
*/
|
|
40
|
+
export * as JournalLogger from "./JournalLogger.ts";
|
|
41
|
+
/**
|
|
42
|
+
* @category observability
|
|
43
|
+
* @since 0.1.0
|
|
44
|
+
*/
|
|
45
|
+
export * as Logger from "./Logger.ts";
|
|
46
|
+
/**
|
|
47
|
+
* @category observability
|
|
48
|
+
* @since 0.1.0
|
|
49
|
+
*/
|
|
50
|
+
export * as Metric from "./Metric.ts";
|
|
51
|
+
/**
|
|
52
|
+
* @category observability
|
|
53
|
+
* @since 0.1.0
|
|
54
|
+
*/
|
|
55
|
+
export * as Otel from "./Otel.ts";
|
|
56
|
+
/**
|
|
57
|
+
* @category observability
|
|
58
|
+
* @since 0.1.0
|
|
59
|
+
*/
|
|
60
|
+
export * as Resource from "./Resource.ts";
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAErC;;;GAGG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
Endpoint: () => Endpoint,
|
|
32
|
+
JournalLogger: () => JournalLogger,
|
|
33
|
+
Logger: () => Logger,
|
|
34
|
+
Metric: () => Metric,
|
|
35
|
+
Otel: () => Otel,
|
|
36
|
+
Otlp: () => Otlp,
|
|
37
|
+
Resource: () => Resource
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
var Otlp = __toESM(require("./Otlp.js"), 1);
|
|
41
|
+
var Endpoint = __toESM(require("./Endpoint.js"), 1);
|
|
42
|
+
var JournalLogger = __toESM(require("./JournalLogger.js"), 1);
|
|
43
|
+
var Logger = __toESM(require("./Logger.js"), 1);
|
|
44
|
+
var Metric = __toESM(require("./Metric.js"), 1);
|
|
45
|
+
var Otel = __toESM(require("./Otel.js"), 1);
|
|
46
|
+
var Resource = __toESM(require("./Resource.js"), 1);
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Observability for flows: the default OTLP export wiring plus the\n * Effect-native logger, metric, and OpenTelemetry resource layers.\n *\n * The store packages define and update their own metric handles\n * (`JournalMetrics`, `RunStoreMetrics`, `CacheStoreMetrics`,\n * `ArtifactStoreMetrics`, `DatabaseMetrics`) and open spans through Effect's\n * tracer; this package is the exporter they deliberately leave out. `Otlp`\n * only composes what `effect` already ships, so it is browser-bundleable. The\n * remaining modules are the fuller stack folded in from the agent workspace:\n * a structured `Logger`, a `JournalLogger` that mirrors log events into the\n * run journal, `Metric` helpers, the `Resource` descriptor, and the `Otel`\n * layer the OpenTelemetry SDK wiring installs behind.\n *\n * `NodeOtel` and `BrowserOtel` are deliberately NOT re-exported here. Each\n * resolves a host-specific OpenTelemetry SDK. `NodeOtel` reaches Node-only\n * host modules through `@effect/opentelemetry/NodeSdk` and\n * `@opentelemetry/sdk-trace-node`, including the bare `async_hooks` specifier\n * `@opentelemetry/context-async-hooks` imports, so re-exporting it would put a\n * module a browser bundler cannot resolve in the root entry and break the\n * browser bundle this package guarantees. Import them by subpath instead:\n * `@smthrs/observability/NodeOtel`.\n *\n * @since 0.1.0\n */\n\n/**\n * @category layers\n * @since 0.1.0\n */\nexport * as Otlp from \"./Otlp.ts\"\n\n/**\n * @category observability\n * @since 1.0.0-rc.0\n */\nexport * as Endpoint from \"./Endpoint.ts\"\n\n/**\n * @category observability\n * @since 0.1.0\n */\nexport * as JournalLogger from \"./JournalLogger.ts\"\n\n/**\n * @category observability\n * @since 0.1.0\n */\nexport * as Logger from \"./Logger.ts\"\n\n/**\n * @category observability\n * @since 0.1.0\n */\nexport * as Metric from \"./Metric.ts\"\n\n/**\n * @category observability\n * @since 0.1.0\n */\nexport * as Otel from \"./Otel.ts\"\n\n/**\n * @category observability\n * @since 0.1.0\n */\nexport * as Resource from \"./Resource.ts\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8BA,WAAsB;AAMtB,eAA0B;AAM1B,oBAA+B;AAM/B,aAAwB;AAMxB,aAAwB;AAMxB,WAAsB;AAMtB,eAA0B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decoder-issue walk shared by this package's refusals.
|
|
3
|
+
*
|
|
4
|
+
* `JournalLogger` and `Resource` both publish the path of the option a decode
|
|
5
|
+
* rejected, and `Resource` also publishes the measured size a budget filter
|
|
6
|
+
* attached to its refusal. Effect's issues nest the same way for both, so the
|
|
7
|
+
* traversal lives once and a decoder change is followed once.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
* @since 1.0.0-rc.0
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Walks a decode failure to the dotted path of the value it refused.
|
|
14
|
+
*
|
|
15
|
+
* Returns the caller's domain name when the failure carries no path at all.
|
|
16
|
+
*
|
|
17
|
+
* @private
|
|
18
|
+
* @since 1.0.0-rc.0
|
|
19
|
+
*/
|
|
20
|
+
export declare const schemaIssuePath: (error: unknown, fallback: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Reads the message a filter attached to the value a decode refused, when the
|
|
23
|
+
* filter attached one. None of the Effect checks this package composes attach
|
|
24
|
+
* one, so a refusal only ever carries text this package wrote, never the
|
|
25
|
+
* rejected value.
|
|
26
|
+
*
|
|
27
|
+
* @private
|
|
28
|
+
* @since 1.0.0-rc.0
|
|
29
|
+
*/
|
|
30
|
+
export declare const schemaIssueMessage: (error: unknown) => string | undefined;
|
|
31
|
+
//# sourceMappingURL=schemaIssuePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaIssuePath.d.ts","sourceRoot":"","sources":["../../../src/internal/schemaIssuePath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA+BH;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,UAAU,MAAM,KAAG,MAAoD,CAAA;AAEvH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAI5D,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var schemaIssuePath_exports = {};
|
|
20
|
+
__export(schemaIssuePath_exports, {
|
|
21
|
+
schemaIssueMessage: () => schemaIssueMessage,
|
|
22
|
+
schemaIssuePath: () => schemaIssuePath
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(schemaIssuePath_exports);
|
|
25
|
+
const walk = (error) => {
|
|
26
|
+
let issue = error?.issue;
|
|
27
|
+
const segments = [];
|
|
28
|
+
for (let depth = 0; depth < 64 && typeof issue === "object" && issue !== null; depth++) {
|
|
29
|
+
const node = issue;
|
|
30
|
+
if (Array.isArray(node.path)) segments.push(...node.path.map(String));
|
|
31
|
+
if (node.issue !== void 0) {
|
|
32
|
+
issue = node.issue;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(node.issues) && node.issues[0] !== void 0) {
|
|
36
|
+
issue = node.issues[0];
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return { segments, leaf: issue };
|
|
42
|
+
};
|
|
43
|
+
const schemaIssuePath = (error, fallback) => walk(error).segments.join(".") || fallback;
|
|
44
|
+
const schemaIssueMessage = (error) => {
|
|
45
|
+
const leaf = walk(error).leaf;
|
|
46
|
+
const message = leaf?.annotations?.message;
|
|
47
|
+
return typeof message === "string" ? message : void 0;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=schemaIssuePath.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/internal/schemaIssuePath.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The decoder-issue walk shared by this package's refusals.\n *\n * `JournalLogger` and `Resource` both publish the path of the option a decode\n * rejected, and `Resource` also publishes the measured size a budget filter\n * attached to its refusal. Effect's issues nest the same way for both, so the\n * traversal lives once and a decoder change is followed once.\n *\n * @private\n * @since 1.0.0-rc.0\n */\n\ninterface IssueLeaf {\n readonly segments: ReadonlyArray<string>\n readonly leaf: unknown\n}\n\n/**\n * Walks a decode failure to its first offending leaf, collecting the path\n * segments passed on the way. The walk is bounded so a self-referential issue\n * tree cannot spin.\n */\nconst walk = (error: unknown): IssueLeaf => {\n let issue = (error as { readonly issue?: unknown } | null)?.issue\n const segments: Array<string> = []\n for (let depth = 0; depth < 64 && typeof issue === \"object\" && issue !== null; depth++) {\n const node = issue as { readonly path?: unknown; readonly issue?: unknown; readonly issues?: unknown }\n if (Array.isArray(node.path)) segments.push(...node.path.map(String))\n if (node.issue !== undefined) {\n issue = node.issue\n continue\n }\n if (Array.isArray(node.issues) && node.issues[0] !== undefined) {\n issue = node.issues[0]\n continue\n }\n break\n }\n return { segments, leaf: issue }\n}\n\n/**\n * Walks a decode failure to the dotted path of the value it refused.\n *\n * Returns the caller's domain name when the failure carries no path at all.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const schemaIssuePath = (error: unknown, fallback: string): string => walk(error).segments.join(\".\") || fallback\n\n/**\n * Reads the message a filter attached to the value a decode refused, when the\n * filter attached one. None of the Effect checks this package composes attach\n * one, so a refusal only ever carries text this package wrote, never the\n * rejected value.\n *\n * @private\n * @since 1.0.0-rc.0\n */\nexport const schemaIssueMessage = (error: unknown): string | undefined => {\n const leaf = walk(error).leaf as { readonly annotations?: { readonly message?: unknown } } | null | undefined\n const message = leaf?.annotations?.message\n return typeof message === \"string\" ? message : undefined\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,MAAM,OAAO,CAAC,UAA8B;AAC1C,MAAI,QAAS,OAA+C;AAC5D,QAAM,WAA0B,CAAC;AACjC,WAAS,QAAQ,GAAG,QAAQ,MAAM,OAAO,UAAU,YAAY,UAAU,MAAM,SAAS;AACtF,UAAM,OAAO;AACb,QAAI,MAAM,QAAQ,KAAK,IAAI,EAAG,UAAS,KAAK,GAAG,KAAK,KAAK,IAAI,MAAM,CAAC;AACpE,QAAI,KAAK,UAAU,QAAW;AAC5B,cAAQ,KAAK;AACb;AAAA,IACF;AACA,QAAI,MAAM,QAAQ,KAAK,MAAM,KAAK,KAAK,OAAO,CAAC,MAAM,QAAW;AAC9D,cAAQ,KAAK,OAAO,CAAC;AACrB;AAAA,IACF;AACA;AAAA,EACF;AACA,SAAO,EAAE,UAAU,MAAM,MAAM;AACjC;AAUO,MAAM,kBAAkB,CAAC,OAAgB,aAA6B,KAAK,KAAK,EAAE,SAAS,KAAK,GAAG,KAAK;AAWxG,MAAM,qBAAqB,CAAC,UAAuC;AACxE,QAAM,OAAO,KAAK,KAAK,EAAE;AACzB,QAAM,UAAU,MAAM,aAAa;AACnC,SAAO,OAAO,YAAY,WAAW,UAAU;AACjD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser OpenTelemetry setup with explicitly injected providers/readers.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.1.0
|
|
5
|
+
*/
|
|
6
|
+
import type { LogRecordProcessor } from "@opentelemetry/sdk-logs";
|
|
7
|
+
import type { MetricReader } from "@opentelemetry/sdk-metrics";
|
|
8
|
+
import type { SpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
10
|
+
import * as Resource from "./Resource.ts";
|
|
11
|
+
import type { Configuration as ResourceConfiguration } from "./Resource.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Browser OTEL layer options. Processors and readers are created by the
|
|
14
|
+
* caller's factories, which keeps this module free of Node imports and browser
|
|
15
|
+
* exporter policy. Every factory is owned: it runs once during layer
|
|
16
|
+
* acquisition, after resource validation, and the layer scope shuts down
|
|
17
|
+
* everything it returned. An empty array installs nothing for that signal.
|
|
18
|
+
*
|
|
19
|
+
* @category models
|
|
20
|
+
* @since 0.1.0
|
|
21
|
+
*/
|
|
22
|
+
export interface Options {
|
|
23
|
+
readonly resource: ResourceConfiguration;
|
|
24
|
+
readonly spanProcessor?: (() => SpanProcessor | ReadonlyArray<SpanProcessor>) | undefined;
|
|
25
|
+
readonly logRecordProcessor?: (() => LogRecordProcessor | ReadonlyArray<LogRecordProcessor>) | undefined;
|
|
26
|
+
readonly metricReader?: (() => MetricReader | ReadonlyArray<MetricReader>) | undefined;
|
|
27
|
+
readonly loggerMergeWithExisting?: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds a scoped browser OpenTelemetry layer. The web SDK owns every
|
|
31
|
+
* processor and reader the factories return and shuts them down on release.
|
|
32
|
+
*
|
|
33
|
+
* @category layers
|
|
34
|
+
* @since 0.1.0
|
|
35
|
+
*/
|
|
36
|
+
export declare const layerOtel: (options: Options) => Layer.Layer<never, Resource.InvalidResourceConfiguration>;
|
|
37
|
+
//# sourceMappingURL=BrowserOtel.d.ts.map
|