Skip to content

Commit

Permalink
fix: add micrometer bom to observability & optimize the structure of …
Browse files Browse the repository at this point in the history
…the package (#11724)

* chore: optimize the structure of the package

* chore: add micrometer bom to observability

---------

Co-authored-by: Albumen Kevin <jhq0812@gmail.com>
  • Loading branch information
conghuhu and AlbumenJ authored Mar 6, 2023
1 parent d711300 commit d3d8c54
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.common.KeyValues;
import io.micrometer.common.docs.KeyName;
Expand All @@ -25,9 +25,9 @@
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.support.RpcUtils;

import static org.apache.dubbo.metrics.filter.observation.DubboObservation.LowCardinalityKeyNames.RPC_METHOD;
import static org.apache.dubbo.metrics.filter.observation.DubboObservation.LowCardinalityKeyNames.RPC_SERVICE;
import static org.apache.dubbo.metrics.filter.observation.DubboObservation.LowCardinalityKeyNames.RPC_SYSTEM;
import static org.apache.dubbo.metrics.observation.DubboObservation.LowCardinalityKeyNames.RPC_METHOD;
import static org.apache.dubbo.metrics.observation.DubboObservation.LowCardinalityKeyNames.RPC_SERVICE;
import static org.apache.dubbo.metrics.observation.DubboObservation.LowCardinalityKeyNames.RPC_SYSTEM;

class AbstractDefaultDubboObservationConvention {
KeyValues getLowCardinalityKeyValues(Invocation invocation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import java.util.List;

Expand All @@ -24,8 +24,8 @@
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcContextAttachment;

import static org.apache.dubbo.metrics.filter.observation.DubboObservation.LowCardinalityKeyNames.NET_PEER_NAME;
import static org.apache.dubbo.metrics.filter.observation.DubboObservation.LowCardinalityKeyNames.NET_PEER_PORT;
import static org.apache.dubbo.metrics.observation.DubboObservation.LowCardinalityKeyNames.NET_PEER_NAME;
import static org.apache.dubbo.metrics.observation.DubboObservation.LowCardinalityKeyNames.NET_PEER_PORT;

/**
* Default implementation of the {@link DubboClientObservationConvention}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.common.KeyValues;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.common.docs.KeyName;
import io.micrometer.observation.Observation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.observation.transport.ReceiverContext;
import org.apache.dubbo.rpc.Invocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dubbo.metrics.filter.observation;
package org.apache.dubbo.metrics.observation;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import io.micrometer.observation.ObservationRegistry;

import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.metrics.filter.observation.DefaultDubboServerObservationConvention;
import org.apache.dubbo.metrics.filter.observation.DubboObservation;
import org.apache.dubbo.metrics.filter.observation.DubboServerContext;
import org.apache.dubbo.metrics.filter.observation.DubboServerObservationConvention;
import org.apache.dubbo.rpc.BaseFilter;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import io.micrometer.observation.ObservationRegistry;

import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.metrics.filter.observation.DefaultDubboClientObservationConvention;
import org.apache.dubbo.metrics.filter.observation.DubboClientContext;
import org.apache.dubbo.metrics.filter.observation.DubboClientObservationConvention;
import org.apache.dubbo.metrics.filter.observation.DubboObservation;
import org.apache.dubbo.rpc.BaseFilter;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.Invocation;
Expand Down
24 changes: 24 additions & 0 deletions dubbo-spring-boot/dubbo-spring-boot-observability-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@

<artifactId>dubbo-spring-boot-observability-starter</artifactId>

<properties>
<micrometer.version>1.10.4</micrometer.version>
<micrometer-tracing.version>1.0.2</micrometer-tracing.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-bom</artifactId>
<version>${micrometer.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bom</artifactId>
<version>${micrometer-tracing.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import io.micrometer.tracing.Tracer;
import io.micrometer.tracing.handler.TracingAwareMeterObservationHandler;
import io.micrometer.tracing.handler.TracingObservationHandler;

import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.spring.boot.observability.annotation.ConditionalOnDubboTracingEnable;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
Expand All @@ -46,7 +48,7 @@
* Register observationRegistry to ApplicationModel.
* Create observationRegistry when you are using Boot <3.0 or you are not using spring-boot-starter-actuator
*/
@AutoConfiguration(after =DubboMicrometerTracingAutoConfiguration.class,afterName = "org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration")
@AutoConfiguration(after = DubboMicrometerTracingAutoConfiguration.class, afterName = "org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration")
@ConditionalOnDubboTracingEnable
public class DubboObservationAutoConfiguration implements BeanFactoryAware, SmartInitializingSingleton {

Expand Down Expand Up @@ -108,14 +110,14 @@ ObservationHandlerGrouping tracingObservationHandlerGrouping() {
}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass({ MeterRegistry.class, Tracer.class })
@ConditionalOnClass({MeterRegistry.class, Tracer.class})
@ConditionalOnMissingBean(type = "org.springframework.boot.actuate.autoconfigure.observation.ObservationRegistryPostProcessor")
static class MetricsWithTracingConfiguration {

@Bean
ObservationHandlerGrouping metricsAndTracingObservationHandlerGrouping() {
return new ObservationHandlerGrouping(
Arrays.asList(TracingObservationHandler.class, MeterObservationHandler.class));
Arrays.asList(TracingObservationHandler.class, MeterObservationHandler.class));
}

}
Expand All @@ -142,7 +144,7 @@ static class TracingAndMetricsObservationHandlerConfiguration {

@Bean
TracingAwareMeterObservationHandler<Observation.Context> tracingAwareMeterObservationHandler(
MeterRegistry meterRegistry, Tracer tracer) {
MeterRegistry meterRegistry, Tracer tracer) {
DefaultMeterObservationHandler delegate = new DefaultMeterObservationHandler(meterRegistry);
return new TracingAwareMeterObservationHandler<>(delegate, tracer);
}
Expand Down
6 changes: 0 additions & 6 deletions dubbo-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<log4j2_version>2.20.0</log4j2_version>
<!-- Spring boot buddy is lower than the delivery dependency package version and can only show the defined dependency version -->
<byte-buddy.version>1.14.0</byte-buddy.version>
<micrometer-core.version>1.10.4</micrometer-core.version>
</properties>

<dependencyManagement>
Expand All @@ -59,11 +58,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${micrometer-core.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit d3d8c54

Please sign in to comment.