Skip to content

Commit 22569ac

Browse files
authored
fix(exporter-zipkin): remove deprecated url.parse usage (#5390)
1 parent 2759d73 commit 22569ac

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
6161

6262
### :bug: (Bug Fix)
6363

64+
* fix(exporter-zipkin): remove usages of deprecated `url.parse` from `node:url` [#5390](https://github.com/open-telemetry/opentelemetry-js/pull/5390) @chancancode
6465
* fix(sdk-metrics): do not export from `PeriodicExportingMetricReader` when there are no metrics to export. [#5288](https://github.com/open-telemetry/opentelemetry-js/pull/5288) @jacksonweber
6566

6667
### :books: (Refine Doc)

packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { diag } from '@opentelemetry/api';
1818
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
1919
import * as http from 'http';
2020
import * as https from 'https';
21-
import * as url from 'url';
2221
import * as zipkinTypes from '../../types';
2322

2423
/**
@@ -31,18 +30,15 @@ export function prepareSend(
3130
urlStr: string,
3231
headers?: Record<string, string>
3332
): zipkinTypes.SendFn {
34-
const urlOpts = url.parse(urlStr);
33+
const url = new URL(urlStr);
3534

36-
const reqOpts: http.RequestOptions = Object.assign(
37-
{
38-
method: 'POST',
39-
headers: {
40-
'Content-Type': 'application/json',
41-
...headers,
42-
},
35+
const reqOpts: http.RequestOptions = Object.assign({
36+
method: 'POST',
37+
headers: {
38+
'Content-Type': 'application/json',
39+
...headers,
4340
},
44-
urlOpts
45-
);
41+
});
4642

4743
/**
4844
* Send spans to the remote Zipkin service.
@@ -56,8 +52,8 @@ export function prepareSend(
5652
return done({ code: ExportResultCode.SUCCESS });
5753
}
5854

59-
const { request } = reqOpts.protocol === 'http:' ? http : https;
60-
const req = request(reqOpts, (res: http.IncomingMessage) => {
55+
const { request } = url.protocol === 'http:' ? http : https;
56+
const req = request(url, reqOpts, (res: http.IncomingMessage) => {
6157
let rawData = '';
6258
res.on('data', chunk => {
6359
rawData += chunk;

0 commit comments

Comments
 (0)