Skip to content

feat(outputs.opentelemetry): Add a config option for specifying name/field separator#19156

Open
mchrome wants to merge 6 commits into
influxdata:masterfrom
mchrome:feat/18251/Configure-separator-for-OpenTelemetry-metric-names
Open

feat(outputs.opentelemetry): Add a config option for specifying name/field separator#19156
mchrome wants to merge 6 commits into
influxdata:masterfrom
mchrome:feat/18251/Configure-separator-for-OpenTelemetry-metric-names

Conversation

@mchrome

@mchrome mchrome commented Jun 24, 2026

Copy link
Copy Markdown

Summary

This PR adds an option to specify a separator for LineProtocol's name/field when converting to OpenTelemtry format, similar to how it is done in graphite's output plugin with graphite_separator option.

This PR relies on changes in a dependency: influxdata/influxdb-observability#341. From my understanding, the team behind telegraf has write access there too, so it would be great if you could review that one also. Until that PR is merged, i replaced the dependency "infuxdb-observability/influx2otel" in go.mod with my fork of it, so tests could pass.

For context: there was another attempt by me to fix this issue here #18680, but after the review i realized it was not the right approach. Sorry for not getting back at you there.

Checklist

Related issues

resolves #18251

@telegraf-tiger telegraf-tiger Bot added feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins labels Jun 24, 2026
@mchrome

mchrome commented Jun 25, 2026

Copy link
Copy Markdown
Author

@srebhan Hi, could you take a look at this? Thanks.

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs: the new otel_name_separator option isn't in sample.conf or README.md. Please add it to sample.conf and run make docs to regenerate the README.

Comment thread go.mod

godebug x509negativeserial=1

replace github.com/influxdata/influxdb-observability/influx2otel => github.com/mchrome/influxdb-observability/influx2otel v0.0.0-20260623155732-db200540d054

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't land on master. The real behavior lives in influxdb-observability#341, so that one needs to be reviewed, merged, and released first; then bump influx2otel here and drop the replace. Note influx2otel, common, and otel2influx are versioned together (currently v0.5.12), so the bump will likely move all three.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got you. Is there anything i can do to get that PR reviewed and merged?

Coralogix *CoralogixConfig `toml:"coralogix"`
Timeout config.Duration `toml:"timeout"`
Compression string `toml:"compression"`
OtelNameSeparator string `toml:"otel_name_separator"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otel_name_separator repeats "otel". name_separator (or just separator) reads better. Config is user-facing API and renaming after release is breaking, so worth settling now.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed it here dfcab49.

require.JSONEq(t, string(expectJSON), string(gotJSON))
}

func TestOpenTelemetrySeparator(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new tests only cover .. Backward compatibility relies on the default _ path through Connect() producing the same output as before, but nothing asserts that (the existing default tests inject the converter directly / use the old constructor). A test that calls Connect() with the default and asserts mem_used_percent would lock that in.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rewrote the old tests in 894adfa because using the old constructor doesn't make much sense anymore since the plugin only uses the new one. Now they don't inject converters directly and create them through Connect(). Also added the test you described in 2eb45e5.

require.JSONEq(t, string(expectJSON), string(gotJSON))
}

func TestOpenTelemetrySeparatorHTTPJSON(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the io.ReadAll error branch returns without w.WriteHeader(http.StatusInternalServerError), unlike the protobuf variant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 9fd0978

@telegraf-tiger

telegraf-tiger Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/output 1. Request for new output plugins 2. Issues/PRs that are related to out plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support dot-separated OpenTelemetry metric names in OpenTelemetry output plugin

2 participants