Skip to content
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

Emit spans for sdk #156

Merged
merged 9 commits into from
Oct 22, 2018
Merged

Emit spans for sdk #156

merged 9 commits into from
Oct 22, 2018

Conversation

vladbarosan
Copy link

Fixes Azure/azure-sdk-for-go#2902

  • add traces to all sdk calls.
  • add new Advancer methods NextWithContext() for iterator and page types.

@ghost ghost assigned vladbarosan Oct 17, 2018
@ghost ghost added the review label Oct 17, 2018
@vladbarosan
Copy link
Author

blocked on Azure/go-autorest#335. Ready to go after that is merged.

@@ -31,6 +32,11 @@ func NewPetsClientWithBaseURI(baseURI string) PetsClient {

// CreateAPInProperties create a Pet which contains more properties than what is defined.
func (client PetsClient) CreateAPInProperties(ctx context.Context, createParameters PetAPInProperties) (result PetAPInProperties, err error) {
ctx = tracing.StartSpan(ctx, "generated/additional-properties/PetsClient.CreateAPInProperties")
defer func() {
sc := result.StatusCode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a nil check here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes discovered this while testing, will add a nill check and use resp instead of result

@vladbarosan
Copy link
Author

vladbarosan commented Oct 19, 2018

@jhendrixMSFT regenerated the whole SDK, everything look good, no files missing or extra and only change is what is expected. And now we have nil checks everywhere so no chance of nil issues in case of no response

@@ -31,6 +32,14 @@ func NewPetsClientWithBaseURI(baseURI string) PetsClient {

// CreateAPInProperties create a Pet which contains more properties than what is defined.
func (client PetsClient) CreateAPInProperties(ctx context.Context, createParameters PetAPInProperties) (result PetAPInProperties, err error) {
ctx = tracing.StartSpan(ctx, "generated/additional-properties/PetsClient.CreateAPInProperties")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the generated string look like for the SDK?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its going to be the fully qualified name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw not the most happy on how we determine that. pretty much we take the outputpath and do an index on it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see so something like services/compute/mgmt/2016-03-30/compute/VirtualMachinesClient.CreateOrUpdate then?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, here is a sample, https://gist.github.com/vladbarosan/3ab6cd696e9b7413194ab78ed75225c3 . Was wondering actually, I could prefix with github.com/Azure/Azure-sdk-for-go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. It might be best to emit the package import path as an unexported const then concatenate that with the fully qualified method name.

@@ -91,6 +100,14 @@ func (client PetsClient) CreateAPInPropertiesResponder(resp *http.Response) (res

// CreateAPInPropertiesWithAPString create a Pet which contains more properties than what is defined.
func (client PetsClient) CreateAPInPropertiesWithAPString(ctx context.Context, createParameters PetAPInPropertiesWithAPString) (result PetAPInPropertiesWithAPString, err error) {
ctx = tracing.StartSpan(ctx, "generated/additional-properties/PetsClient.CreateAPInPropertiesWithAPString")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per offline discussion please update codegen to not do any of this work if tracing.Enabled() == false.

// Not necessary to perform this check as nothing will be instrumented if it is false, but
// adding it to avoid any potential perf issue.
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fmt.Sprintf("%s/PetsClient.CreateAPInProperties", fqdn))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, I would simply do fqdn + "/PetsClient.CreateAPInProperties".

@@ -31,6 +33,18 @@ func NewPetsClientWithBaseURI(baseURI string) PetsClient {

// CreateAPInProperties create a Pet which contains more properties than what is defined.
func (client PetsClient) CreateAPInProperties(ctx context.Context, createParameters PetAPInProperties) (result PetAPInProperties, err error) {
// Not necessary to perform this check as nothing will be instrumented if it is false, but
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm wondering if this comment should be removed. It adds two lines per API making the files longer and it's likely nobody will ever read it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well my reason was just not to make people think they need to do an isEnabled() check. If you think is overkill I can remove it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and let me know if there is anything else

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought about it a little, and yea seems a little overkill, makes more sense maybe to add this note in the go-autorest functions directly, so removing it

Copy link
Member

@jhendrixMSFT jhendrixMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On minor suggestion for the span name.

@vladbarosan
Copy link
Author

@jhendrixMSFT updated

@vladbarosan vladbarosan reopened this Oct 22, 2018
@ghost ghost added review and removed review labels Oct 22, 2018
@vladbarosan vladbarosan merged commit 4ad539b into Azure:master Oct 22, 2018
@ghost ghost removed the review label Oct 22, 2018
@fearthecowboy
Copy link
Member

🤖 AutoRest automatic publish job 🤖

success (version: 2.1.117)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants