[sdk] Ability to add custom `TextMapPropagator`s when using auto-configuration
I think it would be helpful (admittedly JVM only) to have an SPI for adding custom TextMapPropagators which can then be configured using environment variables.
Proposed SPI:
trait TextMapPropagatorProvider {
def name: String
def instance: TextMapPropagator[Context]
}
~~I've also opened open-telemetry/opentelemetry-java#7079 with a request for the equivalent in the official Java library.~~
I am aware that the sdk auto-configuration builder already supports custom TextMapPropagators, but purely environment-based configuration could be nice too
Not ideal, but you can do the following:
OpenTelemetrySdk.autoConfigured[IO](
_.addExportersConfigurer(OtlpExportersAutoConfigure[IO])
.addTextMapPropagatorConfigurer(AutoConfigure.Named.const("myCustomPropagator", propagator))
)
Then you can dynamically configure it: export OTEL_PROPAGATORS=myCustomPropagator.
That doesn't improve usability, but it can be helpful if you need to configure the propagator dynamically.
It will be interesting to explore the SPI topic in the SDK module. So we can finally get rid of the mandatory addExportersConfigurer.
Hi @iRevive ,
I’m interested in contributing to this feature! 🎯 I understand the goal is to allow custom TextMapPropagators to be configured purely via environment variables using an SPI.
Before I dive in, I wanted to clarify a few things: 1️⃣ Should the SPI approach fully replace the current addTextMapPropagatorConfigurer, or should it be an additional option? 2️⃣ Are there any preferred design patterns or existing implementations you'd recommend following? 3️⃣ Would a PR for this be welcome at this stage?
Looking forward to your thoughts! 🚀
Thanks! @shumaila34