New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parse nonstring request-context header #521
parse nonstring request-context header #521
Conversation
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.
Consider refactoring.
AutoCollection/HttpDependencies.ts
Outdated
} else if (correlationHeader && typeof (correlationHeader as any).toString === "function") { | ||
// best effort attempt: requires well-defined toString | ||
try { | ||
header = (correlationHeader as any).toString(); |
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.
Do you know if there's any functional or performance differences between header.toString()
and '' + header
or String(header)
?
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.
https://stackoverflow.com/questions/3945202/whats-the-difference-between-stringvalue-vs-value-tostring
It seems '' + header
and String(header)
are equivalent, and they attempt to call toString
(and valueOf
if that failed). For perf, it seems toString is slightly better, but using either of the other two would cover the scenario of valueOf
being properly defined instead of toString
for a custom object.
* add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * livemetrics: add lastSendSucceeded to prevent permanent retries (#504) * add lastSendSucceeded to prevent permanent retries * add qps time constants, remove static class state * fix request averages being NaN * bump to 1.3.1 (#505) * update diagnostic-channel-publishers to 0.3.1 (#509) * update diagnostic-channel-publishers to 0.3.1 * updates for node12 compat * run functionals on node12 * only log extended duration QPS errors (#511) * only log extended duration QPS errors * refactor QPS error logging * cleanup QPS error logging * readme: document live metrics host config option * Fix typos in readme.md (#517) * parse nonstring request-context header (#521) * parse nonstring request-context header * refactor header parsing, add try/catch on fallback * move includeCorrelationHeader to Util * add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs * ship mapfiles (#526) * ship mapfiles * tsconfig: inline TS in sourcemaps * qps: never change ping state on errors (#525) * qps: only pinging state for consecutive errors * qps: do not change state on errors * add w3c distributed tracing (#519) * add w3c distributed tracing * TraceParent/TraceState to Traceparent/Tracestate * traceparent lint errors * Rename rest of Tracestate/Traceparent * temp del * re-add Traceparent/Tracestate * tests: remove ambiguous url * refactor traceparent parsing in HttpRequestParser * add if guard on unneeded request parsing * trim traceparent header only once * disable qps only on consec errors * revert qps change * resolve merge conflicts * use enum for w3c enablement * remove dead code * move isValidW3CId to Util * create traceparent if tracestate exists * tests: add util import to httprequestparser * bump to 1.4.0 (#527) * docs: add w3c to readme (#528) * docs: add w3c to readme * docs: add default tracing mode * release 1.3.0 (#502) (#530) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README
* Release 1.4.0 (#531) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * livemetrics: add lastSendSucceeded to prevent permanent retries (#504) * add lastSendSucceeded to prevent permanent retries * add qps time constants, remove static class state * fix request averages being NaN * bump to 1.3.1 (#505) * update diagnostic-channel-publishers to 0.3.1 (#509) * update diagnostic-channel-publishers to 0.3.1 * updates for node12 compat * run functionals on node12 * only log extended duration QPS errors (#511) * only log extended duration QPS errors * refactor QPS error logging * cleanup QPS error logging * readme: document live metrics host config option * Fix typos in readme.md (#517) * parse nonstring request-context header (#521) * parse nonstring request-context header * refactor header parsing, add try/catch on fallback * move includeCorrelationHeader to Util * add node.js native metrics (#508) * release 1.3.0 (#502) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * add native metrics subscriber * mark native members of NativePerformance as static * remove segfault lib * update package.json * native: add throw tests * add refs to metrics * add config for enabling metrics, add heap metrics * report stdDev stats * rename custom metric names * fix native perf test * only run tests for node4+ * use node-pre-gyp native metrics * optionaldevdep for travis tests * simulate optionalDevDependency in travis * remove duped travis npm install * gate native metrics to node6+ * refactor extended metrics enablement * move extended metrics arg parsing to API * add info logging for when native module is loaded * docs: add extended metrics * add extended metrics build stage * use env var for travis extended metrics tests * test: modify test for non-installed case * tweak travis.yml * readme: comment out docs * ship mapfiles (#526) * ship mapfiles * tsconfig: inline TS in sourcemaps * qps: never change ping state on errors (#525) * qps: only pinging state for consecutive errors * qps: do not change state on errors * add w3c distributed tracing (#519) * add w3c distributed tracing * TraceParent/TraceState to Traceparent/Tracestate * traceparent lint errors * Rename rest of Tracestate/Traceparent * temp del * re-add Traceparent/Tracestate * tests: remove ambiguous url * refactor traceparent parsing in HttpRequestParser * add if guard on unneeded request parsing * trim traceparent header only once * disable qps only on consec errors * revert qps change * resolve merge conflicts * use enum for w3c enablement * remove dead code * move isValidW3CId to Util * create traceparent if tracestate exists * tests: add util import to httprequestparser * bump to 1.4.0 (#527) * docs: add w3c to readme (#528) * docs: add w3c to readme * docs: add default tracing mode * release 1.3.0 (#502) (#530) * add live metrics (#494) * add QPS files; enablement not included * add tests; add qps ping retry walkback * add off by default config option for QPS * add qps test to ensure off by default * only construct qps when enabled * add qps Sender constants * add QuickPulseEnvelopeFactory * fix ts timer compile * add qps exception and trace error handling * refactor default live metrics test * make qps hostname configurable * fix node0 setTimeout error * add qps telemetrytype constants * move away from export enums for ts backcompat * add qps EventDocument,fix dependency duration * use envelope type in qps telemetryprocessor * send avg execution duration instead of last dur * add error logging for qps endpoint * add telemetry types, move qps config to qpssender * fix keying type issue in TelemetryType * fix wrong telemetrytype in qps conversion (#500) * bump version to 1.3.0 (#501) * bump version to 1.3.0 * add setSendLiveMetrics to README * Http.createServer is missing the options variable * Add overload for non-options createserver * Temporary commit, should be ready? * Reverting unnecessary changes. updating overload logic * Reverting extra space Co-authored-by: Mark Wolff <Mark.Wolff@microsoft.com> Co-authored-by: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com> Co-authored-by: Xiao Li <lixiao900921@gmail.com> Co-authored-by: Hector Hernandez Guzman <hectorh@microsoft.com>
Fixes #512
getHeader
returns a type ofany
instead ofstring
. Only occurrence of this in the SDK is withrequest-context
parsing. This PR attempts to parserequest-context
header for<string | string[] | number>
, else it fallsback totoString
. Current node typings dev dependency of this SDK has the type as returning a string, so it may be useful to upgrade to a more recent typings version for SDK development.