Skip to content
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

Codesmon/exporter/azuremonitor/persistent queue #26258

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
71018ab
Added persistent_queue capability to Azure Monitor Exporter
codesmon Aug 17, 2023
f14681d
Added to config unit test to check for sending_queue
codesmon Aug 17, 2023
f8583fa
Merge remote-tracking branch 'upstream/main' into codesmon/exporter/a…
codesmon Aug 29, 2023
d9f6ed0
Added change log entry
codesmon Aug 29, 2023
7112003
Added persistent_queue capability to Azure Monitor Exporter
codesmon Aug 17, 2023
3dcfcb4
Added to config unit test to check for sending_queue
codesmon Aug 17, 2023
e003865
Added change log entry
codesmon Aug 29, 2023
2ac0875
Merge branch 'codesmon/exporter/azuremonitor/persistent_queue' of
codesmon Oct 31, 2023
f56a8ee
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Oct 31, 2023
78a9b8e
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Oct 31, 2023
a15b380
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Oct 31, 2023
8576048
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Oct 31, 2023
6a2612c
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 1, 2023
3c93f11
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 1, 2023
f137638
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 2, 2023
cbc0d05
Merge conflict
codesmon Nov 6, 2023
a442294
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 6, 2023
afb58cc
GCI'd the code.
codesmon Nov 6, 2023
1cf091d
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 7, 2023
b7100f4
Merge branch 'main' into codesmon/exporter/azuremonitor/persistent_queue
codesmon Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/codesmon_exporter_azuremonitor_persistent_queue.yaml
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. filelogreceiver)
component: azuremonitorexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Extended Azure Monitor exporter to support persistent queue. Default is for QueueSettings.Enabled to be false.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [25859]

# (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]
5 changes: 5 additions & 0 deletions exporter/azuremonitorexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ The following settings can be optionally configured:
- `maxbatchsize` (default = 1024): The maximum number of telemetry items that can be submitted in each request. If this many items are buffered, the buffer will be flushed before `maxbatchinterval` expires.
- `maxbatchinterval` (default = 10s): The maximum time to wait before sending a batch of telemetry.
- `spaneventsenabled` (default = false): Enables export of span events.
- `sending_queue`
- `enabled` (default = false)
- `num_consumers` (default = 10): Number of consumers that dequeue batches; ignored if `enabled` is `false`
- `queue_size` (default = 1000): Maximum number of batches kept in memory before data; ignored if `enabled` is `false`
- `storage` (default = `none`): When set, enables persistence and uses the component specified as a storage extension for the persistent queue

Example:

Expand Down
14 changes: 8 additions & 6 deletions exporter/azuremonitorexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import (
"time"

"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)

// Config defines configuration for Azure Monitor
type Config struct {
Endpoint string `mapstructure:"endpoint"`
ConnectionString configopaque.String `mapstructure:"connection_string"`
InstrumentationKey configopaque.String `mapstructure:"instrumentation_key"`
MaxBatchSize int `mapstructure:"maxbatchsize"`
MaxBatchInterval time.Duration `mapstructure:"maxbatchinterval"`
SpanEventsEnabled bool `mapstructure:"spaneventsenabled"`
exporterhelper.QueueSettings `mapstructure:"sending_queue"`
Endpoint string `mapstructure:"endpoint"`
ConnectionString configopaque.String `mapstructure:"connection_string"`
InstrumentationKey configopaque.String `mapstructure:"instrumentation_key"`
MaxBatchSize int `mapstructure:"maxbatchsize"`
MaxBatchInterval time.Duration `mapstructure:"maxbatchinterval"`
SpanEventsEnabled bool `mapstructure:"spaneventsenabled"`
}
9 changes: 9 additions & 0 deletions exporter/azuremonitorexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap/confmaptest"
"go.opentelemetry.io/collector/exporter/exporterhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter/internal/metadata"
)
Expand All @@ -22,6 +23,8 @@ func TestLoadConfig(t *testing.T) {
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml"))
require.NoError(t, err)

disk := component.NewIDWithName("disk", "")

tests := []struct {
id component.ID
expected component.Config
Expand All @@ -40,6 +43,12 @@ func TestLoadConfig(t *testing.T) {
MaxBatchSize: 100,
MaxBatchInterval: 10 * time.Second,
SpanEventsEnabled: false,
QueueSettings: exporterhelper.QueueSettings{
QueueSize: 1000,
Enabled: true,
NumConsumers: 10,
StorageID: &disk,
},
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions exporter/azuremonitorexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/azuremonitorexporter/internal/metadata"
Expand Down Expand Up @@ -49,6 +50,7 @@ func createDefaultConfig() component.Config {
MaxBatchSize: 1024,
MaxBatchInterval: 10 * time.Second,
SpanEventsEnabled: false,
QueueSettings: exporterhelper.NewDefaultQueueSettings(),
}
}

Expand Down
8 changes: 7 additions & 1 deletion exporter/azuremonitorexporter/logexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ func newLogsExporter(config *Config, transportChannel transportChannel, set expo
logger: set.Logger,
}

return exporterhelper.NewLogsExporter(context.TODO(), set, config, exporter.onLogData)
return exporterhelper.NewLogsExporter(
context.TODO(),
set,
config,
exporter.onLogData,
exporterhelper.WithQueue(config.QueueSettings),
)
}
7 changes: 6 additions & 1 deletion exporter/azuremonitorexporter/metricexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,10 @@ func newMetricsExporter(config *Config, transportChannel transportChannel, set e
packer: newMetricPacker(set.Logger),
}

return exporterhelper.NewMetricsExporter(context.TODO(), set, config, exporter.onMetricData)
return exporterhelper.NewMetricsExporter(
context.TODO(),
set,
config,
exporter.onMetricData,
exporterhelper.WithQueue(config.QueueSettings))
}
9 changes: 9 additions & 0 deletions exporter/azuremonitorexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ azuremonitor/2:
maxbatchsize: 100
# maxbatchinterval is the maximum time to wait before calling the configured endpoint.
maxbatchinterval: 10s

sending_queue:
# queue_size is the maximum number of items that can be queued before dropping data
queue_size: 1000
enabled: true
num_consumers: 10
storage: disk

disk/3:
7 changes: 6 additions & 1 deletion exporter/azuremonitorexporter/traceexporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,10 @@ func newTracesExporter(config *Config, transportChannel transportChannel, set ex
logger: set.Logger,
}

return exporterhelper.NewTracesExporter(context.TODO(), set, config, exporter.onTraceData)
return exporterhelper.NewTracesExporter(
context.TODO(),
set,
config,
exporter.onTraceData,
exporterhelper.WithQueue(config.QueueSettings))
}