jdbc-observations / datasource-micrometer

Micrometer Observation API instrumentation and Spring Boot 3 Auto-Configuration for JDBC APIs
Apache License 2.0
50 stars 8 forks source link

Introduce jdbc.datasource-proxy.with-parent-only configuration property #21

Closed quaff closed 1 year ago

quaff commented 1 year ago

If set jdbc.datasource-proxy.with-parent-only to true, then JDBC instrumentation should be ignored without parent Observation, I think it will mitigate https://github.com/jdbc-observations/datasource-micrometer/issues/17

I have a system that polls a database every second with a simple query, and I will like to exclude it from traces reported to the Jaeger.

see https://github.com/micrometer-metrics/micrometer/pull/3843#issuecomment-1552272400

quaff commented 1 year ago

We could use ObservationPredicate if https://github.com/micrometer-metrics/micrometer/pull/3867 get merged, I'm going to close this.

    @Bean
    ObservationPredicate noParentlessDatabaseObservations() {
        return (name, context) -> {
            if (context instanceof DataSourceBaseContext) {
                return context.getParentObservation() != null;
            }
            return true;
        };
    }