Skip to content

upstream_network_filter: add stats_prefix to NamedUpstreamNetworkFilterConfigFactory#37

Merged
fl0Lec merged 3 commits into
fl/upstream-rbac-stats-prefixfrom
fl/upstream-network-filter-stats-prefix
Jul 13, 2026
Merged

upstream_network_filter: add stats_prefix to NamedUpstreamNetworkFilterConfigFactory#37
fl0Lec merged 3 commits into
fl/upstream-rbac-stats-prefixfrom
fl/upstream-network-filter-stats-prefix

Conversation

@fl0Lec

@fl0Lec fl0Lec commented Jul 13, 2026

Copy link
Copy Markdown

Context

Follow-up to envoyproxy#45987. The reviewer asked to use serverScope() for upstream_context_ and pass "cluster.<name>." explicitly as stats_prefix, mirroring the router pattern. The problem: upstream_context_ is shared by both network and HTTP filter factories, and the network filter API has no stats_prefix parameter — any filter calling context.scope() directly would get root scope and emit unnamespaced stats.

This PR

Adds stats_prefix to NamedUpstreamNetworkFilterConfigFactory::createFilterFactoryFromProto, bringing it in line with the HTTP filter API. Both network and HTTP filter factories now receive "cluster.<name>." explicitly, and upstream_context_ can cleanly use serverScope().

Changes

  • envoy/server/filter_config.h: add stats_prefix to NamedUpstreamNetworkFilterConfigFactory. A 2-arg convenience overload (delegating with "") keeps the ECDS dynamic path compiling pending a follow-up to thread stats_prefix through FilterConfigProviderManagerImpl.
  • source/extensions/bootstrap/reverse_tunnel/: update the only production implementation (ignores stats_prefix, no behaviour change).
  • source/common/upstream/upstream_impl.cc: switch upstream_context_ to serverScope(), pass "cluster.<name>." for both network and HTTP filter creation.
  • source/common/filter/config_discovery_impl.h: override instantiateFilterFactory in UpstreamNetworkDynamicFilterConfigProviderImpl with a TODO for the ECDS path.
  • test/integration/idle_timeout_integration_test.cc: test filter updated to create a subscope from stats_prefix.

Known limitation

ECDS dynamic upstream network filters still receive stats_prefix="" via the 2-arg convenience overload. Full fix requires threading stats_prefix through FilterConfigProviderManagerImpl::createDynamicFilterConfigProvider — left as a follow-up.

…erConfigFactory

Add a stats_prefix parameter to createFilterFactoryFromProto on
NamedUpstreamNetworkFilterConfigFactory, mirroring the upstream HTTP filter API.
This allows upstream_impl.cc to pass 'cluster.<name>.' explicitly so network filters
can emit stats under the cluster namespace even when upstream_context_ uses root scope.

A 2-arg convenience overload is kept for the ECDS dynamic path which hasn't been
updated to thread stats_prefix through yet (TODO in UpstreamNetworkDynamicFilterConfigProviderImpl).

Signed-off-by: Florent Lecoultre <florent.lecoultre@datadoghq.com>
@fl0Lec
fl0Lec changed the base branch from fl/upstream-rbac-stats-prefix to master July 13, 2026 14:53
@fl0Lec
fl0Lec changed the base branch from master to fl/upstream-rbac-stats-prefix July 13, 2026 14:54
fl0Lec added 2 commits July 13, 2026 15:01
…erride

The 2-arg convenience overload on NamedUpstreamNetworkFilterConfigFactory already
handles the base class call in NetworkDynamicFilterConfigProviderImplBase. The
override in config_discovery_impl.h was doing exactly the same thing. Move the
TODO to filter_config.h where the actual gap lives.

Signed-off-by: Florent Lecoultre <florent.lecoultre@datadoghq.com>
…re with default delegation

The 2-arg createFilterFactoryFromProto remains PURE so all existing implementations
continue to compile without any change. The new 3-arg overload (with stats_prefix)
is non-pure virtual and defaults to calling the 2-arg form, allowing callers like
upstream_impl to pass an explicit "cluster.<name>." prefix while backward-compatible
filters (including reverse_tunnel) need not be touched.

Reverts the reverse_tunnel signature change from the previous commit.

Signed-off-by: Florent Lecoultre <florent.lecoultre@datadoghq.com>
@fl0Lec
fl0Lec merged commit c720d68 into fl/upstream-rbac-stats-prefix Jul 13, 2026
@fl0Lec
fl0Lec deleted the fl/upstream-network-filter-stats-prefix branch July 13, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant