Skip to content

Commit

Permalink
use defaults and set maxConnLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsanmi committed Oct 23, 2024
1 parent 86c3b18 commit 64df29d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: pyroscope.receive_http

# pyroscope.receive_http

`pyroscope.receive_http` listens for HTTP requests containing profiles and forwards them to other components capable of receiving profiles.
`pyroscope.receive_http` receives profiles over HTTP and forwards them to `pyroscope.*` components capable of receiving profiles.

The HTTP API exposed is compatible with the Pyroscope [HTTP ingest API](https://grafana.com/docs/pyroscope/latest/configure-server/about-server-api/).
This allows `pyroscope.receive_http` to act as a proxy for Pyroscope profiles, enabling flexible routing and distribution of profile data.
Expand Down
17 changes: 14 additions & 3 deletions internal/component/pyroscope/receive_http/receive_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ import (
"github.com/grafana/alloy/internal/runtime/logging/level"
)

const (
// defaultMaxConnLimit defines the maximum number of simultaneous HTTP connections
defaultMaxConnLimit = 100
)

func init() {
component.Register(component.Registration{
Name: "pyroscope.receive_http",
Stability: featuregate.StabilityGenerallyAvailable,
Stability: featuregate.StabilityPublicPreview,
Args: Arguments{},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand All @@ -37,8 +42,12 @@ type Arguments struct {

// SetToDefault implements syntax.Defaulter.
func (a *Arguments) SetToDefault() {
serverConfig := fnet.DefaultServerConfig()
if serverConfig.HTTP.ConnLimit > defaultMaxConnLimit {
serverConfig.HTTP.ConnLimit = defaultMaxConnLimit
}
*a = Arguments{
Server: fnet.DefaultServerConfig(),
Server: serverConfig,
}
}

Expand Down Expand Up @@ -82,9 +91,11 @@ func (c *Component) Update(args component.Arguments) error {

c.appendables = newArgs.ForwardTo

// if no server config provided, we'll use defaults
if newArgs.Server == nil {
newArgs.Server = fnet.DefaultServerConfig()
newArgs.Server = &fnet.ServerConfig{}
}

if newArgs.Server.HTTP == nil {
newArgs.Server.HTTP = &fnet.HTTPConfig{
ListenPort: 0,
Expand Down

0 comments on commit 64df29d

Please sign in to comment.