feat(scraper): bound article enrichment diagnostics (#40)

This commit is contained in:
2026-11-25 00:07:45 +01:00
parent a3c70670f6
commit 6883b3976b
53 changed files with 4049 additions and 68 deletions

View File

@ -30,7 +30,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
Username string `json:"username"`
Password string `json:"password"`
URLs []string `json:"urls"`
}{username, password, urls})
Measure bool `json:"measure_fetches,omitempty"`
}{username, password, urls, scraper.FetchMetricsEnabled(ctx)})
req, err := http.NewRequestWithContext(ctx, http.MethodPost, b.scraperURL+"/bloomberg/enrich", bytes.NewReader(payload))
if err != nil {
return nil, errors.New("bloomberg: enrichment request failed")
@ -53,7 +54,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
return nil, errors.New("bloomberg: enrichment response too large")
}
var result struct {
Articles []struct {
FetchMetrics *scraper.FetchMetrics `json:"fetch_metrics"`
Articles []struct {
ContentState string `json:"content_state"`
URL string `json:"url"`
Content string `json:"content"`
@ -89,5 +91,8 @@ func (b *Bloomberg) EnrichWithCredentials(ctx context.Context, username, passwor
}
}
}
if result.FetchMetrics != nil {
scraper.MergeFetchMetrics(ctx, *result.FetchMetrics, len(out))
}
return out, nil
}