Add tracing to keyvault-keys library#4654
Conversation
| path: "keys/{key-name}/create", | ||
| urlParameters: [Parameters.vaultBaseUrl, Parameters.keyName0], | ||
| queryParameters: [Parameters.apiVersion], | ||
| headerParameters: [Parameters.acceptLanguage], |
There was a problem hiding this comment.
This file needs few more additions in getDeletedKeysOperationSpec, importKeyOperationSpec, etc. Else, the span will not be serialized to the service.
|
I have tested with my sample with and without tracers and code looks fine. But some of the header parameters are missing and I added the comment on it. We must add them before release |
sadasant
left a comment
There was a problem hiding this comment.
It looks good! Let's make sure we have a plan to have this updated in the auto-generated code. We also need this in secrets and in credentials, since they all share the same core.
|
Here's @schaabs 's reply to this PR:
I'll come back with feedback from @daviwil (or he might too). |
|
@sadasant For Preview 3, we will definitely look into having this auto-generated. |
|
@ramya-rao-a is correct, there isn't time to add this to the code generator for Preview 2 and all we really want is to validate the overall design anyway. I think hand-editing the code is fine in this case since we are in total control of when it gets regenerated in the future. We'll add some logic to |
| */ | ||
| private createSpan(methodName: string, requestOptions: RequestOptionsBase): Span { | ||
| const span = TracerProxy.getTracer().startSpan(methodName, requestOptions.spanOptions); | ||
| requestOptions.spanOptions = { ...requestOptions.spanOptions, parent: span }; |
There was a problem hiding this comment.
It'd be nice if we could do this without directly manipulating the original requestOptions object, but it's fine for now.
|
/azp run js - client - ci |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
|
/azp run js - keyvault - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run js - core - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
| delete unflattenedOptions.expires; | ||
| delete unflattenedOptions.requestOptions; | ||
|
|
||
| const span = this.createSpan("createEcKeyMethod", unflattenedOptions); |
There was a problem hiding this comment.
This might be a bit of a nit, but why do these all end with "*Method"? It's a hunch, but I'd think we'd want the exact same name so that they can do a search for the symbol and find it.
There was a problem hiding this comment.
+1, method suffix is unnecessary, should match the symbol.
| unflattenedOptions | ||
| ); | ||
|
|
||
| span.end(); |
There was a problem hiding this comment.
We also need to end the span if createKey throws an error, otherwise the span will never be closed.
Edit: This applies to all the places where we call start and stop around an awaited function.
|
Serializing the entire spanOptions in the header is not desirable. We instead want to pass only the TraceContext in the header. Therefore, updated this PR to revert changes related to headers in this PR with 139f4a3 We will look into creating a policy just for key vaults keys (since it already uses other custom policies) to do the needful in a separate PR |
This PR adds tracing to keyvault-keys library and is based on the work done by @sarangan12 in #4506
spanOptionsin the request options passed by the userspanOptionsin the request options so thatoptions.spanOptionsin the header