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

Allow extra resource attributes to be parsed to LogEntry labels #531

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions exporter/collector/config.go
Expand Up @@ -143,8 +143,12 @@ type ResourceFilter struct {
type LogConfig struct {
// DefaultLogName sets the fallback log name to use when one isn't explicitly set
// for a log entry. If unset, logs without a log name will raise an error.
DefaultLogName string `mapstructure:"default_log_name"`
ClientConfig ClientConfig `mapstructure:",squash"`
DefaultLogName string `mapstructure:"default_log_name"`
// ResourceFilters, if provided, provides a list of resource filters.
// Resource attributes matching any filter will be included in LogEntry labels.
// Defaults to empty, which won't include any additional resource labels.
ResourceFilters []ResourceFilter `mapstructure:"resource_filters"`
ClientConfig ClientConfig `mapstructure:",squash"`
}

// Known metric domains. Note: This is now configurable for advanced usages.
Expand Down
12 changes: 12 additions & 0 deletions exporter/collector/integrationtest/testcases/testcases_logs.go
Expand Up @@ -14,6 +14,8 @@

package testcases

import "github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/collector"

var LogsTestCases = []TestCase{
{
Name: "Apache access log with HTTPRequest",
Expand All @@ -40,4 +42,14 @@ var LogsTestCases = []TestCase{
OTLPInputFixturePath: "testdata/fixtures/logs/logs_span_trace_id.json",
ExpectFixturePath: "testdata/fixtures/logs/logs_span_trace_id_expected.json",
},
{
Name: "Logs with additional resource attributes",
OTLPInputFixturePath: "testdata/fixtures/logs/logs_apache_access_resource_attributes.json",
ExpectFixturePath: "testdata/fixtures/logs/logs_apache_access_resource_attributes_expected.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.LogConfig.ResourceFilters = []collector.ResourceFilter{
{Prefix: "custom."},
}
},
},
}