Skip to content

feat(flow-php/telemetry): attribute filtering, log pipeline, and attribute-matching sampler#2437

Merged
norberttech merged 3 commits into
1.xfrom
2390-task-flow-phptelemetry---processor-that-can-filter-by-attributes
Jun 8, 2026
Merged

feat(flow-php/telemetry): attribute filtering, log pipeline, and attribute-matching sampler#2437
norberttech merged 3 commits into
1.xfrom
2390-task-flow-phptelemetry---processor-that-can-filter-by-attributes

Conversation

@norberttech

Copy link
Copy Markdown
Member

Resolves: #2390

Change Log


Added

  • flow-php/telemetry - attribute filter with compiled matcher tree (rule/all/any/not)
  • flow-php/telemetry - attribute filtering processors for spans and metrics
  • flow-php/telemetry - log pipeline with enrich/filter/severity middleware and a sink
  • flow-php/telemetry - attribute matching sampler and DSL functions for all samplers
  • flow-php/telemetry - per-scope signal attributes merged into every signal
  • flow-php/symfony-telemetry-bundle - config for filtering, log pipeline, sampler and logging channels

Fixed

Changed

  • flow-php/symfony-telemetry-bundle - named scope attributes split into scope and signal

Removed

  • flow-php/telemetry - SeverityFilteringLogProcessor replaced by log middleware and pipeline
  • flow-php/symfony-telemetry-bundle - severity_filtering log processor type replaced by pipeline

Deprecated

Security

# config/packages/flow_telemetry.yaml
flow_telemetry:
  resource:
    custom:
      service.name: checkout-api

  exporters:
    otlp:
      otlp:
        transport:
          type: curl
          endpoint: 'http://otel-collector:4318'

  # ── Spans ── drop noise at the sampler (decided at span start, never recorded)
  tracer_provider:
    sampler:
      type: attribute_matching
      # compiled to a cached PHP matcher, owner-only by default
      cache_dir: '%kernel.cache_dir%/flow_telemetry_filters'
      cache_dir_permissions: 0o750
      matcher:
        any:
          - { path: http.route, mode: equal, value: /health }
          - { path: http.route, mode: starts_with, value: /ready }
      delegate:
        type: trace_id_ratio   # everything else: 10% head sampling
        ratio: 0.1
    processor:
      type: batching
      exporter: otlp

  # ── Logs ── enrich, then filter, then batch (a compiled pipeline of middleware)
  logger_provider:
    processor:
      type: pipeline
      middleware:
        - type: enriching
          attributes: { deployment.environment: prod }
        - { type: severity_filtering, minimum_severity: info }
        - type: attribute_filtering
          # deeply nested matcher, compiled to a single cached closure
          cache_dir: '%kernel.cache_dir%/flow_telemetry_filters'
          cache_dir_permissions: 0o750
          matcher:
            any:
              - { path: http.route, mode: equal, value: /health }
              - all:
                  - { path: http.user_agent, mode: contains, value: bot, case_sensitive: false }
                  - not: { path: audit, mode: equal, value: true }
      sink:
        type: batching
        exporter: otlp

What this demonstrates:

  • Logs — a pipeline of ordered middleware (enriching → severity_filtering → attribute_filtering) ending in a batching sink; dropped records short-circuit before batching.
  • Spans — attribute_matching sampler drops /health & /ready at span start (so they never record), and defers everything else to 10% ratio sampling.
  • Compilation — every matcher (including the nested any/all/not) compiles to one cached PHP closure under cache_dir, created with cache_dir_permissions (default 0o700).
  • Nesting — (http.user_agent contains "bot" AND NOT audit) OR http.route = /health in a single filter.

…ibute-matching sampler

- add Filter matcher tree (rule/all/any/not) compiled to a cached
closure
- add attribute-filtering processors for spans and metrics
- replace SeverityFilteringLogProcessor with LogMiddleware +
PipelineLogProcessor
- add AttributeFilteringLogMiddleware, SeverityFilteringLogMiddleware,
EnrichingLogMiddleware
- add AttributeMatchingSampler and DSL functions for all samplers
- merge per-scope signal attributes into every emitted signal
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.30337% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.18%. Comparing base (6bfba82) to head (9ef253d).
⚠️ Report is 22 commits behind head on 1.x.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x    #2437      +/-   ##
============================================
+ Coverage     84.94%   85.18%   +0.23%     
- Complexity    20648    20942     +294     
============================================
  Files          1570     1587      +17     
  Lines         63532    64514     +982     
============================================
+ Hits          53968    54957     +989     
+ Misses         9564     9557       -7     
Components Coverage Δ
etl 89.35% <ø> (ø)
cli 89.40% <ø> (ø)
lib-array-dot 81.44% <ø> (ø)
lib-azure-sdk 64.44% <ø> (ø)
lib-doctrine-dbal-bulk 93.61% <ø> (ø)
lib-filesystem 85.03% <ø> (ø)
lib-types 91.98% <ø> (ø)
lib-parquet 68.89% <14.28%> (ø)
lib-parquet-viewer 82.26% <ø> (ø)
lib-snappy 89.82% <ø> (-0.45%) ⬇️
lib-dremel 0.00% <ø> (ø)
lib-postgresql 88.58% <33.33%> (+<0.01%) ⬆️
lib-telemetry 86.28% <100.00%> (+1.96%) ⬆️
bridge-filesystem-async-aws 92.74% <ø> (ø)
bridge-filesystem-azure 90.45% <ø> (ø)
bridge-monolog-http 97.86% <ø> (ø)
bridge-monolog-telemetry 94.11% <ø> (ø)
bridge-openapi-specification 92.07% <ø> (ø)
symfony-http-foundation 78.57% <ø> (ø)
bridge-psr18-telemetry 100.00% <ø> (ø)
bridge-psr3-telemetry 97.84% <ø> (ø)
bridge-psr7-telemetry 100.00% <ø> (ø)
bridge-telemetry-otlp 90.50% <ø> (ø)
bridge-symfony-http-foundation-telemetry 89.47% <ø> (ø)
bridge-symfony-filesystem-bundle 91.54% <100.00%> (ø)
bridge-symfony-filesystem-cache 98.14% <ø> (ø)
bridge-symfony-postgresql-bundle 94.55% <ø> (ø)
bridge-symfony-postgresql-cache 94.41% <ø> (ø)
bridge-symfony-postgresql-messenger 98.80% <ø> (ø)
bridge-symfony-postgresql-session 93.65% <ø> (ø)
bridge-symfony-telemetry-bundle 79.76% <95.34%> (+3.75%) ⬆️
adapter-chartjs 84.05% <ø> (ø)
adapter-csv 91.16% <ø> (ø)
adapter-doctrine 90.79% <ø> (ø)
adapter-elasticsearch 92.07% <ø> (ø)
adapter-google-sheet 99.18% <ø> (ø)
adapter-http 73.04% <ø> (ø)
adapter-json 88.63% <ø> (ø)
adapter-logger 50.00% <ø> (ø)
adapter-parquet 81.75% <ø> (ø)
adapter-text 74.13% <ø> (ø)
adapter-xml 83.40% <ø> (ø)
adapter-avro 0.00% <ø> (ø)
adapter-excel 94.21% <ø> (ø)
adapter-postgresql 91.42% <95.74%> (+0.53%) ⬆️
bridge-phpunit-postgresql 75.30% <ø> (ø)
bridge-phpunit-telemetry 80.09% <ø> (ø)
bridge-phpstan-types 0.00% <ø> (ø)
bridge-postgresql-valinor 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@norberttech norberttech merged commit 72b80ef into 1.x Jun 8, 2026
37 of 39 checks passed
@norberttech norberttech deleted the 2390-task-flow-phptelemetry---processor-that-can-filter-by-attributes branch June 8, 2026 14:52
@norberttech norberttech added this to the 0.40.0 milestone Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Task]: flow-php/telemetry - Processor that can filter by attributes

1 participant