Skip to content

Commit

Permalink
observability: rename Observability to GcpObservability (grpc#9030)
Browse files Browse the repository at this point in the history
* observability: rename Observability to GcpObservability
rename artifact to grpc-gcp-observability
enable maven publication of grpc-gcp-observability
  • Loading branch information
sanjaypujare authored Mar 30, 2022
1 parent 30b5d6b commit 5113e92
Show file tree
Hide file tree
Showing 32 changed files with 99 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id "ru.vyarus.animalsniffer"
}

description = "gRPC: Observability"
description = "gRPC: Google Cloud Platform Observability"

[compileJava].each() {
it.options.compilerArgs += [
Expand Down Expand Up @@ -52,5 +52,3 @@ dependencies {
}

configureProtoCompilation()

[publishMavenPublicationToMavenRepository]*.onlyIf { false }
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,34 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.base.Preconditions.checkNotNull;

import com.google.common.annotations.VisibleForTesting;
import io.grpc.ExperimentalApi;
import io.grpc.ManagedChannelProvider.ProviderNotFoundException;
import io.grpc.gcp.observability.interceptors.ConfigFilterHelper;
import io.grpc.gcp.observability.interceptors.InternalLoggingChannelInterceptor;
import io.grpc.gcp.observability.interceptors.InternalLoggingServerInterceptor;
import io.grpc.gcp.observability.interceptors.LogHelper;
import io.grpc.gcp.observability.logging.GcpLogSink;
import io.grpc.gcp.observability.logging.Sink;
import io.grpc.internal.TimeProvider;
import io.grpc.observability.interceptors.ConfigFilterHelper;
import io.grpc.observability.interceptors.InternalLoggingChannelInterceptor;
import io.grpc.observability.interceptors.InternalLoggingServerInterceptor;
import io.grpc.observability.interceptors.LogHelper;
import io.grpc.observability.logging.GcpLogSink;
import io.grpc.observability.logging.Sink;
import java.io.IOException;

/** The main class for gRPC Observability features. */
/** The main class for gRPC Google Cloud Platform Observability features. */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/8869")
public final class Observability implements AutoCloseable {
private static Observability instance = null;
public final class GcpObservability implements AutoCloseable {
private static GcpObservability instance = null;
private final Sink sink;

/**
* Initialize grpc-observability.
*
* @throws ProviderNotFoundException if no underlying channel/server provider is available.
*/
public static synchronized Observability grpcInit() throws IOException {
public static synchronized GcpObservability grpcInit() throws IOException {
if (instance == null) {
GlobalLoggingTags globalLoggingTags = new GlobalLoggingTags();
ObservabilityConfigImpl observabilityConfig = ObservabilityConfigImpl.getInstance();
Expand All @@ -56,21 +56,21 @@ public static synchronized Observability grpcInit() throws IOException {
return instance;
}

@VisibleForTesting static Observability grpcInit(Sink sink,
@VisibleForTesting static GcpObservability grpcInit(Sink sink,
InternalLoggingChannelInterceptor.Factory channelInterceptorFactory,
InternalLoggingServerInterceptor.Factory serverInterceptorFactory) {
if (instance == null) {
instance = new Observability(sink, channelInterceptorFactory, serverInterceptorFactory);
instance = new GcpObservability(sink, channelInterceptorFactory, serverInterceptorFactory);
}
return instance;
}

/** Un-initialize/shutdown grpc-observability. */
@Override
public void close() {
synchronized (Observability.class) {
synchronized (GcpObservability.class) {
if (instance == null) {
throw new IllegalStateException("Observability already closed!");
throw new IllegalStateException("GcpObservability already closed!");
}
LoggingChannelProvider.shutdown();
LoggingServerProvider.shutdown();
Expand All @@ -79,7 +79,7 @@ public void close() {
}
}

private Observability(Sink sink,
private GcpObservability(Sink sink,
InternalLoggingChannelInterceptor.Factory channelInterceptorFactory,
InternalLoggingServerInterceptor.Factory serverInterceptorFactory) {
this.sink = checkNotNull(sink);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.base.Preconditions.checkNotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.base.Preconditions.checkNotNull;

Expand All @@ -23,7 +23,7 @@
import io.grpc.ManagedChannelBuilder;
import io.grpc.ManagedChannelProvider;
import io.grpc.ManagedChannelRegistry;
import io.grpc.observability.interceptors.InternalLoggingChannelInterceptor;
import io.grpc.gcp.observability.interceptors.InternalLoggingChannelInterceptor;

/** A channel provider that injects logging interceptor. */
final class LoggingChannelProvider extends ManagedChannelProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.base.Preconditions.checkNotNull;

Expand All @@ -23,7 +23,7 @@
import io.grpc.ServerCredentials;
import io.grpc.ServerProvider;
import io.grpc.ServerRegistry;
import io.grpc.observability.interceptors.InternalLoggingServerInterceptor;
import io.grpc.gcp.observability.interceptors.InternalLoggingServerInterceptor;

/** A server provider that injects the logging interceptor. */
final class LoggingServerProvider extends ServerProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import io.grpc.observabilitylog.v1.GrpcLogRecord.EventType;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.base.Preconditions.checkArgument;

Expand All @@ -27,7 +27,7 @@
import java.util.Map;

/**
* gRPC Observability configuration processor.
* gRPC GcpObservability configuration processor.
*/
final class ObservabilityConfigImpl implements ObservabilityConfig {
private static final String CONFIG_ENV_VAR_NAME = "GRPC_CONFIG_OBSERVABILITY";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
* limitations under the License.
*/

package io.grpc.observability.interceptors;
package io.grpc.gcp.observability.interceptors;

import com.google.auto.value.AutoValue;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.grpc.Internal;
import io.grpc.MethodDescriptor;
import io.grpc.observability.ObservabilityConfig;
import io.grpc.observability.ObservabilityConfig.LogFilter;
import io.grpc.gcp.observability.ObservabilityConfig;
import io.grpc.gcp.observability.ObservabilityConfig.LogFilter;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventType;
import java.util.HashMap;
import java.util.List;
Expand All @@ -33,7 +33,7 @@
import java.util.logging.Logger;

/**
* Parses gRPC Observability configuration filters for interceptors usage.
* Parses gRPC GcpObservability configuration filters for interceptors usage.
*/
@Internal
public class ConfigFilterHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.interceptors;
package io.grpc.gcp.observability.interceptors;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.interceptors;
package io.grpc.gcp.observability.interceptors;

import com.google.protobuf.Duration;
import com.google.protobuf.util.Durations;
Expand All @@ -30,7 +30,7 @@
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.grpc.Status;
import io.grpc.observability.interceptors.ConfigFilterHelper.FilterParams;
import io.grpc.gcp.observability.interceptors.ConfigFilterHelper.FilterParams;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventLogger;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventType;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.interceptors;
package io.grpc.gcp.observability.interceptors;

import com.google.protobuf.Duration;
import com.google.protobuf.util.Durations;
Expand All @@ -29,7 +29,7 @@
import io.grpc.ServerInterceptor;
import io.grpc.Status;

import io.grpc.observability.interceptors.ConfigFilterHelper.FilterParams;
import io.grpc.gcp.observability.interceptors.ConfigFilterHelper.FilterParams;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventLogger;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventType;
import java.net.SocketAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.interceptors;
package io.grpc.gcp.observability.interceptors;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand All @@ -29,8 +29,8 @@
import io.grpc.InternalMetadata;
import io.grpc.Metadata;
import io.grpc.Status;
import io.grpc.gcp.observability.logging.Sink;
import io.grpc.internal.TimeProvider;
import io.grpc.observability.logging.Sink;
import io.grpc.observabilitylog.v1.GrpcLogRecord;
import io.grpc.observabilitylog.v1.GrpcLogRecord.Address;
import io.grpc.observabilitylog.v1.GrpcLogRecord.EventLogger;
Expand Down Expand Up @@ -318,7 +318,7 @@ GrpcLogRecord.Builder createTimestamp() {
return GrpcLogRecord.newBuilder().setTimestamp(Timestamps.fromNanos(nanos));
}

// TODO(DNVindhya): Evaluate if we need following clause for metadata logging in Observability
// TODO(DNVindhya): Evaluate if we need following clause for metadata logging in GcpObservability
// Leaving the implementation for now as is to have same behavior across Java and Go
private static final Set<String> NEVER_INCLUDED_METADATA = new HashSet<>(
Collections.singletonList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.logging;
package io.grpc.gcp.observability.logging;

import com.google.cloud.MonitoredResource;
import com.google.cloud.logging.LogEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.logging;
package io.grpc.gcp.observability.logging;

import com.google.cloud.MonitoredResource;
import com.google.cloud.logging.LogEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.logging;
package io.grpc.gcp.observability.logging;

import io.grpc.Internal;
import io.grpc.observabilitylog.v1.GrpcLogRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability.logging;
package io.grpc.gcp.observability.logging;

import io.grpc.ExperimentalApi;
import io.grpc.observabilitylog.v1.GrpcLogRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
Expand All @@ -23,15 +23,15 @@

import io.grpc.ManagedChannelProvider;
import io.grpc.ServerProvider;
import io.grpc.observability.interceptors.InternalLoggingChannelInterceptor;
import io.grpc.observability.interceptors.InternalLoggingServerInterceptor;
import io.grpc.observability.logging.Sink;
import io.grpc.gcp.observability.interceptors.InternalLoggingChannelInterceptor;
import io.grpc.gcp.observability.interceptors.InternalLoggingServerInterceptor;
import io.grpc.gcp.observability.logging.Sink;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class ObservabilityTest {
public class GcpObservabilityTest {

@Test
public void initFinish() {
Expand All @@ -42,12 +42,12 @@ public void initFinish() {
InternalLoggingChannelInterceptor.Factory.class);
InternalLoggingServerInterceptor.Factory serverInterceptorFactory = mock(
InternalLoggingServerInterceptor.Factory.class);
Observability observability1;
try (Observability observability = Observability.grpcInit(sink, channelInterceptorFactory,
GcpObservability observability1;
try (GcpObservability observability = GcpObservability.grpcInit(sink, channelInterceptorFactory,
serverInterceptorFactory)) {
assertThat(ManagedChannelProvider.provider()).isInstanceOf(LoggingChannelProvider.class);
assertThat(ServerProvider.provider()).isInstanceOf(ServerProvider.class);
observability1 = Observability.grpcInit(sink, channelInterceptorFactory,
observability1 = GcpObservability.grpcInit(sink, channelInterceptorFactory,
serverInterceptorFactory);
assertThat(observability1).isSameInstanceAs(observability);

Expand All @@ -59,7 +59,7 @@ public void initFinish() {
observability1.close();
fail("should have failed for calling close() second time");
} catch (IllegalStateException e) {
assertThat(e).hasMessageThat().contains("Observability already closed!");
assertThat(e).hasMessageThat().contains("GcpObservability already closed!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.grpc.observability;
package io.grpc.gcp.observability;

import static com.google.common.truth.Truth.assertThat;

Expand Down
Loading

0 comments on commit 5113e92

Please sign in to comment.