forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.go
44 lines (34 loc) · 1012 Bytes
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package scraper // import "go.opentelemetry.io/collector/scraper"
import (
"context"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/pdata/plog"
)
// Logs is the base interface for logs scrapers.
type Logs interface {
component.Component
// ScrapeLogs is the base interface to indicate that how should logs be scraped.
ScrapeLogs(context.Context) (plog.Logs, error)
}
// ScrapeLogsFunc is a helper function that is similar to Logs.ScrapeLogs.
type ScrapeLogsFunc ScrapeFunc[plog.Logs]
func (sf ScrapeLogsFunc) ScrapeLogs(ctx context.Context) (plog.Logs, error) {
return sf(ctx)
}
type logs struct {
baseScraper
ScrapeLogsFunc
}
// NewLogs creates a new Logs scraper.
func NewLogs(scrape ScrapeLogsFunc, options ...Option) (Logs, error) {
if scrape == nil {
return nil, errNilFunc
}
bs := &logs{
baseScraper: newBaseScraper(options),
ScrapeLogsFunc: scrape,
}
return bs, nil
}