Skip to content

Commit

Permalink
fix(exporter-zipkin): remove deprecated url.parse usage (#5390)
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode authored Jan 29, 2025
1 parent 2759d73 commit 22569ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se

### :bug: (Bug Fix)

* fix(exporter-zipkin): remove usages of deprecated `url.parse` from `node:url` [#5390](https://github.com/open-telemetry/opentelemetry-js/pull/5390) @chancancode
* 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

### :books: (Refine Doc)
Expand Down
22 changes: 9 additions & 13 deletions packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { diag } from '@opentelemetry/api';
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
import * as http from 'http';
import * as https from 'https';
import * as url from 'url';
import * as zipkinTypes from '../../types';

/**
Expand All @@ -31,18 +30,15 @@ export function prepareSend(
urlStr: string,
headers?: Record<string, string>
): zipkinTypes.SendFn {
const urlOpts = url.parse(urlStr);
const url = new URL(urlStr);

const reqOpts: http.RequestOptions = Object.assign(
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
...headers,
},
const reqOpts: http.RequestOptions = Object.assign({
method: 'POST',
headers: {
'Content-Type': 'application/json',
...headers,
},
urlOpts
);
});

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

const { request } = reqOpts.protocol === 'http:' ? http : https;
const req = request(reqOpts, (res: http.IncomingMessage) => {
const { request } = url.protocol === 'http:' ? http : https;
const req = request(url, reqOpts, (res: http.IncomingMessage) => {
let rawData = '';
res.on('data', chunk => {
rawData += chunk;
Expand Down

0 comments on commit 22569ac

Please sign in to comment.