Skip to content

Commit

Permalink
feat: use global error handler in zipkin exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
mwear committed Sep 16, 2020
1 parent 80940d7 commit e2e66f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as api from '@opentelemetry/api';
import { ExportResult } from '@opentelemetry/core';
import { ExportResult, globalErrorHandler } from '@opentelemetry/core';
import * as zipkinTypes from '../../types';
import { OT_REQUEST_HEADER } from '../../utils';

Expand Down Expand Up @@ -75,7 +75,7 @@ function sendWithBeacon(
logger.debug('sendBeacon - can send', data);
done(ExportResult.SUCCESS);
} else {
logger.error('sendBeacon - cannot send', data);
globalErrorHandler(new Error(`sendBeacon - cannot send ${data}`));
done(ExportResult.FAILED_NOT_RETRYABLE);
}
}
Expand Down Expand Up @@ -120,8 +120,8 @@ function sendWithXhr(
}
};

xhr.onerror = err => {
logger.error('Zipkin request error', err);
xhr.onerror = msg => {
globalErrorHandler(new Error(`Zipkin request error: ${msg}`));
return done(ExportResult.FAILED_RETRYABLE);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as api from '@opentelemetry/api';
import { ExportResult } from '@opentelemetry/core';
import { ExportResult, globalErrorHandler } from '@opentelemetry/core';
import * as http from 'http';
import * as https from 'https';
import * as url from 'url';
Expand Down Expand Up @@ -84,7 +84,7 @@ export function prepareSend(
});

req.on('error', (err: Error) => {
logger.error('Zipkin request error', err);
globalErrorHandler(err);
return done(ExportResult.FAILED_RETRYABLE);
});

Expand Down

0 comments on commit e2e66f6

Please sign in to comment.