1.10 Migration Guide (original) (raw)

If you are upgrading from 1.9, there should not be breaking changes, and the main new API to check out is the Observation API, which has its own Observation API Migration Guide.

If you are upgrading from a 1.10 milestone or RC pre-release, the following guide describes how to adapt to the breaking changes that have happened in between those pre-releases.

Formerly released 2.0 milestones have been superseded by the 1.10 milestones.

Features that were being worked on in the 2.0 milestones will be released instead as 1.10 milestones and eventually a GA version. The 1.10.0-M1 milestone release follows the 2.0.0-M3 milestone.

Micrometer 1.10.0-RC1

Anywhere you were passing a Context object to an Observation factory method (static methods on Observation and instance methods on ObservationDocumentation), the parameter type has been changed to Supplier<Context> to allow for lazy instantiation of the context. There are a few options available on how to migrate your code.

Lambda

Using a lambda is one way to adapt code to the new API. Before where you may have had code like the following:

JerseyContext jerseyContext = new JerseyContext(event); Observation observation = JerseyObservationDocumentation.DEFAULT.start(this.jerseyObservationConvention, new DefaultJerseyObservationConvention(this.metricName), jerseyContext, this.registry);

It can be updated to:

JerseyContext jerseyContext = new JerseyContext(event); Observation observation = JerseyObservationDocumentation.DEFAULT.start(this.jerseyObservationConvention, new DefaultJerseyObservationConvention(this.metricName), () -> jerseyContext, this.registry);

Method reference

If you do not need to pass arguments to the context, you can use a method reference to the constructor.

Observation.start("my.observation", Context::new, observationRegistry)

Make your context a supplier

Another alternative if you are using a custom context is to make it implement Supplier and then you can pass the context object as you were before. For example, an OkHttpContext class could be updated to the following.

public class OkHttpContext extends RequestReplySenderContext<Request.Builder, Response> implements Supplier { // ... @Override public OkHttpContext get() { return this; }

And then used the same as before, such as:

Observation observation = OkHttpObservationDocumentation.DEFAULT.observation(this.observationConvention, new DefaultOkHttpObservationConvention(requestMetricName), okHttpContext, this.registry).start();

Micrometer 1.10.0-M5

Micrometer 1.10.0-M4

Micrometer 1.10.0-M3

Micrometer 1.10.0-M1

micrometer-observation

There is a new module that contains an Observation API for instrumenting code. micrometer-core provides an integration that produces Timer metrics from this Observation instrumentation, and micrometer-tracing provides an integration to produce spans from that instrumentation. You can make your own integrations with this API, and instrument your code with this API.

See the Migration to the Observation API wiki.

micrometer-commons

We've moved TagKey and internal utilities from micrometer-observation to a new module called micrometer-commons. You'll need to update your imports like the following

Before : io.micrometer.observation.docs.TagKey, after: io.micrometer.common.docs.KeyName

More detailed migration guide

Up till Micrometer 2.0.0-M3

micrometer-tracing

See https://github.com/micrometer-metrics/tracing and the corresponding reference documentation.