Commit Graph

298 Commits

Author SHA1 Message Date
Eric Anderson f737cbc143 api: Hide internal metric APIs
Some APIs were marked experimental but had internal APIs in their
surface. These were all changed to internal. And then the internal APIs
were mostly hidden from generated documentation.

All these APIs will eventually become public and maybe even stable. But
they need some iteration before we're ready for others to start using
them.
2024-05-09 11:31:01 -07:00
Eric Anderson 3b6b1537d4 rls: Add metric test with real channel 2024-05-09 09:01:35 -07:00
Eric Anderson b6f7b693e7 Add gauge metric API and Otel implementation
This is needed by gRFC A78 for xds metrics, and for RLS metrics. Since
gauges need to acquire a lock (or other synchronization) in the
callback, the callback allows batching multiple gauges together to avoid
acquiring-and-requiring such locks.

Unlike other metrics, gauges are reported on-demand to the MetricSink.
This means not all sinks will receive the same data, as the sinks will
ask for the gauges at different times.
2024-05-08 19:28:28 -07:00
Eric Anderson 952ac022ee Add internal channel builder API to get target
This will be used for gRFC A66's OTel per-RPC metric label:

> `grpc.target` : Canonicalized target URI used when creating gRPC
> Channel, e.g. "dns:///pubsub.googleapis.com:443",
> "xds:///helloworld-gke:8000". Canonicalized target URI is the form
> with the scheme included if the user didn't mention the scheme
> (`scheme://[authority]/path`).

The majority of the changes are to move target computation from
ManagedChannelImpl into the builder. A small hack API was added to
ManagedChannelBuilder to get the target to create an interceptor.
2024-05-08 19:28:14 -07:00
Eric Anderson 18cf46e456 Migrate GlobalInterceptors to ConfiguratorRegistry
This should preserve all the existing behavior of GlobalInterceptors as
used by grpc-gcp-observability, including it disabling the implicit
OpenCensus integration.

Both the old and new API are internal. I hid Configurator and
ConfiguratorRegistry behind Internal-prefixed classes, like had been
done with GlobalInterceptors to further discourage use until the API is
ready.

GlobalInterceptorsTest was modified to become ConfiguratorRegistryTest.
2024-05-08 16:23:51 -07:00
Vindhya Ningegowda d6f1a9d569 Add MetricSink implementation for gRPC OpenTelemetry
This adds the following components that are required for gRPC A79
non-per-call metrics architecture.

- MetricSink implementation for gRPC OpenTelemetry
- Configurator for plumbing per call metrics ClientInterceptor and
  ServerStreamTracer.Factory via unified OpenTelemetryModule.
2024-05-08 15:49:49 -07:00
Terry Wilson a9fb272b78
rls: add counter metrics (#11138)
Adds the following metrics to the RlsLoadBalancer:
- grpc.lb.rls.default_target_picks
- grpc.lb.rls.target_picks
- grpc.lb.rls.failed_picks
2024-05-01 11:24:38 -07:00
Eric Anderson 4561bb5b80 Plumb target to load balancer
gRFC A78 has WRR and pick-first include a `grpc.target` label, defined
in A66:

> `grpc.target` : Canonicalized target URI used when creating gRPC
> Channel, e.g. "dns:///pubsub.googleapis.com:443",
> "xds:///helloworld-gke:8000". Canonicalized target URI is the form
> with the scheme included if the user didn't mention the scheme
> (`scheme://[authority]/path`). For channels such as inprocess channels
> where a target URI is not available, implementations can synthesize a
> target URI.
2024-05-01 09:19:45 -07:00
Eric Anderson 27d57585cd api: Return a noop MetricRecorder from Helper by default
Since 06df25b65d, WRR has been calling this method, and it will get an
exception. We don't want WRR to be broken until we have MetricRecorder
fully plumbed.
2024-04-30 07:18:56 -07:00
Eric Anderson 4c78a9746c
Plumb optional labels from LB to ClientStreamTracer
As part of gRFC A78:

> To support the locality label in the per-call metrics, we will provide
> a mechanism for LB picker to add optional labels to the call attempt
> tracer.
2024-04-29 16:30:51 -07:00
Vindhya Ningegowda 795ee0f6e3
Add MetricRecorder implementation (#11128)
* added MetricRecorderImpl and unit tests for MetricInstrumentRegistry

* updated MetricInstrumentRegistry to use array instead of ArrayList

* renamed record<>Counter APIs to add<>Counter. Added check for mismatched label values

* added lock for instruments array
2024-04-26 13:47:55 -07:00
Vindhya Ningegowda c404c9f66c
Add MetricRecorder and MetricSink interface (#11109)
Adds interfaces required for recording metrics from gRPC components. And added API to get `MetricRecorder` in `LoadBalancer.Helper` and add `MetricSink` to `ManagedChannelBuilder`.
2024-04-17 15:10:57 -07:00
Vindhya Ningegowda 497e155217
Add Metric Instrument Registry (#11103)
* added metric instrument registry
2024-04-12 13:42:40 -07:00
Alex Panchenko e36f099be9
StatusException/StatusRuntimeException hide stack trace in a simpler way (#11064) 2024-04-01 08:31:13 -07:00
David Burns 00649913b0
bazel: Use the `artifact` macro for loading maven deps
The recommended way to load dependencies from `rules_jvm_external`
is to make use of the `@maven` workspace, and the most readable
way of doing that is to use the `artifact` macro provides.

This removes the need to generate the "compat" namespaces, which
`rules_jvm_external` provided for backwards compatibility with
older releases. This change also sets things up for supporting
`bzlmod`: this requires all workspaces accessed by a library to
be named "up front" in the `MODULE.bazel` file. This way, the
only repo that needs to be exported is `@maven`, rather than the
current huge list.
2024-03-28 14:33:32 -07:00
James Duong 2c83ef0632
Allow configuration of the queued byte threshold at which a Stream is considered not ready (#10977)
* Allow the queued byte threshold for a Stream to be ready to be configurable

- on clients this is exposed by setting a CallOption
- on servers this is configured by calling a method on ServerCall or ServerStreamListener
2024-03-21 15:37:26 -07:00
Sergii Tkachenko b3475a0e46
api: Remove ExperimentalApi from Attributes.Builder.discard (#11004)
Now tracked together with Attributes:
https://github.com/grpc/grpc-java/issues/1764.

Closes #5777.
2024-03-11 16:15:03 -07:00
Touko Vainio-Kaila 0b82f01260
api: Fix a typo in ServerInterceptor JavaDoc (#10990) 2024-03-06 10:43:14 -08:00
Sergii Tkachenko de7e649e04
(minor) Fix a typo in ReflectableMarshaller docstring (#10942)
`it's` -> `its`
2024-02-21 13:29:51 -08:00
yifeizhuang ff34d51c73
api: stabilize server.getListenerSockets (#10910) 2024-02-09 14:40:54 -08:00
Larry Safran 7f4c16e068
internal:Happy eyeballs (#10731)
* implement happy eyeballs

---------

Co-authored-by: tonyjongyoonan <tonyjan@google.com>
2024-01-29 12:50:58 -08:00
Larry Safran a151099820
change since javadoc in ClientTransportFilter.java (#10817)
Change from 1.61 to 1.62 since it wasn't released in 1.61
2024-01-16 09:54:56 -08:00
Larry Safran 4b2e5eddd2
api:Provide a default implementation for new method added to ManagedTranport.Listener to support ClientTransportFilters (#10795)
* Provide a default implementation for new method added to ManagedTransport.Listener to support ClientTransportFilters
* Relax test constraint to reduce flakiness due to timing.
* Add test for listener.filterTransport.
2024-01-04 14:19:13 -08:00
joybestourous 91d15ce4e6
Add ClientTransportFilter (#10646)
* Add ClientTransportFilter
2024-01-03 10:45:22 -08:00
Eric Anderson d6830d7f99
Change many api deps to implementation deps
These look pretty fair now, mostly only exposing grpc-api and
annotations as api dependencies.
2023-12-15 15:14:29 -08:00
Terry Wilson 8c4f4e08d9
Move Noop{Client,Server}Call from testing to api (#10753)
To help reduce cross dependencies, we move these test classes to the test
fixtures of grpc-api.
2023-12-14 23:00:30 -08:00
Eric Anderson 682d84c427 api: Remove unused grpc-core jmh dependency 2023-12-14 08:35:13 -08:00
Eric Anderson cf19263595 api: Remove test dependency on grpclb
It was just unnecessary, and is isn't great having lower-level tests
depend on higher-level packages.
2023-12-14 08:07:34 -08:00
Larry Safran e562a0558b
Remove Unused experimental API ManagedChannelBuilder.enableFullStreamDecompression. (#10744) 2023-12-12 14:56:22 -08:00
Eric Anderson c985797d90
Upgrade dependencies
All the changes outside libs.versions.toml and examples were
because of ErrorProne. It didn't actually find anything to fix; signal
vs noise has gotten pretty bad with the newer checks.

Status was changed for ErrorProne's SuperCallToObjectMethod. With the
old code it didn't notice the trivial implementation. The fail-for-test
code wasn't used, so it was easiest to just remove it.

Some of the libs had their versions inlined; now that we have
:checkForUpdates it isn't much of a risk for versions to diverge when
there's only a few artifacts sharing a version. If we need 4+ artifacts
to have the same version, then it makes sense to still use a shared
version.

Dependencies not upgraded: google-auth-libray, mockito, netty, cronet
2023-12-12 12:40:20 -08:00
yifeizhuang 7567894e67
dual stack: generic health checking (#10623)
This change has health checking consumer (new pick first) to install a listener through and health checking producer (outlier detection and client health checking) producing health checks. Health notification chain is built reusing the previous connectivity state chain.
Pickfirst installs the health listener, and is capable of detecting when no health checking producer is installed in the system. In that case, it sets health status to be READY so that health system is no-op.
2023-12-11 17:49:56 -08:00
yifeizhuang 1a0c97a7a4
util: attributs is petiole policy (#10729) 2023-12-06 13:14:26 -08:00
Eric Anderson 860b5cb1f0 api: Deprecate LoadBalancer.EMPTY_PICKER
FixedResultPicker is our preferred approach.
2023-11-21 12:57:06 -08:00
John Cormie e89389a50a
api: Clarify that NameResolver can only be started once (#10681) 2023-11-17 07:44:24 -08:00
Eric Anderson 84baad12fc inprocess: Remove InProcessNameResolver
It was introduced in 15fc70be but unused. It could be "used" from
inprocess: targets, but the in-process transport wasn't registered, so
would fail.

We do want an in-process name resolver, but we need to agree no the URI
format cross-language before we introduce it.
2023-11-10 15:48:30 -08:00
sanjaypujare 15fc70be2a
core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder (#10590)
* core, netty, okhttp: implement new logic for nameResolverFactory API in channelBuilder
fix ManagedChannelImpl to use NameResolverRegistry instead of NameResolverFactory
fix the ManagedChannelImplBuilder and remove nameResolverFactory

* Integrate target parsing and NameResolverProvider searching

Actually creating the name resolver is now delayed to the end of
ManagedChannelImpl.getNameResolver; we don't want to call into the name
resolver to determine if we should use the name resolver.

Added getDefaultScheme() to NameResolverRegistry to avoid needing
NameResolver.Factory.
---------

Co-authored-by: Eric Anderson <ejona@google.com>
2023-11-03 09:57:59 -07:00
Terry Wilson 9888a54abd
lb: acceptResolvedAddresses() to return Status (#10636)
Instead of a boolean, we now return a Status object. Status.OK
represents accepted addresses and other non-acceptance. This allows the
LB to provide more information about why a set of addresses were not
acceptable.

The status will later be sent to the name resolver as well to allow it
to also better react to to bad addresses.
2023-11-03 09:02:46 -07:00
Sergii Tkachenko a294b27d52
core: Deprecate ForwardingChannelBuilder (#10587)
Deprecate `ForwardingChannelBuilder` in favor of `ForwardingChannelBuilder2`.
2023-11-02 10:58:20 -07:00
Larry Safran 0d39bf5018
lb:Implement LeastRequestLB as a petiole policy and restore RR and WRR (#10584)
* Change LeastRequest, Round Robin and WeightedRoundRobin into petiole policies
2023-10-16 16:40:20 -07:00
Sergii Tkachenko ab8210ae0c
Stabilize forwarding builders (#10586)
- `ForwardingServerBuilder`
- `ForwardingChannelBuilder` - will be deprecated immidiatelly after
   stabilization
- `ForwardingChannelBuilder2` - should be used instead of
  `ForwardingChannelBuilder`
2023-10-06 11:18:29 -07:00
Sergii Tkachenko 0e03654add core: Remove temporary AbstractManagedChannelImplBuilder
This breaks the ABI of the classes listed below.

Users that recompiled  their code using grpc-java [`v1.36.0`]
(https://github.com/grpc/grpc-java/releases/tag/v1.36.0) (released on
Feb 23, 2021) and later, ARE NOT AFFECTED.

Users that compiled their source using grpc-java earlier than
[`v1.36.0`]
(https://github.com/grpc/grpc-java/releases/tag/v1.36.0) need to
recompile when upgrading to grpc-java `v1.59.0`. Otherwise the code
will fail on runtime with `NoSuchMethodError`. For example, code:

```java
NettyChannelBuilder.forTarget("localhost:100").maxRetryAttempts(2);
```

Will fail with

> `java.lang.NoSuchMethodError: 'io.grpc.internal.AbstractManagedChannelImplBuilder
  io.grpc.netty.NettyChannelBuilder.maxRetryAttempts(int)'`

**Affected classes**

Class `AbstractManagedChannelImplBuilder` is deleted, and no longer in
the class hierarchy of the channel builders:
- `io.grpc.netty.NettyChannelBuilder`
- `io.grpc.okhttp.OkhttpChannelBuilder`
- `grpc.cronet.CronetChannelBuilder`
2023-10-03 10:35:16 -07:00
Eric Anderson cf4cf03d79
api: Replace ErrorPicker with FixedResultPicker
FixedResultPicker can be used in more situations. Note that
WrrLocalityLoadBalancerTest's test was changed non-trivially. The
noChildLb test was particularly nasty as it assumed
LoadBalancer.ErrorPicker had same toString() as
GracefulSwitchLoadBalancer's ErrorPicker.
2023-09-26 15:28:29 -07:00
sanjaypujare 923ac60416
api: don't generate Java7 bytecode with Java 20+ (#10552)
Java 20+ don't support --release 7, so we just will use the default (8).
2023-09-11 13:41:50 -07:00
Eric Anderson b839b38b83 api: Add grpc-okhttp to suggestions if no server is available
Since 3b61799 OkHttp can support Grpc.newServerBuilderForPort().
2023-09-11 13:40:26 -07:00
yifeizhuang 6335e0be3e
core: DEADLINE_EXCEEDED gives hints for slow resolver (#10545) 2023-09-08 15:09:18 -07:00
Eric Anderson 461dc85ba6 api: Make offload executor's purpose more clear
Blocking can be confused with the blocking stub, which is unrelated. I'm
purposefully not saying "it is used only for X," as that isn't what we
need from the API. But it is still helpful to users to describe the
sorts of things that use it.

Fixes #10508
2023-09-06 07:44:35 -07:00
yifeizhuang eb18cba062
stablize ServerBuilder.handshakeTimeout (#10499) 2023-08-18 10:13:34 -07:00
Terry Wilson d987fb10aa
api: ManagedChannelBuilder note about ipv6 scope id JDK bug. (#10503)
Adds a note on how to avoid a JDK bug by converting an ipv6 scope ID to
its numeric form.
2023-08-17 18:05:15 -07:00
sanjaypujare 0fd4e3b122
api: stabilize ServerCall.getAuthority() by removing experimental annotation (#10498) 2023-08-16 18:40:18 -07:00
Tony An 93118f4075
API stabilization: getRequestMarshaller, getResponseMarshaller (#10495) 2023-08-16 15:04:49 -07:00