Search code examples
javagoogle-cloud-platformstackdrivergoogle-cloud-stackdriver

Why does Google offer so many client libs? Which should I use for Stackdriver logging?


I'm trying to send logs to Stackdriver and am a little confounded by the option of two dependencies I could use —

The Google Cloud Client Library recommends google-cloud version 0.35.0-alpha

The logging docs recommend I install google-cloud-logging version 1.14.0

Googling around for the LogEntryOperation I would like to use yields a google-api-services-logging version v2-rev577-1.23.0.

Are the underlying communications mechanisms to Google's API different between these?

Which of these is most feature-full, least likely to be deprecated, and maintained going forward? Why are there so many?


Solution

  • Google Cloud ships two kinds of client libraries:

    1. Auto generated libraries that just export the REST API directly. These are called the "Google API Client Libraries". These have the advantage that they cover every API in every language in complete detail.

      For Java, these are in com.google.apis. This is what you found searching for LogEntryOperation.

    2. Hand-crafted libraries that aim to be more "natural". These are called the "Google Cloud APIs". These are easier to use and fit in better with how the language is used. However they are available for fewer API/language combinations, and don't always cover 100% of the API.

      For Java, these are in com.google.cloud. This is what our docs recommend. google-cloud is simply a convenience package for all of the available libraries, including the logging-specific google-cloud-logging package.

    The logging library is a good example of the difference. As the actual REST API exposes a LogEntryOperation resource, the auto-generated API just creates a LogEntryOperation class that blindly copies this.

    By contrast, the manually created API has a more concisely named Operation class. In addition, the manually created API provides a better static constructor, a Builder, and names the first() and last() methods more sensibly.