Stackdriver Exporter does not seem to export the field as expected by stackdriver
loneparadox opened this issue · 4 comments
Stack driver exporter does not seems to pass on the openCensus attributes and does not seem to convert them to the stack driver attributes.
What version of OpenCensus are you using?
"@opencensus/exporter-stackdriver": "0.0.17",
"@opencensus/nodejs": "0.0.17",
What version of Node are you using?
v10.16.1
What did you do?
Followed the instructions from https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-exporter-stackdriver/README.md#usage
The trace data gets sent to stack driver however it seems in stack driver trace the methods and responses are not picked up by stack driver.
i.e. on the stack driver screen you cannot filter on HTTP method
, etc...
What did you expect to see?
I would expect the attributes to be populated so it works with stack driver.
From what I could see it seems the stack driver exporter is not converting the openCensus attributes.
From https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/HTTP.md#attributes
I would expect "http.host"
to be converted to "/http/host"
and so forth.
Additional context
I suspect this is the same as #163
That tickets has a link in which no longer exists and I think https://github.com/census-instrumentation/opencensus-python/blob/master/contrib/opencensus-ext-stackdriver/opencensus/ext/stackdriver/trace_exporter/__init__.py#L292
might be what is the current code on the python side.
Thanks for reporting this! I will take a look at this shortly.
@mayurkale22 thank you.
To test this theory I made some changes in stackdriver-cloudtrace-utils.js
file.
Excuse my crappy code, and I am not suggesting that the change should occur here; But like I said I just wanted to see if this will make it display correctly in stack driver.
function createAttributesBuilder(attributes, droppedAttributesCount) {
const attributeMap = {};
const keyswitch = {
"http.host": "/http/host",
"http.method": "/http/method",
"http.path": "/http/path",
"http.route": "/http/route",
"http.user_agent": "/http/user_agent",
"http.status_code": "/http/status_code",
"http.url": "/http/url"
};
for (const key of Object.keys(attributes)) {
if (keyswitch.hasOwnProperty(key)) {
attributeMap[keyswitch[key]] = createAttributeValue(attributes[key]);
}
attributeMap[key] = createAttributeValue(attributes[key]);
}
return { attributeMap, droppedAttributesCount };
}
And that did in fact work, to display it correctly in stack driver.
Not sure if this helps in any way.
@loneparadox Thanks for the pointers, I managed to repro-d the issue and open a PR to fix the reported problem. This will be available in 0.0.18
release.
Published in 0.0.18
, let us know if you encounter any issues!