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

Expose track2 module name and version for tracing purpose #23574

Closed
MartinForReal opened this issue Oct 14, 2024 · 16 comments
Closed

Expose track2 module name and version for tracing purpose #23574

MartinForReal opened this issue Oct 14, 2024 · 16 comments
Assignees
Labels
CodeGen Issues that relate to code generation customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Milestone

Comments

@MartinForReal
Copy link
Contributor

Feature Request

Expose track2 module name and version for tracing purpose

We need to add module info into trace context. But Module name and module version are not exposed to public.

e.g.

moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute"

Do you think if it is feasible to expose those information? Thanks!

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 14, 2024
@lirenhe
Copy link
Member

lirenhe commented Oct 14, 2024

@jhendrixMSFT, could you comment on this ask? Is it by design that we don't expose name & version?

@jhendrixMSFT jhendrixMSFT added CodeGen Issues that relate to code generation feature-request This issue requires a new behavior in the product in order be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Oct 14, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 14, 2024
@jhendrixMSFT
Copy link
Member

The only reason we never exported it in the past was because we didn't think it would be useful. If there's a real need for these to be exported, we can do that.

@RickWinter RickWinter added this to the 2025-02 milestone Dec 9, 2024
@RickWinter
Copy link
Member

We should export if we can't find a suitable way to query this at runtime.

@RickWinter
Copy link
Member

@JeffreyRichter Any concerns with exposing these two fields for all modules?

@JeffreyRichter
Copy link
Member

Doesn't our tracing work as-is?
Why do these variables need to be exposed for tracing (assuming it already works)?
Exposing them is not a big deal but I'd still prefer they NOT be exposed.
So, I'd like to understand better what scenario requires them to be exposed.

@MartinForReal
Copy link
Contributor Author

SDK is a dependency of our library. I need to add this info into log and trace.
But if I enable logging in sdk. It will print too many entries.
I also need to customize user agent header in request. The length limit is too short. I can't add additional version info into UA header.

@JeffreyRichter
Copy link
Member

I don't quite understand.
You are writing a package that depends on it Go sdk and you want to grab our module and version info and use it in your own logging which is not related to the logging infrastructure we have in our sdk?

If your app depended on any other module which did not have constants for the module name and version embedded in it, then what would you do? Most modules do not have these constants and I don't think that just because we do we need to expose them.

I'm hesitant to expose them because we don't guarantee that we'll keep them in future versions of that their content will keep the same format.

@MartinForReal
Copy link
Contributor Author

MartinForReal commented Dec 25, 2024

Sorry for my poor written English.

You are writing a package that depends on it Go sdk and you want to grab our module and version info and use it in your own logging which is not related to the logging infrastructure we have in our sdk?

Yes. I will print this in our own logger.

If your app depended on any other module which did not have constants for the module name and version embedded in it, then what would you do? Most modules do not have these constants and I don't think that just because we do we need to expose them.

Arm requests will be generated by sdk and apiVersion will be overwritten in our lib. So, it is hard to tell which version of sdk is in use.
We do need module version info in our log so that we can know that if the dependency has been changed.

I'm hesitant to expose them because we don't guarantee that we'll keep them in future versions of that their content will keep the same format.

As long as I can tell which version the lib depends on, That's ok.

@JeffreyRichter
Copy link
Member

You can tell because you build your package with the dependent module versions in your go.mod file.

@MartinForReal
Copy link
Contributor Author

But I can't print it in logger..

@JeffreyRichter
Copy link
Member

I'm not following this enough. I think you know what version of the module you are taking a dependency on when you build your package and therefore, I think you can hard-code this version in your logging code. You do not REQUIRE that we make these constants public to accomplish your goal. While making these constants public might be convenient for you, it is inconvenient for us as we would now have to document them and maintain them in perpetuity.

If I'm not following the problem you're trying to solve, then you have to really explain it to me in detail. Specifically, I need to know the various components that are part of the problem and which entity (the Go SDK, an immediate consumer of the SDK, a more distant consumer of the SDK, etc.) owns which component. I also need to understand how the components integrate with each other.

@chlowell
Copy link
Member

Go builds dependency info into executables that you can parse with runtime/debug. For example:

import "runtime/debug"

if bi, ok := debug.ReadBuildInfo(); ok {
	for _, dep := range bi.Deps {
		fmt.Printf("%s %s\n", dep.Path, dep.Version)
	}
}

Output

github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
...

Does that work for you?

@chlowell chlowell added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jan 10, 2025
Copy link

Hi @MartinForReal. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@JeffreyRichter
Copy link
Member

@chlowell, this is cool and I had no idea about it! Great suggestion!

@MartinForReal
Copy link
Contributor Author

Thanks!

@github-actions github-actions bot added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Jan 12, 2025
@chlowell
Copy link
Member

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CodeGen Issues that relate to code generation customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

No branches or pull requests

6 participants