Skip to content

Commit

Permalink
test: fix list logs test flakiness (#301)
Browse files Browse the repository at this point in the history
* chore: debrand Cloud Logging library from Stackdriver
* chore: add cdpe ops team to codeowners
* fix: add monitored resource filter to flaky tests
* fix: updated listlogs test for samples

Co-authored-by: Jeff Ching <[email protected]>
  • Loading branch information
Simon Zeltser and chingor13 authored Oct 28, 2020
1 parent 1488370 commit 024b73d
Show file tree
Hide file tree
Showing 23 changed files with 153 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
**/*.java @googleapis/api-logging

# The java-samples-reviewers team is the default owner for samples changes
samples/**/*.java @googleapis/java-samples-reviewers
samples/**/*.java @googleapis/java-samples-reviewers @googleapis/api-logging
8 changes: 4 additions & 4 deletions .readme-partials.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
custom_content: |
#### Creating an authorized service object
To make authenticated requests to Stackdriver Logging, you must create a service object with
To make authenticated requests to Cloud Logging, you must create a service object with
credentials. You can then make API calls by calling methods on the Logging service object. The
simplest way to authenticate is to use
[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
Expand Down Expand Up @@ -78,17 +78,17 @@ custom_content: |
}
```
#### Add a Stackdriver Logging handler to a logger
#### Add a Cloud Logging handler to a logger
You can also register a `LoggingHandler` to a `java.util.logging.Logger` that publishes log entries
to Stackdriver Logging. Given the following logger:
to Cloud Logging. Given the following logger:
```java
private final static Logger LOGGER = Logger.getLogger(MyClass.class.getName());
```
You can register a `LoggingHandler` with the code:
```java
LoggingHandler.addHandler(LOGGER, new LoggingHandler());
```
After that, logs generated using `LOGGER` will be also directed to Stackdriver Logging.
After that, logs generated using `LOGGER` will be also directed to Cloud Logging.
Notice that you can also register a `LoggingHandler` via the `logging.properties` configuration
file. Adding, for instance, the following line:
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Google Stackdriver Logging Client for Java
# Google Cloud Logging Client for Java

Java idiomatic client for [Stackdriver Logging][product-docs].
Java idiomatic client for [Cloud Logging][product-docs].

[![Maven][maven-version-image]][maven-version-link]
![Stability][stability-image]
Expand Down Expand Up @@ -61,7 +61,7 @@ See the [Authentication][authentication] section in the base directory's README.

### Prerequisites

You will need a [Google Cloud Platform Console][developer-console] project with the Stackdriver Logging [API enabled][enable-api].
You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Logging [API enabled][enable-api].

[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by
[installing the Google Cloud SDK][cloud-sdk] and running the following commands in command line:
Expand All @@ -72,17 +72,17 @@ You will need a [Google Cloud Platform Console][developer-console] project with
You'll need to obtain the `google-cloud-logging` library. See the [Quickstart](#quickstart) section
to add `google-cloud-logging` as a dependency in your code.

## About Stackdriver Logging
## About Cloud Logging


[Stackdriver Logging][product-docs] allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud and Amazon Web Services. Using the BindPlane service, you can also collect this data from over 150 common application components, on-premises systems, and hybrid cloud systems. BindPlane is included with your Google Cloud project at no additional cost.
[Cloud Logging][product-docs] allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud and Amazon Web Services. Using the BindPlane service, you can also collect this data from over 150 common application components, on-premises systems, and hybrid cloud systems. BindPlane is included with your Google Cloud project at no additional cost.

See the [Stackdriver Logging client library docs][javadocs] to learn how to
use this Stackdriver Logging Client Library.
See the [Cloud Logging client library docs][javadocs] to learn how to
use this Cloud Logging Client Library.


#### Creating an authorized service object
To make authenticated requests to Stackdriver Logging, you must create a service object with
To make authenticated requests to Cloud Logging, you must create a service object with
credentials. You can then make API calls by calling methods on the Logging service object. The
simplest way to authenticate is to use
[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
Expand Down Expand Up @@ -160,17 +160,17 @@ while (entryIterator.hasNext()) {
}
```

#### Add a Stackdriver Logging handler to a logger
#### Add a Cloud Logging handler to a logger
You can also register a `LoggingHandler` to a `java.util.logging.Logger` that publishes log entries
to Stackdriver Logging. Given the following logger:
to Cloud Logging. Given the following logger:
```java
private final static Logger LOGGER = Logger.getLogger(MyClass.class.getName());
```
You can register a `LoggingHandler` with the code:
```java
LoggingHandler.addHandler(LOGGER, new LoggingHandler());
```
After that, logs generated using `LOGGER` will be also directed to Stackdriver Logging.
After that, logs generated using `LOGGER` will be also directed to Cloud Logging.

Notice that you can also register a `LoggingHandler` via the `logging.properties` configuration
file. Adding, for instance, the following line:
Expand Down Expand Up @@ -209,7 +209,7 @@ To get help, follow the instructions in the [shared Troubleshooting document][tr

## Transport

Stackdriver Logging uses gRPC for the transport layer.
Cloud Logging uses gRPC for the transport layer.

## Java Versions

Expand Down
2 changes: 1 addition & 1 deletion google-cloud-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<packaging>jar</packaging>
<name>Google Cloud Logging</name>
<url>https://github.com/googleapis/java-logging</url>
<description>Java idiomatic client for Stackdriver Logging</description>
<description>Java idiomatic client for Cloud Logging</description>
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-logging-parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import java.util.Objects;

/**
* A Stackdriver Logging log entry. All log entries are represented via objects of this class. Log
* entries can have different type of payloads: an UTF-8 string (see {@link Payload.StringPayload}),
* a JSON object (see {@link Payload.JsonPayload}, or a protobuf object (see {@link
* Payload.ProtoPayload}). Entries can also store additional information about the operation or the
* HTTP request that generated the log (see {@link LogEntry#getOperation()} and {@link
* LogEntry#getHttpRequest()}, respectively).
* A Cloud Logging log entry. All log entries are represented via objects of this class. Log entries
* can have different type of payloads: an UTF-8 string (see {@link Payload.StringPayload}), a JSON
* object (see {@link Payload.JsonPayload}, or a protobuf object (see {@link Payload.ProtoPayload}).
* Entries can also store additional information about the operation or the HTTP request that
* generated the log (see {@link LogEntry#getOperation()} and {@link LogEntry#getHttpRequest()},
* respectively).
*
* @see <a href="https://cloud.google.com/logging/docs/view/logs_index">Log Entries and Logs</a>
*/
Expand Down Expand Up @@ -139,7 +139,7 @@ public Builder setTimestamp(long timestamp) {
return this;
}

/** Sets the time the log entry was received by Stackdriver Logging. */
/** Sets the time the log entry was received by Cloud Logging. */
public Builder setReceiveTimestamp(long receiveTimestamp) {
this.receiveTimestamp = receiveTimestamp;
return this;
Expand Down Expand Up @@ -305,7 +305,7 @@ public Long getTimestamp() {
return timestamp;
}

/** Returns the time the log entry was received by Stackdriver Logging. */
/** Returns the time the log entry was received by Cloud Logging. */
public Long getReceiveTimestamp() {
return receiveTimestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ public static EntryListOption filter(String filter) {
ApiFuture<Boolean> deleteLogAsync(String log);

/**
* Lists the monitored resource descriptors used by Stackdriver Logging. This method returns a
* {@link Page} object that can be used to consume paginated results. Use {@link ListOption} to
* specify the page size or the page token from which to start listing resource descriptors.
* Lists the monitored resource descriptors used by Cloud Logging. This method returns a {@link
* Page} object that can be used to consume paginated results. Use {@link ListOption} to specify
* the page size or the page token from which to start listing resource descriptors.
*
* <p>Example of listing monitored resource descriptors, specifying the page size.
*
Expand All @@ -458,11 +458,11 @@ public static EntryListOption filter(String filter) {
Page<MonitoredResourceDescriptor> listMonitoredResourceDescriptors(ListOption... options);

/**
* Sends a request for listing monitored resource descriptors used by Stackdriver Logging. This
* method returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()}
* returns an {@link AsyncPage} object that can be used to asynchronously handle paginated
* results. Use {@link ListOption} to specify the page size or the page token from which to start
* listing resource descriptors.
* Sends a request for listing monitored resource descriptors used by Cloud Logging. This method
* returns a {@code ApiFuture} object to consume the result. {@link ApiFuture#get()} returns an
* {@link AsyncPage} object that can be used to asynchronously handle paginated results. Use
* {@link ListOption} to specify the page size or the page token from which to start listing
* resource descriptors.
*
* <p>Example of asynchronously listing monitored resource descriptors, specifying the page size.
*
Expand Down Expand Up @@ -678,8 +678,8 @@ ApiFuture<AsyncPage<MonitoredResourceDescriptor>> listMonitoredResourceDescripto
void flush();

/**
* Sends a request to log entries to Stackdriver Logging. Use {@link WriteOption#logName(String)}
* to provide a log name for those entries that do not specify one. Use {@link
* Sends a request to log entries to Cloud Logging. Use {@link WriteOption#logName(String)} to
* provide a log name for those entries that do not specify one. Use {@link
* WriteOption#resource(MonitoredResource)} to provide a monitored resource for those entries that
* do not specify one. Use {@link WriteOption#labels(Map)} to provide some labels to be added to
* every entry in {@code logEntries}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
import java.util.logging.SimpleFormatter;

/**
* A logging handler that outputs logs generated with {@link java.util.logging.Logger} to
* Stackdriver Logging.
* A logging handler that outputs logs generated with {@link java.util.logging.Logger} to Cloud
* Logging.
*
* <p>Java logging levels (see {@link java.util.logging.Level}) are mapped to the following Google
* Stackdriver Logging severities:
* Cloud Logging severities:
*
* <table summary="Mapping of Java logging level to Stackdriver Logging severities">
* <tr><th width="50%">Java Level</th><th>Stackdriver Logging Severity</th></tr>
* <table summary="Mapping of Java logging level to Cloud Logging severities">
* <tr><th width="50%">Java Level</th><th>Cloud Logging Severity</th></tr>
* <tr><td>SEVERE</td><td>ERROR</td></tr>
* <tr><td>WARNING</td><td>WARNING</td></tr>
* <tr><td>INFO</td><td>INFO</td></tr>
Expand All @@ -53,9 +53,9 @@
* </table>
*
* <p>Original Java logging levels are added as labels (with {@code levelName} and {@code
* levelValue} keys, respectively) to the corresponding Stackdriver Logging {@link LogEntry}. You
* can read entry labels using {@link LogEntry#getLabels()}. To use logging levels that correspond
* to Stackdriver Logging severities you can use {@link LoggingLevel}.
* levelValue} keys, respectively) to the corresponding Cloud Logging {@link LogEntry}. You can read
* entry labels using {@link LogEntry#getLabels()}. To use logging levels that correspond to Cloud
* Logging severities you can use {@link LoggingLevel}.
*
* <p><b>Configuration</b>: By default each {@code LoggingHandler} is initialized using the
* following {@code LogManager} configuration properties (that you can set in the {@code
Expand All @@ -72,16 +72,16 @@
* <li>{@code com.google.cloud.logging.LoggingHandler.formatter} specifies the name of a {@link
* Formatter} class to use (defaults to {@link SimpleFormatter}).
* <li>{@code com.google.cloud.logging.LoggingHandler.flushLevel} specifies the flush log level.
* When a log with this level is published, logs are transmitted to the Stackdriver Logging
* service (defaults to {@link LoggingLevel#ERROR}).
* When a log with this level is published, logs are transmitted to the Cloud Logging service
* (defaults to {@link LoggingLevel#ERROR}).
* <li>{@code com.google.cloud.logging.LoggingHandler.enhancers} specifies a comma separated list
* of {@link LoggingEnhancer} classes. This handler will call each enhancer list whenever it
* builds a {@link LogEntry} instance (defaults to empty list).
* <li>{@code com.google.cloud.logging.LoggingHandler.resourceType} the type name to use when
* creating the default {@link MonitoredResource} (defaults to auto-detected resource type,
* else "global").
* <li>{@code com.google.cloud.logging.Synchronicity} the synchronicity of the write method to use
* to write logs to the Stackdriver Logging service (defaults to {@link Synchronicity#ASYNC}).
* to write logs to the Cloud Logging service (defaults to {@link Synchronicity#ASYNC}).
* </ul>
*
* <p>To add a {@code LoggingHandler} to an existing {@link Logger} and be sure to avoid infinite
Expand All @@ -105,7 +105,7 @@ public class LoggingHandler extends Handler {

private volatile Logging logging;

// Logs with the same severity with the base could be more efficiently sent to Stackdriver.
// Logs with the same severity with the base could be more efficiently sent to Cloud.
// Defaults to level of the handler or Level.FINEST if the handler is set to Level.ALL.
// Currently there is no way to modify the base level, see
// https://github.com/googleapis/google-cloud-java/issues/1740 .
Expand All @@ -115,13 +115,13 @@ public class LoggingHandler extends Handler {

private WriteOption[] defaultWriteOptions;

/** Creates an handler that publishes messages to Stackdriver Logging. */
/** Creates an handler that publishes messages to Cloud Logging. */
public LoggingHandler() {
this(null, null, null);
}

/**
* Creates a handler that publishes messages to Stackdriver Logging.
* Creates a handler that publishes messages to Cloud Logging.
*
* @param log the name of the log to which log entries are written
*/
Expand All @@ -130,20 +130,20 @@ public LoggingHandler(String log) {
}

/**
* Creates a handler that publishes messages to Stackdriver Logging.
* Creates a handler that publishes messages to Cloud Logging.
*
* @param log the name of the log to which log entries are written
* @param options options for the Stackdriver Logging service
* @param options options for the Cloud Logging service
*/
public LoggingHandler(String log, LoggingOptions options) {
this(log, options, null);
}

/**
* Creates a handler that publishes messages to Stackdriver Logging.
* Creates a handler that publishes messages to Cloud Logging.
*
* @param log the name of the log to which log entries are written
* @param options options for the Stackdriver Logging service
* @param options options for the Cloud Logging service
* @param monitoredResource the monitored resource to which log entries refer. If it is null then
* a default resource is created based on the project ID and deployment environment.
*/
Expand All @@ -152,10 +152,10 @@ public LoggingHandler(String log, LoggingOptions options, MonitoredResource moni
}

/**
* Creates a handler that publishes messages to Stackdriver Logging.
* Creates a handler that publishes messages to Cloud Logging.
*
* @param log the name of the log to which log entries are written
* @param options options for the Stackdriver Logging service
* @param options options for the Cloud Logging service
* @param monitoredResource the monitored resource to which log entries refer. If it is null then
* a default resource is created based on the project ID and deployment environment.
* @param enhancers List of {@link LoggingEnhancer} instances used to enhance any{@link LogEntry}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.logging.Level;

/**
* This class adds some additional Java logging levels for Stackdriver Logging. Added levels fill in
* the gap between Java logging levels and Stackdriver Logging severities.
* This class adds some additional Java logging levels for Cloud Logging. Added levels fill in the
* gap between Java logging levels and Cloud Logging severities.
*
* <p>Added levels in descending order are (between parenthesis the relation with Java logging
* levels):
Expand Down Expand Up @@ -85,7 +85,7 @@ private LoggingLevel(String name, int value, Severity severity) {
this.severity = severity;
}

/** Returns the Stackdriver Logging severity associated with this logging level. */
/** Returns the Cloud Logging severity associated with this logging level. */
public Severity getSeverity() {
return severity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.Objects;

/**
* Stackdriver Logging metrics describe logs-based metric. The value of the metric is the number of
* log entries that match a logs filter (see {@link #getFilter()}).
* Cloud Logging metrics describe logs-based metric. The value of the metric is the number of log
* entries that match a logs filter (see {@link #getFilter()}).
*
* <p>{@code Metric} adds a layer of service-related functionality over {@link MetricInfo}. Objects
* of this class are immutable. To get a {@code Metric} object with the most recent information use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.Objects;

/**
* Stackdriver Logging metrics describe logs-based metric. The value of the metric is the number of
* log entries that match a logs filter (see {@link #getFilter()}).
* Cloud Logging metrics describe logs-based metric. The value of the metric is the number of log
* entries that match a logs filter (see {@link #getFilter()}).
*
* @see <a href="https://cloud.google.com/logging/docs/view/logs_based_metrics">Logs-based Metrics
* </a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.Objects;

/**
* Stackdriver Logging sinks can be used to control the export of your logs. Each sink specifies the
* Cloud Logging sinks can be used to control the export of your logs. Each sink specifies the
* export of a set of log entries to a certain destination. A sink consists of a name, unique to the
* project, a filter for choosing the log entries to export and a destination for the log entries.
*
Expand Down
Loading

0 comments on commit 024b73d

Please sign in to comment.