EdgeAIG/opencode / .opencode /node_modules /effect /src /unstable /observability /OtlpSerialization.ts
| /** | |
| * Serializes OTLP payloads into HTTP request bodies. | |
| * | |
| * Signal exporters build trace, metric, and log data structures in memory. This | |
| * module provides the service that turns those structures into JSON or protobuf | |
| * HTTP bodies before they are posted to an OTLP collector. | |
| * | |
| * @since 4.0.0 | |
| */ | |
| import * as Context from "../../Context.ts" | |
| import * as Layer from "../../Layer.ts" | |
| import * as HttpBody from "../http/HttpBody.ts" | |
| import * as otlpProtobuf from "./internal/otlpProtobuf.ts" | |
| import type { LogsData } from "./OtlpLogger.ts" | |
| import type { MetricsData } from "./OtlpMetrics.ts" | |
| import type { TraceData } from "./OtlpTracer.ts" | |
| /** | |
| * Service for serializing OTLP traces, metrics, and logs into HTTP request | |
| * bodies. | |
| * | |
| * @category services | |
| * @since 4.0.0 | |
| */ | |
| export class OtlpSerialization extends Context.Service<OtlpSerialization, { | |
| readonly traces: (data: TraceData) => HttpBody.HttpBody | |
| readonly metrics: (data: MetricsData) => HttpBody.HttpBody | |
| readonly logs: (data: LogsData) => HttpBody.HttpBody | |
| }>()("effect/observability/OtlpSerialization") {} | |
| /** | |
| * Provides `OtlpSerialization` using OTLP/HTTP JSON bodies. | |
| * | |
| * @category layers | |
| * @since 4.0.0 | |
| */ | |
| export const layerJson = Layer.succeed(OtlpSerialization, { | |
| traces: (spans) => HttpBody.jsonUnsafe(spans), | |
| metrics: (metrics) => HttpBody.jsonUnsafe(metrics), | |
| logs: (logs) => HttpBody.jsonUnsafe(logs) | |
| }) | |
| /** | |
| * Provides `OtlpSerialization` using protobuf-encoded OTLP bodies with the | |
| * `application/x-protobuf` content type. | |
| * | |
| * @category layers | |
| * @since 4.0.0 | |
| */ | |
| export const layerProtobuf = Layer.succeed(OtlpSerialization, { | |
| traces: (spans) => | |
| HttpBody.uint8Array( | |
| otlpProtobuf.encodeTracesData(spans as any), | |
| "application/x-protobuf" | |
| ), | |
| metrics: (metrics) => | |
| HttpBody.uint8Array( | |
| otlpProtobuf.encodeMetricsData(metrics as any), | |
| "application/x-protobuf" | |
| ), | |
| logs: (logs) => | |
| HttpBody.uint8Array( | |
| otlpProtobuf.encodeLogsData(logs as any), | |
| "application/x-protobuf" | |
| ) | |
| }) | |
Xet Storage Details
- Size:
- 2.04 kB
- Xet hash:
- 84b58750dc33f985779f0c967ddcf52af8684f1aacb9d834a5912e51a8a11dfb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.