Skip to content

Conversation

@jerm-dro
Copy link
Contributor

@jerm-dro jerm-dro commented Dec 4, 2025

Summary

This pull request refactors the existing logic of AddTelemetryConfigOptions so the conversion from mcpv1alpha1.TelemetryConfig to telemetry.Config is reusable without having to create a RunConfigBuilderOption.

I'd like to reuse just this conversion logic within #2906, so the vMCP CRD uses the same exact telemetry type as the MCP Proxy, etc.

This PR isn't small but it's mostly just moving code to places that make it more composable.

Implementation Details

  • Moved the telemetry.Config construction logic that was within WithTelemetryConfig to telemetry.MaybeMakeConfig.
  • Renamed WithTelemetryConfig to WithTelemetryConfigFlags which behaves just as before.
  • Created WithTelemetryConfig which just assign the given telemetry config.
  • Created spectoconfig/telemetry.go (pronounced "Spec To Config" other names welcome) which contains ConvertTelemetryConfig. ConvertTelemetryConfig is exactly the same as AddTelemetryConfigOptions minus creating the option.

@github-actions github-actions bot added the size/S Small PR: 100-299 lines changed label Dec 4, 2025
@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 20.00000% with 76 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.26%. Comparing base (55d0cee) to head (0899abd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/thv-operator/pkg/spectoconfig/telemetry.go 0.00% 47 Missing ⚠️
pkg/telemetry/config.go 0.00% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2908      +/-   ##
==========================================
- Coverage   56.39%   56.26%   -0.14%     
==========================================
  Files         322      323       +1     
  Lines       31622    31640      +18     
==========================================
- Hits        17834    17801      -33     
- Misses      12257    12308      +51     
  Partials     1531     1531              

☔ 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.

@jerm-dro jerm-dro changed the title Refactor CRD Telmetry Config Conversion for Reusability WIP: Refactor CRD Telmetry Config Conversion for Reusability Dec 4, 2025
Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
@jerm-dro jerm-dro force-pushed the jerm/jerm/refactor-telemetry-conversion branch from 9419346 to 0899abd Compare December 4, 2025 22:34
@github-actions github-actions bot added size/M Medium PR: 300-599 lines changed and removed size/S Small PR: 100-299 lines changed labels Dec 4, 2025
@jerm-dro jerm-dro requested a review from Copilot December 4, 2025 22:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors telemetry configuration conversion logic to improve code reusability. It extracts the conversion logic from WithTelemetryConfig into standalone functions (MaybeMakeConfig and ConvertTelemetryConfig) that can be used independently, particularly for integration with the vMCP CRD in PR #2906.

Key changes:

  • Created telemetry.MaybeMakeConfig() to handle the core telemetry config construction logic from individual parameters
  • Renamed WithTelemetryConfig() to WithTelemetryConfigFromFlags() and created a new WithTelemetryConfig() that accepts a pre-built config
  • Introduced spectoconfig package with ConvertTelemetryConfig() to convert CRD TelemetryConfig to telemetry.Config

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/telemetry/config.go Added MaybeMakeConfig() function to create telemetry configuration from individual parameters
pkg/runner/config_builder.go Renamed WithTelemetryConfig to WithTelemetryConfigFromFlags, created new WithTelemetryConfig that accepts config directly
cmd/thv-operator/pkg/spectoconfig/telemetry.go New package/file containing ConvertTelemetryConfig() to convert CRD types to telemetry.Config
cmd/thv-operator/pkg/runconfig/telemetry.go Simplified to use spectoconfig.ConvertTelemetryConfig() instead of inline conversion logic
pkg/runner/config_test.go Updated all test calls from WithTelemetryConfig to WithTelemetryConfigFromFlags
pkg/api/v1/workload_service.go Updated function call to use WithTelemetryConfigFromFlags
cmd/thv/app/run_flags.go Updated function call to use WithTelemetryConfigFromFlags

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jerm-dro jerm-dro changed the title WIP: Refactor CRD Telmetry Config Conversion for Reusability WIP: Refactor CRD Telemetry Config Conversion for Reusability Dec 4, 2025
@jerm-dro jerm-dro changed the title WIP: Refactor CRD Telemetry Config Conversion for Reusability Refactor CRD Telemetry Config Conversion for Reusability Dec 4, 2025
@jerm-dro jerm-dro merged commit 6cf23d4 into main Dec 4, 2025
56 of 60 checks passed
@jerm-dro jerm-dro deleted the jerm/jerm/refactor-telemetry-conversion branch December 4, 2025 23:09
carlos-gn pushed a commit to carlos-gn/toolhive that referenced this pull request Dec 8, 2025
Refactor CRD Telmetry Config Conversion for Reusability

- Moved the telemetry.Config construction logic that was within WithTelemetryConfig to telemetry.MaybeMakeConfig.
- Renamed WithTelemetryConfig to WithTelemetryConfigFlags which behaves just as before.
- Created WithTelemetryConfig which just assign the given telemetry config.
- Created spectoconfig/telemetry.go (pronounced "Spec To Config" other names welcome) which contains ConvertTelemetryConfig. ConvertTelemetryConfig is exactly the same as AddTelemetryConfigOptions minus creating the option.

Signed-off-by: Jeremy Drouillard <jeremy@stacklok.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants