MCPcopy Create free account
hub / github.com/codeaashu/claude-code / getOtlpLogExporters

Function getOtlpLogExporters

src/utils/telemetry/instrumentation.ts:217–271  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215}
216
217async function getOtlpLogExporters() {
218 const exporterTypes = parseExporterTypes(process.env.OTEL_LOGS_EXPORTER)
219
220 const protocol =
221 process.env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL?.trim() ||
222 process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim()
223 const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT
224
225 logForDebugging(
226 `[3P telemetry] getOtlpLogExporters: types=${jsonStringify(exporterTypes)}, protocol=${protocol}, endpoint=${endpoint}`,
227 )
228
229 const exporters = []
230 for (const exporterType of exporterTypes) {
231 if (exporterType === 'console') {
232 exporters.push(new ConsoleLogRecordExporter())
233 } else if (exporterType === 'otlp') {
234 const httpConfig = getOTLPExporterConfig()
235
236 switch (protocol) {
237 case 'grpc': {
238 const { OTLPLogExporter } = await import(
239 '@opentelemetry/exporter-logs-otlp-grpc'
240 )
241 exporters.push(new OTLPLogExporter())
242 break
243 }
244 case 'http/json': {
245 const { OTLPLogExporter } = await import(
246 '@opentelemetry/exporter-logs-otlp-http'
247 )
248 exporters.push(new OTLPLogExporter(httpConfig))
249 break
250 }
251 case 'http/protobuf': {
252 const { OTLPLogExporter } = await import(
253 '@opentelemetry/exporter-logs-otlp-proto'
254 )
255 exporters.push(new OTLPLogExporter(httpConfig))
256 break
257 }
258 default:
259 throw new Error(
260 `Unknown protocol set in OTEL_EXPORTER_OTLP_LOGS_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL env var: ${protocol}`,
261 )
262 }
263 } else {
264 throw new Error(
265 `Unknown exporter type set in OTEL_LOGS_EXPORTER env var: ${exporterType}`,
266 )
267 }
268 }
269
270 return exporters
271}
272
273async function getOtlpTraceExporters() {
274 const exporterTypes = parseExporterTypes(process.env.OTEL_TRACES_EXPORTER)

Callers 1

initializeTelemetryFunction · 0.85

Calls 5

parseExporterTypesFunction · 0.85
logForDebuggingFunction · 0.85
jsonStringifyFunction · 0.85
getOTLPExporterConfigFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected