Refactor config loading (in progress 3)

This commit is contained in:
2025-07-15 00:15:56 -05:00
parent 0a045762bc
commit 4b2d63335a
19 changed files with 380 additions and 360 deletions

View File

@@ -1,14 +1,12 @@
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { Logger } from '../utils/logger.util.js';
import { formatErrorForMcpTool } from '../utils/error.util.js';
import { OpenTelemetryService } from '../services/opentelemetry-llm.service.js';
import { OpenTelemetryController } from '../controllers/opentelemetry-llm.controller.js';
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
import {
OpenTelemetryLlmInputSchema,
OpenTelemetryLlmInputSchemaType,
} from '../types/opentelemetry-llm.types.js';
import { OpenTelemetryConfig } from '../config/opentelemetry-llm.config.js';
/**
* @function captureOpenTelemetryLlmObservability
@@ -31,19 +29,8 @@ async function captureOpenTelemetryLlmObservability(
// Parse and validate arguments
const validatedArgs = OpenTelemetryLlmInputSchema.parse(args);
// Ensure OpenTelemetry is configured
const configLoader = new OpenTelemetryConfig();
const config = configLoader.fromEnv();
const service = OpenTelemetryService.getInstance(config);
// Initialize if not already done
service.initialize();
// Create controller with the service
const controller = new OpenTelemetryController(service);
// Pass validated args to the controller
const result = await controller.captureLlmObservability(validatedArgs);
const result = await OpenTelemetryController.capture(validatedArgs);
methodLogger.debug('Got response from controller', result);
// Format the response for the MCP tool