Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observation.ObservationConvention -> ObservationConvention #3387

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micrometer.common.docs.KeyName;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
import io.micrometer.observation.docs.DocumentedObservation;

/**
Expand All @@ -28,7 +29,7 @@ public enum ApacheHttpClientDocumentedObservation implements DocumentedObservati

DEFAULT {
@Override
public Class<? extends Observation.ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
public Class<? extends ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
return DefaultApacheHttpClientObservationConvention.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package io.micrometer.core.instrument.binder.httpcomponents;

import io.micrometer.observation.Observation;
import io.micrometer.observation.Observation.ObservationConvention;
import io.micrometer.observation.ObservationConvention;

/**
* {@link ObservationConvention} for Apache HTTP client instrumentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.micrometer.common.docs.KeyName;
import io.micrometer.common.lang.NonNullApi;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
import io.micrometer.observation.docs.DocumentedObservation;

/**
Expand All @@ -34,7 +35,7 @@ public enum OkHttpDocumentedObservation implements DocumentedObservation {
*/
DEFAULT {
@Override
public Class<? extends Observation.ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
public Class<? extends ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
return DefaultOkHttpObservationConvention.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
package io.micrometer.core.instrument.binder.okhttp3;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;

/**
* An {@link Observation.ObservationConvention} for OkHttp3.
* An {@link ObservationConvention} for OkHttp3.
*
* @author Marcin Grzejszczak
* @since 1.10.0
*/
public interface OkHttpObservationConvention extends Observation.ObservationConvention<OkHttpContext> {
public interface OkHttpObservationConvention extends ObservationConvention<OkHttpContext> {

@Override
default boolean supportsContext(Observation.Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.micrometer.core.instrument.Timer;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.ObservationConvention;
import io.micrometer.observation.transport.RequestReplySenderContext;
import io.micrometer.observation.transport.ResponseContext;

Expand Down Expand Up @@ -50,9 +51,9 @@ public class ObservationOrTimerCompatibleInstrumentation<T extends Observation.C
private final ObservationRegistry observationRegistry;

@Nullable
private final Observation.ObservationConvention<T> convention;
private final ObservationConvention<T> convention;

private final Observation.ObservationConvention<T> defaultConvention;
private final ObservationConvention<T> defaultConvention;

@Nullable
private Timer.Sample timerSample;
Expand Down Expand Up @@ -81,18 +82,16 @@ public class ObservationOrTimerCompatibleInstrumentation<T extends Observation.C
*/
public static <T extends Observation.Context> ObservationOrTimerCompatibleInstrumentation<T> start(
MeterRegistry meterRegistry, @Nullable ObservationRegistry observationRegistry, Supplier<T> context,
@Nullable Observation.ObservationConvention<T> convention,
Observation.ObservationConvention<T> defaultConvention) {
@Nullable ObservationConvention<T> convention, ObservationConvention<T> defaultConvention) {
ObservationOrTimerCompatibleInstrumentation<T> observationOrTimer = new ObservationOrTimerCompatibleInstrumentation<>(
meterRegistry, observationRegistry, convention, defaultConvention);
observationOrTimer.start(context);
return observationOrTimer;
}

private ObservationOrTimerCompatibleInstrumentation(MeterRegistry meterRegistry,
@Nullable ObservationRegistry observationRegistry,
@Nullable Observation.ObservationConvention<T> convention,
Observation.ObservationConvention<T> defaultConvention) {
@Nullable ObservationRegistry observationRegistry, @Nullable ObservationConvention<T> convention,
ObservationConvention<T> defaultConvention) {
this.meterRegistry = meterRegistry;
this.observationRegistry = observationRegistry == null ? ObservationRegistry.NOOP : observationRegistry;
this.convention = convention;
Expand Down Expand Up @@ -125,7 +124,7 @@ public <RES> void setResponse(RES response) {
}

/**
* If using an Observation will set the error on Observation. For metrics it will do
* If using an Observation will set the error on Observation. For metrics, it will do
* nothing.
* @param throwable error that got recorded
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.micrometer.common.docs.KeyName;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
import io.micrometer.observation.docs.DocumentedObservation;

enum HttpClientDocumentedObservation implements DocumentedObservation {
Expand All @@ -26,7 +27,7 @@ enum HttpClientDocumentedObservation implements DocumentedObservation {
*/
HTTP_CALL {
@Override
public Class<? extends Observation.ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
public Class<? extends ObservationConvention<? extends Observation.Context>> getDefaultConvention() {
return DefaultHttpClientObservationConvention.class;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
package io.micrometer.core.instrument.binder.jdk;

import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;

import java.net.http.HttpClient;

/**
* A {@link Observation.ObservationConvention} for an {@link HttpClient}.
* A {@link ObservationConvention} for an {@link HttpClient}.
*
* @author Marcin Grzejszczak
* @since 1.10.0
*/
public interface HttpClientObservationConvention extends Observation.ObservationConvention<HttpClientContext> {
public interface HttpClientObservationConvention extends ObservationConvention<HttpClientContext> {

@Override
default boolean supportsContext(Observation.Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import io.micrometer.core.instrument.observation.DefaultMeterObservationHandler;
import io.micrometer.core.instrument.search.MeterNotFoundException;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.GlobalObservationConvention;
import io.micrometer.observation.tck.TestObservationRegistry;
import io.micrometer.observation.tck.TestObservationRegistryAssert;
import org.apache.http.client.HttpClient;
Expand Down Expand Up @@ -298,7 +298,7 @@ public String getMethod() {
// TODO add test for status = IO_ERROR case.

static class CustomGlobalApacheHttpConvention extends DefaultApacheHttpClientObservationConvention
implements Observation.GlobalObservationConvention<ApacheHttpClientContext> {
implements GlobalObservationConvention<ApacheHttpClientContext> {

@Override
public String getName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

import io.micrometer.common.KeyValue;
import io.micrometer.common.KeyValues;
import io.micrometer.observation.Observation;
import io.micrometer.observation.KeyValuesConvention;

/**
* Conventions for HTTP key values.
*
* @author Marcin Grzejszczak
* @since 1.10.0
*/
public interface HttpKeyValuesConvention<REQ, RES> extends Observation.KeyValuesConvention {
public interface HttpKeyValuesConvention<REQ, RES> extends KeyValuesConvention {

/**
* HTTP request method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationConvention;
import io.micrometer.observation.tck.TestObservationRegistry;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -55,7 +56,7 @@ void withObservationRegistry() {
.hasLowCardinalityKeyValue("low", "value").hasHighCardinalityKeyValue("high", "value");
}

private static class TestDefaultConvention implements Observation.ObservationConvention<Observation.Context> {
private static class TestDefaultConvention implements ObservationConvention<Observation.Context> {

public static TestDefaultConvention INSTANCE = new TestDefaultConvention();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.micrometer.observation.Observation;
import io.micrometer.observation.ObservationHandler;
import io.micrometer.observation.ObservationRegistry;
import io.micrometer.observation.GlobalObservationConvention;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -644,7 +645,7 @@ static class TestContext extends Observation.Context {

}

static class TestObservationConvention implements Observation.GlobalObservationConvention<TestContext> {
static class TestObservationConvention implements GlobalObservationConvention<TestContext> {

private final String id;

Expand All @@ -669,8 +670,7 @@ public boolean supportsContext(Observation.Context context) {

}

static class TestObservationConventionWithNameOverrides
implements Observation.GlobalObservationConvention<TestContext> {
static class TestObservationConventionWithNameOverrides implements GlobalObservationConvention<TestContext> {

@Nullable
@Override
Expand All @@ -691,8 +691,7 @@ public boolean supportsContext(Observation.Context context) {

}

static class UnsupportedObservationConvention
implements Observation.GlobalObservationConvention<Observation.Context> {
static class UnsupportedObservationConvention implements GlobalObservationConvention<Observation.Context> {

private final String id;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2022 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micrometer.observation;

/**
* An observation convention that will be set on the {@link ObservationRegistry}.
*
* @author Marcin Grzejszczak
* @since 1.10.0
*/
public interface GlobalObservationConvention<T extends Observation.Context> extends ObservationConvention<T> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2022 VMware, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micrometer.observation;

import io.micrometer.common.KeyValues;

/**
* A marker interface for conventions of {@link KeyValues} naming.
*
* @author Marcin Grzejszczak
* @since 1.10.0
*/
public interface KeyValuesConvention {

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import io.micrometer.common.KeyValues;

/**
* No-op implementation of {@link Observation.ObservationConvention} so that we can
* disable the instrumentation logic.
* No-op implementation of {@link ObservationConvention} so that we can disable the
* instrumentation logic.
*
* @author Jonatan Ivanov
* @author Tommy Ludwig
* @author Marcin Grzejszczak
* @since 1.10.0
*/
final class NoopObservationConvention implements Observation.ObservationConvention<Observation.Context> {
final class NoopObservationConvention implements ObservationConvention<Observation.Context> {

/**
* Instance of {@link NoopObservationConvention}.
Expand All @@ -48,17 +48,17 @@ public String getContextualName(Observation.Context context) {

@Override
public boolean supportsContext(Observation.Context context) {
return Observation.ObservationConvention.EMPTY.supportsContext(context);
return ObservationConvention.EMPTY.supportsContext(context);
}

@Override
public KeyValues getLowCardinalityKeyValues(Observation.Context context) {
return Observation.ObservationConvention.EMPTY.getLowCardinalityKeyValues(context);
return ObservationConvention.EMPTY.getLowCardinalityKeyValues(context);
}

@Override
public KeyValues getHighCardinalityKeyValues(Observation.Context context) {
return Observation.ObservationConvention.EMPTY.getHighCardinalityKeyValues(context);
return ObservationConvention.EMPTY.getHighCardinalityKeyValues(context);
}

}
Loading