File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,30 @@ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
77
88// Only set up logs if OTEL is configured
99if ( process . env . OTEL_EXPORTER_OTLP_ENDPOINT ) {
10+ console . log ( "🔍 OTEL Debug - Endpoint:" , process . env . OTEL_EXPORTER_OTLP_ENDPOINT ) ;
11+ console . log ( "🔍 OTEL Debug - Headers set:" , ! ! process . env . OTEL_EXPORTER_OTLP_HEADERS ) ;
12+ console . log ( "🔍 OTEL Debug - Service name:" , process . env . OTEL_SERVICE_NAME ) ;
13+
1014 const resource = resourceFromAttributes ( {
1115 [ ATTR_SERVICE_NAME ] : process . env . OTEL_SERVICE_NAME || "typelets-api" ,
1216 } ) ;
1317
1418 const logExporter = new OTLPLogExporter ( ) ;
19+
20+ // Add error handling to the exporter
21+ const originalExport = logExporter . export . bind ( logExporter ) ;
22+ logExporter . export = ( logs , resultCallback ) => {
23+ console . log ( `📤 Attempting to export ${ logs . length } log records to OTLP...` ) ;
24+ originalExport ( logs , ( result ) => {
25+ if ( result . code === 0 ) {
26+ console . log ( `✅ Successfully exported ${ logs . length } logs to Grafana` ) ;
27+ } else {
28+ console . error ( `❌ Failed to export logs:` , result . error ) ;
29+ }
30+ resultCallback ( result ) ;
31+ } ) ;
32+ } ;
33+
1534 const logRecordProcessor = new BatchLogRecordProcessor ( logExporter ) ;
1635
1736 const loggerProvider = new LoggerProvider ( {
You can’t perform that action at this time.
0 commit comments