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

gcp-observability: remove logging channel/server providers #9424

Merged
merged 5 commits into from Aug 10, 2022

Conversation

DNVindhya
Copy link
Contributor

This PR removes ManagedChannelProvider and ServerProvider used by logging.

With this change, going forward all three features of Observability namely logging, metrics and traces will use GlobalInterceptors to set Client/Server interceptors as well as Stream Tracers.

CC @sanjaypujare

new InternalLoggingChannelInterceptor.FactoryImpl(logHelper, logFilterHelper),
new InternalLoggingServerInterceptor.FactoryImpl(logHelper, logFilterHelper));
instance = new GcpObservability(sink, config);
instance.setProducer(channelInterceptorFactory, serverInterceptorFactory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something that's now clear is that we only ever create one instance of the InternalLoggingChannelInterceptor and InternalLoggingServerInterceptor each and install those in the Global interceptors. So the factory is kind of useless. One thing we may consider (may be a separate PR) is to eliminate the Factories and replace those with those respective interceptors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a TODO comment saying we will eliminate the factory?

@@ -40,7 +40,7 @@
import java.util.logging.Logger;

/**
* A logging interceptor for {@code LoggingChannelProvider}.
* A logging client interceptor for Observability.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned elsewhere we should consider getting rid of the Factory (in the Server interceptor as well). A separate PR seems more convenient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree and will do this in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add a TODO comment saying so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*
* <p>Ignoring test, because it calls external Cloud Monitoring APIs. To test cloud monitoring
* setup locally, 1. Set up Cloud auth credentials 2. Assign permissions to service account to
* write metrics to project specified by variable PROJECT_ID 3. Comment @Ignore annotation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am assuming when enabled with the correct set up this test passes? It might be worth mentioning that.

Sink mockSink = new GcpLogSink(mockLogging, destProjectName, locationTags,
customTags, flushLimit);
assertThat(mockSink).isInstanceOf(GcpLogSink.class);
assertThat(spySink).isInstanceOf(GcpLogSink.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this test achieve? Or what does it really test from the "class-under-test"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated test to check if sink is instance of Sink interface


ArgumentCaptor<Collection<LogEntry>> logEntrySetCaptor = ArgumentCaptor.forClass(
(Class) Collection.class);
verify(mockLogging, times(1)).write(logEntrySetCaptor.capture());
for (Iterator<LogEntry> it = logEntrySetCaptor.getValue().iterator(); it.hasNext(); ) {
LogEntry entry = it.next();
System.out.println(entry);
assertThat(entry.getPayload().getData()).isEqualTo(expectedStructLogProto);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed expectedStructLogProto - can it be defined in upper-case as EXPECTED_STRUCT_LOG_PROTO since it is like a constant object?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly logProto ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finished 1st round. Will do the 2nd round once the comments are addressed

@DNVindhya
Copy link
Contributor Author

Addressed comments. PTAL

assertThat(mockSink).isInstanceOf(GcpLogSink.class);
GcpLogSink sink = new GcpLogSink(mockLogging, destProjectName, locationTags,
customTags, FLUSH_LIMIT);
assertThat(sink).isInstanceOf(Sink.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the value of this assert? Since GcpLogSink is declared to implement Sink this will be true so the test seems trivial - does not verify any run time behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Removed the test since this was not adding any additional value.

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Small changes requested

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sanjaypujare
Copy link
Contributor

CC @ejona86

@sanjaypujare sanjaypujare merged commit 7bdca0c into grpc:master Aug 10, 2022
@DNVindhya DNVindhya deleted the o11y-remove-logging-providers branch August 10, 2022 22:02
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants