Skip to content

Conversation

@gracewehner
Copy link
Contributor

@gracewehner gracewehner commented Jun 20, 2025

@gracewehner gracewehner requested a review from Copilot July 10, 2025 22:13

This comment was marked as outdated.

@gracewehner gracewehner requested a review from Copilot July 18, 2025 18:27
Copy link

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 aims to simplify the process of adding new default scrape configurations by consolidating scattered configuration definitions and logic into a centralized data structure. The refactoring centralizes job definitions, default values, and configuration logic into a single location.

Key changes include:

  • Centralized all default scrape job configurations into a shared data structure
  • Simplified configuration parsing by using the centralized definitions
  • Refactored error handling to be more lenient (log and continue vs fail)

Reviewed Changes

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

Show a summary per file
File Description
otelcollector/shared/definitions.go New file containing centralized default scrape job configurations and constants
otelcollector/shared/helpers.go Modified error handling in file parsing to log errors and continue
otelcollector/shared/go.mod Updated dependencies and added new required packages
otelcollector/shared/configmap/mp/tomlparser-*.go Refactored configuration parsing to use centralized definitions
Various test files Updated test files and removed obsolete test files
Comments suppressed due to low confidence (2)

otelcollector/shared/configmap/mp/tomlparser-opentelemetry-metrics.go:14

  • The function name 'populateOpentelemetryMetricsSettingValuesFromConfigMap' is inconsistent with the function being called. The original code calls 'populateSettingValuesFromConfigMap' but the new code calls a different function name.
	enabled := populateOpentelemetryMetricsSettingValuesFromConfigMap(metricsConfigBySection)

otelcollector/shared/configmap/mp/tomlparser-opentelemetry-metrics.go:41

  • [nitpick] The error message format is improved but uses inconsistent variable reference. The original code referenced 'enabled' but now references 'err.Error()' which provides better context.
			fmt.Printf("Invalid value for opentelemetry-metrics enabled: %s, defaulting to %v\n", err.Error(), enabled)

file, err := os.Open(filePath)
if err != nil {
return nil, fmt.Errorf("failed to open file %s: %w", filePath, err)
fmt.Printf("failed to open file %s: %v\n", filePath, err)
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

The error message format is inconsistent with the original error handling pattern. Consider using a more descriptive error message that explains the impact of the failure.

Suggested change
fmt.Printf("failed to open file %s: %v\n", filePath, err)
log.Printf("error: failed to open file %s: %v. Skipping this file.", filePath, err)

Copilot uses AI. Check for mistakes.
return err
}
return nil
return os.WriteFile(filePath, out, 0644)
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

The file permissions are hardcoded as 0644. Consider using a constant or fs.FileMode for better maintainability and consistency.

Suggested change
return os.WriteFile(filePath, out, 0644)
return os.WriteFile(filePath, out, defaultFilePermissions)

Copilot uses AI. Check for mistakes.
job.KeepListRegex = job.CustomerKeepListRegex + job.KeepListRegex
}

fmt.Printf("Parsed config map for default-targets-metrics-keep-list successfully\n")
Copy link

Copilot AI Jul 18, 2025

Choose a reason for hiding this comment

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

[nitpick] The success message is not consistent with error handling patterns in the codebase. Consider using a more structured logging approach or removing this debug message.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

This PR is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2025

This PR is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants