-
Notifications
You must be signed in to change notification settings - Fork 916
Closed as duplicate of#5711
Labels
Description
What happened?
Steps to Reproduce
We are upgraded @opentelemetry/exporter-logs-otlp-proto
from 0.50.0 to latest 0.203.0 and the problems begun
I'm behind a corporate proxy.
setting up an OTLPLogExporter
const collector = {
//collector configuration
url: `https://${process.env.OTLP_EXPORTER_ENV}.live.dynatrace.com/api/v2/otlp/v1/logs`,
headers: {
Authorization: `Api-Token ${process.env.OTLP_EXPORTER_TOKEN}`,
},
keepAlive: true,
httpAgentOptions: new HttpsProxyAgent(this._proxyAddress),
};
// create exporter and set proxy
const otelExporter: OTLPLogExporter = new OTLPLogExporter(collector);
to reproduce same error:
import * as https from 'https';
import { HttpsProxyAgent } from 'https-proxy-agent';
function testHttpProxy() {
const agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
// Data to send
const postData = JSON.stringify({
name: 'OTEL',
job: 'Developer',
});
const nodeAgent = new https.Agent(agent); // Create an HTTPS agent with the proxy settings
// Request options
const options: https.RequestOptions = {
hostname: `${process.env.OTLP_EXPORTER_ENV}.live.dynatrace.com`, // Replace with your target host
port: 443,
path: '/api/v2/otlp/v1/logs', // Replace with your target path
method: 'POST',
headers: {
'Content-Type': 'application/x-protobuf',
'User-Agent': `OTel-OTLP-Exporter-test`,
'Content-Length': Buffer.byteLength(postData),
Authorization: `Api-Token ${process.env.OTLP_EXPORTER_TOKEN}`,
},
agent: nodeAgent, //use Agent
//agent: agent // use HttpsProxyAgent
};
// Create and send the request
const req = https.request(options, (res) => {
console.log(`Status Code: ${res.statusCode}`);
res.on('data', (chunk) => {
console.log(`Response: ${chunk}`);
});
});
req.on('error', (e) => {
console.error(`Request error: ${e.message}`);
});
req.write(postData);
req.end();
}
just change the agent settings in options
object
//agent: nodeAgent, //use Agent
agent: agent // use HttpsProxyAgent
and transport back to work with error from collector that message is malformed (400)
Expected Result
data collected/received in Dynatrace
Actual Result
connection error:
"Error: connect ETIMEDOUT x.x.x.:443,Error: connect ETIMEDOUT","code":"ETIMEDOUT","name":"AggregateError"}
after 5 retries
Additional Details
The problem is in @opentelemetry\otlp-exporter-base\build\src\transport\http-transport-utils.js
method createHttpAgent
function createHttpAgent(rawUrl, agentOptions) {
const parsedUrl = new URL(rawUrl);
const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;
return new Agent(agentOptions);
}
event if agentOptions
set to use a proxy,
the line ``` js
return new Agent(agentOptions)
override all proxy settings
### OpenTelemetry Setup Code
```JavaScript
package.json
Relevant log output
Operating System and Version
Windows 11
Runtime and Version
NodeJS v22.13.0