-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add loadgenreceiver and loadgen config (#246)
Add a loadgen config that configures elastic collector components distro to replay and rewrite canned opentelemetry-demo data at a configurable rate. It uses a new loadgenreceiver and the existing ratelimitprocessor.
- Loading branch information
Showing
25 changed files
with
2,813 additions
and
1 deletion.
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
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,19 @@ | ||
# loadgen: the load generator based on OTel collector | ||
|
||
To generate load to an OTLP target, run Elastic collector components distro with specific pipelines to replay canned data at a configurable rate. | ||
|
||
See an example configuration at `config.example.yaml`. There are rate limiting and trace ID rewriting by default. | ||
|
||
## Usage | ||
|
||
``` | ||
../_build/elastic-collector-components --config config.example.yaml --set "exporter.otlp.endpoint=http://localhost:8200" --set "exporter.otlp.headers.Authorization=ApiKey xxx" --set "exporter.otlp.headers.X-FOO-HEADER=bar" | ||
``` | ||
|
||
Alternatively, there's `ELASTIC_APM_SERVER_URL` and `ELASTIC_APM_API_KEY` env var handling out of the box. `ELASTIC_APM_SECRET_TOKEN` is NOT supported without changing `config.example.yaml`. | ||
|
||
``` | ||
ELASTIC_APM_SERVER_URL=http://localhost:8200 ELASTIC_APM_API_KEY=some_api_key ../_build/elastic-collector-components --config config.example.yaml | ||
``` | ||
|
||
Even better, create your own `config.yaml` from `config.example.yaml` to fit your needs. |
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,48 @@ | ||
receivers: | ||
loadgen: | ||
|
||
exporters: | ||
otlp: | ||
endpoint: "${env:ELASTIC_APM_SERVER_URL}" | ||
headers: | ||
Authorization: "ApiKey ${env:ELASTIC_APM_API_KEY}" | ||
# Authorization: "Bearer ${env:ELASTIC_APM_SECRET_TOKEN}" | ||
sending_queue: | ||
enabled: false | ||
timeout: 60s | ||
debug: | ||
|
||
|
||
processors: | ||
transform/rewrite: # Rewrite telemetry to increase cardinality | ||
trace_statements: | ||
- context: span | ||
statements: | ||
# The worst way to generate a random ID, but is the simplest in OTTL | ||
# Only randomize trace ID such that span relationships are still maintained | ||
- set(trace_id.string, Substring(MD5(UUID()), 0, 32)) | ||
|
||
ratelimit: | ||
strategy: records | ||
rate: 5000 | ||
burst: 5000 | ||
throttle_behavior: delay | ||
|
||
|
||
service: | ||
pipelines: | ||
logs: | ||
receivers: [loadgen] | ||
processors: [ratelimit, transform/rewrite] | ||
exporters: [otlp, debug] | ||
metrics: | ||
receivers: [loadgen] | ||
processors: [ratelimit, transform/rewrite] | ||
exporters: [otlp, debug] | ||
traces: | ||
receivers: [loadgen] | ||
processors: [ratelimit, transform/rewrite] | ||
exporters: [otlp, debug] | ||
# telemetry: | ||
# logs: | ||
# level: debug |
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 @@ | ||
include ../../Makefile.Common |
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,56 @@ | ||
# Loadgen receiver | ||
|
||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |-----------| | ||
| Stability | [development]: metrics, logs, traces | | ||
| Distributions | [] | | ||
| Issues | [![Open issues](https://img.shields.io/github/issues-search/elastic/opentelemetry-collector-components?query=is%3Aissue%20is%3Aopen%20label%3Areceiver%2Floadgen%20&label=open&color=orange&logo=opentelemetry)](https://github.com/elastic/opentelemetry-collector-components/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Floadgen) [![Closed issues](https://img.shields.io/github/issues-search/elastic/opentelemetry-collector-components?query=is%3Aissue%20is%3Aclosed%20label%3Areceiver%2Floadgen%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/elastic/opentelemetry-collector-components/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Floadgen) | | ||
|
||
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development | ||
<!-- end autogenerated section --> | ||
|
||
The Loadgen receiver is a specialized OpenTelemetry receiver designed to generate metrics, logs, and traces for testing, benchmarking, and validation purposes. | ||
|
||
## How Telemetry Is Generated | ||
|
||
The receiver utilizes pre-captured telemetry data from a typical OpenTelemetry Demo execution, which represents a diverse set of application scenarios and workloads. When generating telemetry, the receiver uses this base data, dynamically adjusting timestamps to match the current time. This approach ensures the generated telemetry retains the structure and content of authentic OpenTelemetry Demo data while appearing as though it were generated in real-time. The pre-captured telemetry is embedded in the receiver and can be found in [testdata](./testdata/) directory. | ||
|
||
## Rate limiting | ||
|
||
The receiver generates telemetry as quickly as possible. Any rate limiting should be done via backpressure using [processor/ratelimitprocessor](/processor/ratelimitprocessor). | ||
|
||
## Telemetry cardinality | ||
|
||
The receiver only rewrites timestamps to Now, and does not modify any other fields. Therefore, it will have the same cardinality as the original canned data. To simulate higher cardinality (e.g. trace ID, service name), use `transform` processor with OTTL to rewrite fields. | ||
|
||
## Sample configuration | ||
|
||
```yaml | ||
receivers: | ||
loadgen: | ||
|
||
processors: | ||
|
||
exporters: | ||
debug: | ||
verbosity: detailed | ||
|
||
service: | ||
telemetry: | ||
logs: | ||
level: debug | ||
pipelines: | ||
metrics: | ||
receivers: [loadgen] | ||
processors: | ||
exporters: [debug] | ||
logs: | ||
receivers: [loadgen] | ||
processors: | ||
exporters: [debug] | ||
traces: | ||
receivers: [loadgen] | ||
processors: | ||
exporters: [debug] | ||
``` |
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,58 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package loadgenreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/loadgenreceiver" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/component" | ||
) | ||
|
||
type ( | ||
JsonlFile string | ||
) | ||
|
||
// Config defines configuration for HostMetrics receiver. | ||
type Config struct { | ||
Metrics MetricsConfig `mapstructure:"metrics"` | ||
Logs LogsConfig `mapstructure:"logs"` | ||
Traces TracesConfig `mapstructure:"traces"` | ||
} | ||
|
||
type MetricsConfig struct { | ||
// JsonlFile is an optional configuration option to specify the path to | ||
// get the base generated signals from. | ||
JsonlFile `mapstructure:"jsonl_file"` | ||
} | ||
|
||
type LogsConfig struct { | ||
// JsonlFile is an optional configuration option to specify the path to | ||
// get the base generated signals from. | ||
JsonlFile `mapstructure:"jsonl_file"` | ||
} | ||
|
||
type TracesConfig struct { | ||
// JsonlFile is an optional configuration option to specify the path to | ||
// get the base generated signals from. | ||
JsonlFile `mapstructure:"jsonl_file"` | ||
} | ||
|
||
var _ component.Config = (*Config)(nil) | ||
|
||
// Validate checks the receiver configuration is valid | ||
func (cfg *Config) Validate() error { | ||
return nil | ||
} |
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,20 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
//go:generate mdatagen metadata.yaml | ||
|
||
package loadgenreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/loadgenreceiver" |
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,39 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package loadgenreceiver // import "github.com/elastic/opentelemetry-collector-components/receiver/loadgenreceiver" | ||
|
||
import ( | ||
"github.com/elastic/opentelemetry-collector-components/receiver/loadgenreceiver/internal/metadata" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/receiver" | ||
) | ||
|
||
// CreateDefaultConfig creates the default configuration for the Scraper. | ||
func createDefaultReceiverConfig() component.Config { | ||
return &Config{} | ||
} | ||
|
||
func NewFactory() receiver.Factory { | ||
return receiver.NewFactory( | ||
metadata.Type, | ||
createDefaultReceiverConfig, | ||
receiver.WithMetrics(createMetricsReceiver, component.StabilityLevelDevelopment), | ||
receiver.WithTraces(createTracesReceiver, component.StabilityLevelDevelopment), | ||
receiver.WithLogs(createLogsReceiver, component.StabilityLevelDevelopment), | ||
) | ||
} |
Oops, something went wrong.