-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[receiver/tcplog] Add metrics to track payload size and connections created/closed #45204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: enhancement | ||
|
|
||
| # The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) | ||
| component: receiver/tcplog | ||
|
|
||
| # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
| note: Add new metrics to track incoming connections and payload size in the tcplog receiver | ||
|
|
||
| # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
| issues: [45146] | ||
|
|
||
| # (Optional) One or more lines of additional information to render under the primary note. | ||
| # These lines will be padded with 2 spaces and then inserted directly into the document. | ||
| # Use pipe (|) for multiline entries. | ||
| subtext: | ||
|
|
||
| # If your change doesn't affect end users or the exported elements of any package, | ||
| # you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
| # Optional: The change log or logs in which this entry should be included. | ||
| # e.g. '[user]' or '[user, api]' | ||
| # Include 'user' if the change is relevant to end users. | ||
| # Include 'api' if there is a change to a library API. | ||
| # Default: '[user]' | ||
| change_logs: [user] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ import ( | |||||||||||||||||
| "github.com/jpillora/backoff" | ||||||||||||||||||
| "go.opentelemetry.io/collector/component" | ||||||||||||||||||
| "go.opentelemetry.io/collector/config/configtls" | ||||||||||||||||||
| "go.opentelemetry.io/otel/metric" | ||||||||||||||||||
| "golang.org/x/text/encoding" | ||||||||||||||||||
|
|
||||||||||||||||||
| "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/textutils" | ||||||||||||||||||
|
|
@@ -72,6 +73,11 @@ type BaseConfig struct { | |||||||||||||||||
| SplitConfig split.Config `mapstructure:"multiline,omitempty"` | ||||||||||||||||||
| TrimConfig trim.Config `mapstructure:",squash"` | ||||||||||||||||||
| SplitFuncBuilder SplitFuncBuilder `mapstructure:"-"` | ||||||||||||||||||
| Metrics MetricsConfig `mapstructure:"metrics,omitempty"` | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| type MetricsConfig struct { | ||||||||||||||||||
| Enabled bool `mapstructure:"enabled,omitempty"` | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| type SplitFuncBuilder func(enc encoding.Encoding) (bufio.SplitFunc, error) | ||||||||||||||||||
|
|
@@ -122,10 +128,43 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error | |||||||||||||||||
| splitFunc = trim.WithFunc(splitFunc, c.TrimConfig.Func()) | ||||||||||||||||||
|
|
||||||||||||||||||
| var resolver *helper.IPResolver | ||||||||||||||||||
| if c.AddAttributes { | ||||||||||||||||||
| if c.AddAttributes || c.Metrics.Enabled { | ||||||||||||||||||
| resolver = helper.NewIPResolver() | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| var ( | ||||||||||||||||||
| metricPayloadSize metric.Int64Histogram | ||||||||||||||||||
| metricConnectionsCreated metric.Int64Counter | ||||||||||||||||||
| metricConnectionsClosed metric.Int64Counter | ||||||||||||||||||
| ) | ||||||||||||||||||
|
|
||||||||||||||||||
| if c.Metrics.Enabled { | ||||||||||||||||||
| meter := set.MeterProvider.Meter("github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/operator/input/tcp") | ||||||||||||||||||
| if metricPayloadSize, err = meter.Int64Histogram( | ||||||||||||||||||
| "otelcol_tcplog_receiver_payload_size_bytes", | ||||||||||||||||||
| metric.WithDescription("Size of the payload size received by the tcp log receiver"), | ||||||||||||||||||
| metric.WithUnit("bytes"), | ||||||||||||||||||
| metric.WithExplicitBucketBoundaries(64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, | ||||||||||||||||||
| 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728), // 64 bytes to 128MB | ||||||||||||||||||
| ); err != nil { | ||||||||||||||||||
| return nil, err | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if metricConnectionsCreated, err = meter.Int64Counter( | ||||||||||||||||||
| "otelcol_tcplog_receiver_connections_created_total", | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Or to follow semantic conventions on namespacing:
Suggested change
Or even which fits better with other conventions and allows consolidation.
Suggested change
With network.connection.state attribute = established We could even have if we add otel.component.type attribute capturing that it is a collector reciever.
Suggested change
All options use attributes to identify the reciever ie otel.component.name |
||||||||||||||||||
| metric.WithDescription("Total number of connections created by the tcp log receiver"), | ||||||||||||||||||
| ); err != nil { | ||||||||||||||||||
| return nil, err | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if metricConnectionsClosed, err = meter.Int64Counter( | ||||||||||||||||||
| "otelcol_tcplog_receiver_connections_closed_total", | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Or to follow semantic conventions on namespacing:
Suggested change
Or even which fits better with other conventions and allows consolidation.
Suggested change
With network.connection.state attribute = closed We could even have if we add otel.component.type attribute capturing that it is a collector reciever.
Suggested change
All options use attributes to identify the reciever ie otel.component.name |
||||||||||||||||||
| metric.WithDescription("Total number of connections closed by the tcp log receiver"), | ||||||||||||||||||
| ); err != nil { | ||||||||||||||||||
| return nil, err | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| tcpInput := &Input{ | ||||||||||||||||||
| InputOperator: inputOperator, | ||||||||||||||||||
| address: c.ListenAddress, | ||||||||||||||||||
|
|
@@ -138,6 +177,10 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error | |||||||||||||||||
| Max: 3 * time.Second, | ||||||||||||||||||
| }, | ||||||||||||||||||
| resolver: resolver, | ||||||||||||||||||
|
|
||||||||||||||||||
| metricPayloadSize: metricPayloadSize, | ||||||||||||||||||
| metricConnectionsCreated: metricConnectionsCreated, | ||||||||||||||||||
| metricConnectionsClosed: metricConnectionsClosed, | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| if c.TLS != nil { | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or to follow semantic conventions on namespacing:
Or following additional semconv patterns
We could even have if we add otel.component.type attribute capturing that it is a collector reciever.
All options use attributes to identify the reciever ie otel.component.name as well as the network direction.