Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use diag error logging for uninitialized providers #43

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Logger } from 'winston';
import { GlobalProviders } from '@zonneplan/open-telemetry-node';
import { LogAttributes, SeverityNumber } from '@opentelemetry/api-logs';
import { LoggerService } from '../services/logger.service';
import { context } from '@opentelemetry/api';
import { context, diag } from '@opentelemetry/api';
import {
NEST_LOG_LEVEL_WINSTON_SEVERITY,
SEVERITY_NUMBER_TO_TEXT_MAP,
Expand Down Expand Up @@ -126,7 +126,7 @@ export class NestWinstonLoggerAdapter extends LoggerService {
}

if (!GlobalProviders.logProvider) {
console.error('OpenTelemetry log provider not initialized');
diag.error('OpenTelemetry log provider not initialized');
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MetricOptions, MetricTypeMap } from '../models/metric-options.model';
import { GlobalProviders } from '../../globals';
import { diag } from '@opentelemetry/api';

/**
* Gets a metric if exists, otherwise creates a new metric.
Expand All @@ -12,7 +13,7 @@ export const getOrCreateMetric = <
options: MetricOptions<TMetricType>
): TMetric | null => {
if (!GlobalProviders.metricProvider) {
console.error('OpenTelemetry metrics are not initialized');
diag.error('OpenTelemetry metrics are not initialized');
return null;
}

Expand Down
Loading