-
Notifications
You must be signed in to change notification settings - Fork 96
Add support for custom attributes #492
Add support for custom attributes #492
Conversation
This is a snippet of the code I used to validate/test out manually function customAttributeFunction(span, request, response) {
console.log('called');
console.log(span.kind);
if (span.kind === 1) {
span.addAttribute('custom attribute1', 'value1');
} else {
span.addAttribute('custom attribute2', 'value2');
}
}
const exporter = new JaegerTraceExporter(jaegerOptions);
const jaeger = new propagation.JaegerFormat();
const tracer = tracing.registerExporter(exporter).start({
propagation: jaeger,
plugins: {
'http': {
module: '@opencensus/instrumentation-http',
config: {
applyCustomAttributesOnSpan: customAttributeFunction
}
},
'https': {
module: '@opencensus/instrumentation-https',
config: {
applyCustomAttributesOnSpan: customAttributeFunction
}
}
}
}); |
See there are also existing test failures. I had compiled the modules locally with npm run compile but not at the top level. |
Believe I have resolved the failures which are applicable. Failures on node6 seem unrelated to the changes in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I like the general structure of this. IMO, if we had tests it would LGTM.
Overall LGTM, please add unit tests and update the CHANGLOG.md |
@mayurkale22 thanks for reviewing! Just back from holiday today. will try to add the unit tests late this week or early next. |
Added unit tests. Next need to rebase and then update CHANGLOG.md as well. Hope to get to that tomorrow. |
Seems I have some fixup. Seems like npm test does not run all that npm run compile does even though it seems to run the linter and be able to run the tests... |
@mayurkale22 I might need a suggestion on this one:
I'd added the ...rest:any[] because the http plugin custom attribute function has additional parameters. I'm new to TypeScript so now quite sure how to work around this differently. |
7fc2fed
to
b744c8f
Compare
@mayurkale22 I found that any is allowed through a comment for some other similar cases, did that for now. Just pushed an update that rebases and adds the changes to the CHANGELOG.md. Locally |
Codecov Report
@@ Coverage Diff @@
## master #492 +/- ##
==========================================
- Coverage 95.15% 94.79% -0.36%
==========================================
Files 147 150 +3
Lines 9861 10054 +193
Branches 541 744 +203
==========================================
+ Hits 9383 9531 +148
- Misses 478 523 +45
Continue to review full report at Codecov.
|
b744c8f
to
01448dc
Compare
@mayurkale22 I think this should be ready to go now. Just let me know if you have things you'd like me to change or update. |
@mhdawson Thanks for fixing the build, will review it today. |
Is it a good time to remove "WIP" from the title? |
Add support for custom attributes for http and https spans Fixes: census-instrumentation#490
01448dc
to
9c05fba
Compare
@mayurkale22 thanks forgot about that. Pushed update that removes WIP. |
You may want to see this #514, looks like we can achieve same using |
@mayurkale22 unless I'm missing something that just lets you add a set of default key/value pairs. The requirement we had was to to be able to pull additional attributes from the request/response or otherwise as opposed to a fixed set? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok got you. Thanks for the explanation. LGTM.
If no other comments from @draffensperger, I will merge it later today and will be avaiable in next release (0.0.13). |
Add support for custom attributes for http and https spans
Fixes: #490
I've marked as Work in progress WIP as I've not looked at the updates needed to add any required documentation and to add tests.
I'm away until May 8th so I won't get back to the docs and tests until then but I wanted to get this out so that people could review provide additional feedback.
I think it is in line with the recommendations in #490 and it seems to work based on my test app.