Skip to content

[Proposal] Make table name configurable in OpenTelemetry C++ ETW exporter #2680

@ThomsonTan

Description

@ThomsonTan

In the current OpenTelemetry ETW Log exporter, the attribute for table name is hard-coded to "Log" (see below 2 links for more details). The table name is useful for grouping events in the backend, especially for the Logging signal. Based on that the ETW exporter is header-only, this table name can only be changed by patching the source code and recompiling the source code which could be inconvenient because the same source file can only have one table name defined.

# define ETW_VALUE_LOG "Log" /* ETW event name for Log */

Here are the 2 proposals about making this table name configurable at launch/runtime.

1. Reuse the library_name as table name

OpenTelemetry API has library name in GetLogger, but it is not used in ETW exporter (see here). So library_name can be mapped to table name under explicit enlightenment in the provider option. The config code looks like below.

 opentelemetry::exporter::etw::TelemetryProviderOptions options { {"libraryNameAsTableName", true} }; opentelemetry::exporter::etw::LoggerProvider logger_provider(options); auto logger = logger_provider.GetLogger(providerName, "my_table_name");

Pros

  • It doesn't break existing code for upgrading with the explicit enlightenment.
  • No extra perf cost on logging besides configuration option which is only for launch time.
  • It is consistent with .NET which defines the mapping in exporter configuration.

Cons

  • The library_name will not be able to be used for other mapping once this is enabled

2. Pass pre-defined attribute as table name for each Log call

We can also define a unique attribute to set the table as below.

 logger->Info("Hello World!", common::MakeAttributes{{"unique_table_name_key", "my_event_name"}});

Pros

  • No need to take out library_name from unused list.

Cons

  • Extra runtime cost for each Log call.
    • Extra memory allocated for the key value pairs struct.
    • Extra CPU time on initialize the key value pairs container, and also query the unique key to extract table name in the container.
  • The new convention of defining the unique key for table name causes inconsistency with other languages like .NET Geneva exporter, which does this in configuration option.

I prefer the option 1 above, let me know your suggestion or other options.

Metadata

Metadata

Assignees

Labels

triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions