Skip to content

Introduce granular (service selector) export modes #276

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

rafaelroquetto
Copy link
Contributor

@rafaelroquetto rafaelroquetto commented Jul 8, 2025

Introduce a per service-selector export mode. This allows individual selectors to specify whether they want to:

  • export metrics only (exports: [metrics])
  • export traces only (exports: [traces])
  • export both metrics and traces (exports: [metrics, traces])
  • export nothing (exports: [])
  • use the default behaviour (exports: not present / nil)

The selection criteria are applied in order of appearance. For example, consider the following sample configuration for discovering a service called planet-service which lives in the default namespace:

discovery:
  services:
    - k8s_namespace: default              #(1)
      exports: [metrics]
    - k8s_deployment_name: planet-service #(2)
      exports: [traces]

Because selectors are processed in sequential order of appearance (selector 2 appears after selector 1), the resulting configuration will only enable traces export for planet-service. Whilst this PR only adds a new export attribute, this paves the road for future attributes to be added and allows for configurations to be stacked. For instance, we can decide to export metrics and traces for the entire default namespace, except for planet-service, which exports metrics only:

discovery:
  services:
    - k8s_namespace: default              #(1)
      exports: [metrics, traces]
    - k8s_deployment_name: planet-service #(2)
      exports: [metrics]

Omitting the exports attribute falls back to the conventional behaviour that relies on variables such as OTEL_EXPORTER_OTLP_ENDPOINT, i.e. they are orthogonal (unless of course the same service has been matched by a previous selector, as in the examples above). For instance, if a service selector specifies export: traces but no trace endpoint is defined, then obviously no traces will be generated.

This PR is best reviewed on a per-commit basis

@rafaelroquetto rafaelroquetto changed the title WIP: Introduce granular (service selector) export modes [WIP]: Introduce granular (service selector) export modes Jul 8, 2025
Copy link

codecov bot commented Jul 9, 2025

Codecov Report

Attention: Patch coverage is 85.29412% with 15 lines in your changes missing coverage. Please review.

Project coverage is 77.07%. Comparing base (fd41fc4) to head (e60360f).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/services/criteria.go 58.62% 12 Missing ⚠️
pkg/export/prom/prom.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #276      +/-   ##
==========================================
+ Coverage   72.04%   77.07%   +5.02%     
==========================================
  Files         181      181              
  Lines       19742    19820      +78     
==========================================
+ Hits        14224    15276    +1052     
+ Misses       4731     3756     -975     
- Partials      787      788       +1     
Flag Coverage Δ
integration-test 57.12% <78.43%> (+1.04%) ⬆️
integration-test-arm 35.36% <67.64%> (+0.39%) ⬆️
k8s-integration-test 51.86% <59.80%> (?)
oats-test 35.57% <59.80%> (+0.07%) ⬆️
unittests 47.19% <72.54%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rafaelroquetto rafaelroquetto force-pushed the discovery branch 4 times, most recently from cb3e211 to a53ceba Compare July 10, 2025 00:46
@rafaelroquetto rafaelroquetto force-pushed the discovery branch 5 times, most recently from 5201152 to 3528433 Compare July 10, 2025 23:02
@rafaelroquetto rafaelroquetto marked this pull request as ready for review July 11, 2025 21:01
@rafaelroquetto rafaelroquetto requested a review from a team as a code owner July 11, 2025 21:01
@rafaelroquetto rafaelroquetto changed the title [WIP]: Introduce granular (service selector) export modes Introduce granular (service selector) export modes Jul 11, 2025
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.

2 participants