Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/fix-clickhouse-json-exporter-factory.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: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
component: exporter/clickhouse

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix a bug in the exporter factory resulting in a nil dereference panic when the clickhouse.json feature gate is enabled

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

# (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]
7 changes: 7 additions & 0 deletions exporter/clickhouseexporter/exporter_logs_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/clickhouseexporter/internal/sqltemplates"
)

// anyLogsExporter is an interface that satisfies both the default map logsExporter and the logsJSONExporter
type anyLogsExporter interface {
start(context.Context, component.Host) error
shutdown(context.Context) error
pushLogsData(context.Context, plog.Logs) error
}

type logsJSONExporter struct {
cfg *Config
logger *zap.Logger
Expand Down
7 changes: 7 additions & 0 deletions exporter/clickhouseexporter/exporter_traces_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/clickhouseexporter/internal/sqltemplates"
)

// anyTracesExporter is an interface that satisfies both the default map tracesExporter and the tracesJSONExporter
type anyTracesExporter interface {
start(context.Context, component.Host) error
shutdown(context.Context) error
pushTraceData(ctx context.Context, td ptrace.Traces) error
}

type tracesJSONExporter struct {
cfg *Config
logger *zap.Logger
Expand Down
20 changes: 10 additions & 10 deletions exporter/clickhouseexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func createLogsExporter(
c := cfg.(*Config)
c.collectorVersion = set.BuildInfo.Version

exp := newLogsExporter(set.Logger, c)
startOpt := exporterhelper.WithStart(exp.start)
var exp anyLogsExporter
if featureGateJSON.IsEnabled() {
exp := newLogsJSONExporter(set.Logger, c)
startOpt = exporterhelper.WithStart(exp.start)
exp = newLogsJSONExporter(set.Logger, c)
} else {
exp = newLogsExporter(set.Logger, c)
}

return exporterhelper.NewLogs(
ctx,
set,
cfg,
exp.pushLogsData,
startOpt,
exporterhelper.WithStart(exp.start),
exporterhelper.WithShutdown(exp.shutdown),
exporterhelper.WithTimeout(c.TimeoutSettings),
exporterhelper.WithQueue(c.QueueSettings),
Expand All @@ -65,19 +65,19 @@ func createTracesExporter(
c := cfg.(*Config)
c.collectorVersion = set.BuildInfo.Version

exp := newTracesExporter(set.Logger, c)
startOpt := exporterhelper.WithStart(exp.start)
var exp anyTracesExporter
if featureGateJSON.IsEnabled() {
exp := newTracesJSONExporter(set.Logger, c)
startOpt = exporterhelper.WithStart(exp.start)
exp = newTracesJSONExporter(set.Logger, c)
} else {
exp = newTracesExporter(set.Logger, c)
}

return exporterhelper.NewTraces(
ctx,
set,
cfg,
exp.pushTraceData,
startOpt,
exporterhelper.WithStart(exp.start),
exporterhelper.WithShutdown(exp.shutdown),
exporterhelper.WithTimeout(c.TimeoutSettings),
exporterhelper.WithQueue(c.QueueSettings),
Expand Down