GCP 中 setApplicationName() 的意义是什么?

What is the significance of setApplicationName() in GCP?

我是 Google Cloud Platform 的新手,正在尝试使用 Java SDK 在 GCP 中创建资源。

我可以在下面的代码片段中看到应用程序方法,在 GCP 帐户中创建我的资源(如 VPC)时可以使用任何名称。

我想知道这个有什么意义?

这是代码片段:

Compute compute = new Compute.Builder(GoogleNetHttpTransport.newTrustedTransport(), 
    JacksonFactory.getDefaultInstance(), 
        googleCredential)
            .setApplicationName("Google-ComputeSample/0.1") 
            .build();

来自 Google API 文档,setApplicationName():

Sets the application name to be used in the UserAgent header of each request or null for none.

A User-Agent header 用于标识请求在线内容的设备。 根据此 answer, it appears that it really doesn't matter what value you set in it. It can even be just any random strings if you wanted to. Here's another Google API quickstart 使用与示例相同的方法。

正如 Guillaume 所提到的,您使用的库是 Google API 客户端库。它被认为是完整的并且处于维护模式。这意味着 Google 仍将解决严重错误和安全问题,但不会再添加任何新功能。

为了跟上最新的客户端库模型,最好在访问 Cloud API 时学习和使用更新的 Cloud Client Libraries,因此我也推荐使用它。