microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Custom proxy with error "Expecting a valid host string in proxy settings, but found"

hintdesk opened this issue · comments

Description/Screenshot
In my company we have set a corporate proxy. To connect to Internet the application has to use this proxy.
The proxy has the format of "proxy.companyname.i:port".
I have set that proxy over env variable http_proxy und https_proxy. Currently I receive this error

Configuring Azure AppInsights
Failed to start default client: [object Error]{ stack: 'Error: Expecting a valid host string in proxy settings, but found "proxy.companyname.i".
2024-05-15T13:03:52.037201912Z at getUrlFromProxySettings (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/proxyPolicy.js:129:15)
at proxyPolicy (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/policies/proxyPolicy.js:177:11)
2024-05-15T13:03:52.037210399Z at createPipelineFromOptions (/app/node_modules/@azure/core-rest-pipeline/dist/commonjs/createPipelineFromOptions.js:30:61)
at createClientPipeline (/app/node_modules/@azure/core-client/dist/commonjs/pipeline.js:16:73)
at createDefaultPipeline (/app/node_modules/@azure/core-client/dist/commonjs/serviceClient.js:157:51)
at new ServiceClient (/app/node_modules/@azure/core-client/dist/commonjs/serviceClient.js:53:45)
at new ApplicationInsightsClient (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:1824:9)
2024-05-15T13:03:52.037227236Z at new HttpSender (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:2782:34)
at new AzureMonitorMetricExporter (/app/node_modules/@azure/monitor-opentelemetry-exporter/dist/index.js:3591:24)
at new MetricHandler (/app/node_modules/@azure/monitor-opentelemetry/dist/index.js:3220:31)', message: 'Expecting a valid host string in proxy settings, but found "proxy.companyname.i".', name: 'Error' []
AppInsights ProxyHttpUrl: http://proxy.companyname.i:port
AppInsights new ProxyHttpUrl: http://proxy.companyname.i:port
`

Steps to Reproduce

  • SDK Version [e.g. 22]: 3.0.0
  • How you initialized the SDK:

if (process.env.APPLICATIONINSIGHTS_CONNECTION_STRING) {
console.log('Configuring Azure AppInsights');
appInsights
.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING)
.setAutoDependencyCorrelation(false)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(false, false)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(false)
.setAutoCollectConsole(false)
.start();
}

Expected behavior
What should I have to do to tell ApplicationInsights SDK that "proxy.companayname.i:port" is a valid host?

are you using ApplicationInsights JS SDK or ApplicationInsights Node.js, for Node.js, please refer this repo https://github.com/microsoft/ApplicationInsights-node.js

Closing as a duplicate of #1329