-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a component for faro.reciever, an equivalent to the app_agent_receiver integration from static mode. This is not 100% a straight port from the existing integration. I have done some minor refactoring to make it possible for this component to be dynamically updateable at runtime. However, the implementation remains mostly the same. During my porting, I have noticed bugs in integration, particularly around sourcemaps. I have not fixed these, but I have added TODO comments in the code for them to be resolved down the line. Unfortunately, the resulting code is quite complex. Future changes to refactor it to make it easier to read are warranted, but it would likely require more code and would drift further from the original integration. In the spirit of this being a "port," such changes are not included here. Supersedes #5243 Closes #2320 Co-authored-by: CRA Keishi Kawada <[email protected]> Co-authored-by: mattdurham <[email protected]> Co-authored-by: Clayton Cornell <[email protected]> Co-authored-by: Paschalis Tsilias <[email protected]>
- Loading branch information
1 parent
2b4e368
commit 0aeca59
Showing
20 changed files
with
3,896 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package receiver | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/alecthomas/units" | ||
"github.com/grafana/agent/component/common/loki" | ||
"github.com/grafana/agent/component/otelcol" | ||
"github.com/grafana/river" | ||
"github.com/grafana/river/rivertypes" | ||
) | ||
|
||
// Defaults for various arguments. | ||
var ( | ||
DefaultArguments = Arguments{ | ||
Server: DefaultServerArguments, | ||
SourceMaps: DefaultSourceMapsArguments, | ||
} | ||
|
||
DefaultServerArguments = ServerArguments{ | ||
Host: "127.0.0.1", | ||
Port: 12347, | ||
RateLimiting: DefaultRateLimitingArguments, | ||
MaxAllowedPayloadSize: 5 * units.MiB, | ||
} | ||
|
||
DefaultRateLimitingArguments = RateLimitingArguments{ | ||
Enabled: true, | ||
Rate: 50, | ||
BurstSize: 100, | ||
} | ||
|
||
DefaultSourceMapsArguments = SourceMapsArguments{ | ||
Download: true, | ||
DownloadFromOrigins: []string{"*"}, | ||
DownloadTimeout: time.Second, | ||
} | ||
) | ||
|
||
// Arguments configures the app_agent_receiver component. | ||
type Arguments struct { | ||
LogLabels map[string]string `river:"extra_log_labels,attr,optional"` | ||
|
||
Server ServerArguments `river:"server,block,optional"` | ||
SourceMaps SourceMapsArguments `river:"sourcemaps,block,optional"` | ||
Output OutputArguments `river:"output,block"` | ||
} | ||
|
||
var _ river.Defaulter = (*Arguments)(nil) | ||
|
||
// SetToDefault applies default settings. | ||
func (args *Arguments) SetToDefault() { *args = DefaultArguments } | ||
|
||
// ServerArguments configures the HTTP server where telemetry information will | ||
// be sent from Faro clients. | ||
type ServerArguments struct { | ||
Host string `river:"listen_address,attr,optional"` | ||
Port int `river:"listen_port,attr,optional"` | ||
CORSAllowedOrigins []string `river:"cors_allowed_origins,attr,optional"` | ||
APIKey rivertypes.Secret `river:"api_key,attr,optional"` | ||
MaxAllowedPayloadSize units.Base2Bytes `river:"max_allowed_payload_size,attr,optional"` | ||
|
||
RateLimiting RateLimitingArguments `river:"rate_limiting,block,optional"` | ||
} | ||
|
||
// RateLimitingArguments configures rate limiting for the HTTP server. | ||
type RateLimitingArguments struct { | ||
Enabled bool `river:"enabled,attr,optional"` | ||
Rate float64 `river:"rate,attr,optional"` | ||
BurstSize float64 `river:"burst_size,attr,optional"` | ||
} | ||
|
||
// SourceMapsArguments configures how app_agent_receiver will retrieve source | ||
// maps for transforming stack traces. | ||
type SourceMapsArguments struct { | ||
Download bool `river:"download,attr,optional"` | ||
DownloadFromOrigins []string `river:"download_from_origins,attr,optional"` | ||
DownloadTimeout time.Duration `river:"download_timeout,attr,optional"` | ||
Locations []LocationArguments `river:"location,block,optional"` | ||
} | ||
|
||
// LocationArguments specifies an individual location where source maps will be loaded. | ||
type LocationArguments struct { | ||
Path string `river:"path,attr"` | ||
MinifiedPathPrefix string `river:"minified_path_prefix,attr"` | ||
} | ||
|
||
// OutputArguments configures where to send emitted logs and traces. Metrics | ||
// emitted by app_agent_receiver are exported as targets to be scraped. | ||
type OutputArguments struct { | ||
Logs []loki.LogsReceiver `river:"logs,attr,optional"` | ||
Traces []otelcol.Consumer `river:"traces,attr,optional"` | ||
} |
Oops, something went wrong.