You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(zcsazzurro): migrate the receiver to the collector/scraper framework (#120)
## Problem
The zcsazzurro receiver was using a custom scraping implementation with
manual goroutines and tickers, while the wavinsentio receiver was
already using the standardized OpenTelemetry collector/scraper
framework. This inconsistency made the codebase harder to maintain and
prevented the project from having a unified scraping approach.
## Solution
Migrated the zcsazzurro receiver to use the OpenTelemetry
collector/scraper framework (`go.opentelemetry.io/collector/scraper` and
`go.opentelemetry.io/collector/scraper/scraperhelper`), bringing it in
line with the wavinsentio receiver implementation.
## Changes Made
### Configuration Updates
- Updated `Config` struct to embed `scraperhelper.ControllerConfig`
instead of custom `Interval` field
- Modified validation logic to use `CollectionInterval` with
`MinCollectionInterval` constant
- Maintains the same 30-second minimum interval requirement with
improved error messaging
### Factory Refactoring
- Replaced custom receiver creation with
`scraperhelper.NewMetricsController`
- Updated imports to include scraper framework dependencies
- Integrated with existing metadata generation system
### Scraper Implementation
- Created new `zcsazzurroScraper` struct implementing the
collector/scraper interface
- Implemented required methods:
- `scrape(context.Context) (pmetric.Metrics, error)` - main scraping
logic
- `start(context.Context, component.Host) error` - initialization logic
- Preserved all existing functionality:
- Cache-based deduplication logic (`shouldProcessThing`,
`updateThingState`)
- Data processing and marshaling with `azzurroRealtimeDataMarshaler`
- Error handling and logging patterns
### Legacy Code Removal
- Removed `receiver.go` containing the custom receiver implementation
- Cleaned up unused goroutine and ticker-based polling logic
- Maintained backward compatibility for configuration and behavior
## Benefits
1. **Unified Framework**: Both receivers now use the same OpenTelemetry
scraping framework
2. **Consistency**: Configuration and lifecycle management follow
standard patterns
3. **Maintainability**: Reduced custom code in favor of well-tested
framework components
4. **Performance**: Leverages optimized scraper controller
implementation
5. **Future-Proof**: Easier to adopt new collector framework features
and updates
## Verification
- All component lifecycle tests pass
- Configuration validation works correctly with new structure
- Existing functionality preserved (caching, deduplication, data
processing)
- No breaking changes to external interfaces or behavior
The migration achieves the goal stated in the issue: "Unified scraping
framework across all receivers" while maintaining full backward
compatibility.
<!-- START COPILOT CODING AGENT SUFFIX -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>feat(zcsazzurro): migrate the receiver to the
collector/scraper</issue_title>
> <issue_description>## Context
> <!-- Provide context on what needs to be done. -->
>
> The wavinsentio receiver is using the
https://github.com/open-telemetry/opentelemetry-collector/tree/main/scraper
framework to scrape metrics from the Wavin Sentio API.
>
> The zcsazzurro reciver is also scraping metrics fom the ZCS API,
however it's using a custom scraping framework.
>
> ## Goal
> <!-- Describe the goal we aim to achieve by doing this task. -->
>
> Migrate tee zcsazzurro receiver to use
https://github.com/open-telemetry/opentelemetry-collector/tree/main/scraper
>
> ## Impact
>
> <!-- Describe the foresaw impact of doing/NOT doing this work. This
should guide you in choosing an appropriate "impact" label: the higher
the impact/risk of achieving or not achieving the goal, the higher
impact label should be. -->
>
> - Unified scraping framework across all receivers</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
Fixes#119
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 Share your feedback on Copilot coding agent for the chance to win a
$200 gift card! Click
[here](https://survey3.medallia.com/?EAHeSx-AP01bZqG0Ld9QLQ) to start
the survey.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: zmoog <[email protected]>
Co-authored-by: Maurizio Branca <[email protected]>
0 commit comments