spring-projects-experimental / spring-cloud-sleuth-otel

Spring Cloud Sleuth support for OpenTelemetry
https://spring-projects-experimental.github.io/spring-cloud-sleuth-otel/docs/current/reference/html/
Apache License 2.0
111 stars 33 forks source link

Configuration Properties for OTel Resource Attributes #107

Closed kschlesselmann closed 2 years ago

kschlesselmann commented 2 years ago

Hi!

Currently we have a look at Sleuth OTel and it seems the only way to configure resource attributes is by providing a custom Supplier<io.opentelemetry.sdk.resources.Resource> like

@Configuration
class SpringCloudSleuthOtelConfiguration {
    @Bean
    fun otelResourceAttributes(): Supplier<Resource> = Supplier {
        Resource.builder()
            .put(ResourceAttributes.DEPLOYMENT_ENVIRONMENT, "local")
            .put(ResourceAttributes.SERVICE_VERSION, "1.0.0")
            .put(ResourceAttributes.SERVICE_NAMESPACE, "my-namespace")
            .build()
    }
}

It would be great if the starter could take care of that via configuration properties. I thought of something like

spring:
  sleuth:
    otel:
      resource:
        deployment.environment: develop
        service.version: 1.0.0
        …
marcingrzejszczak commented 2 years ago

cc @mhalbritter (this could be added in Boot too)

kschlesselmann commented 2 years ago

@marcingrzejszczak As I said, I think I could provide a PR here.

Didn't know that Boot supports OTel as well. I'll wait for @mhalbritter to give his opinion on that before I'll start anything.

marcingrzejszczak commented 2 years ago

You can start working on this here for sure. We are supporting things in Boot 3.0 but it will take while to consider adding things to boot.