Skip to content

Commit

Permalink
Moved Event back to Observation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Aug 25, 2022
1 parent ba79927 commit c5e12fe
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ public static void updateKeyValuesFromEnum(JavaEnumImpl parentEnum, JavaSource<?
return;
}
JavaEnumImpl myEnum = (JavaEnumImpl) source;
if (!myEnum.getInterfaces().contains(requiredClass.getCanonicalName())) {
String name = requiredClass.getName(); // requiredClass.getCanonicalName()
if (name.contains("$")) {
name = requiredClass.getName().substring(requiredClass.getName().lastIndexOf(".") + 1).replace("$", ".");
}
if (!myEnum.getInterfaces().contains(name)) {
return;
}
logger.debug("Checking [" + parentEnum.getName() + "." + myEnum.getName() + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.micrometer.common.Event;
import io.micrometer.common.docs.KeyName;
import io.micrometer.common.util.internal.logging.InternalLogger;
import io.micrometer.common.util.internal.logging.InternalLoggerFactory;
Expand Down Expand Up @@ -240,7 +239,7 @@ else if ("overridesDefaultMetricFrom".equals(methodName)) {
overridesDefaultMetricFrom = ParsingUtils.readClassToEnum(methodDeclaration);
}
else if ("getEvents".equals(methodName)) {
Collection<KeyValueEntry> entries = ParsingUtils.keyValueEntries(myEnum, methodDeclaration, Event.class, "getName");
Collection<KeyValueEntry> entries = ParsingUtils.keyValueEntries(myEnum, methodDeclaration, Observation.Event.class, "getName");
Collection<MetricEntry> counters = entries.stream().map(k -> new MetricEntry(k.getName(), null, null, myEnum.getCanonicalName(), enumConstant.getName(), k.getDescription(), null, null, Meter.Type.COUNTER, new TreeSet<>(), new TreeSet<>(), null, new TreeSet<>())).collect(Collectors.toList());
events.addAll(counters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.micrometer.docs.metrics;

import io.micrometer.common.Event;
import io.micrometer.observation.Observation;
import io.micrometer.observation.docs.DocumentedObservation;

enum EventObservation implements DocumentedObservation {
Expand All @@ -36,15 +36,15 @@ public String getContextualName() {
}

@Override
public Event[] getEvents() {
public Observation.Event[] getEvents() {
return Events.values();
}
};

/**
* Observation events.
*/
enum Events implements Event {
enum Events implements Observation.Event {

/**
* Start event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.micrometer.common.Event;
import io.micrometer.common.docs.KeyName;
import io.micrometer.common.util.internal.logging.InternalLogger;
import io.micrometer.common.util.internal.logging.InternalLoggerFactory;
Expand Down Expand Up @@ -248,7 +247,7 @@ else if ("getEvents".equals(methodName)) {
if (methodDeclaration.getReturnType2().toString().contains("EventValue")) {
events.addAll(ParsingUtils.keyValueEntries(myEnum, methodDeclaration, EventValue.class));
} else {
events.addAll(ParsingUtils.keyValueEntries(myEnum, methodDeclaration, Event.class, "getContextualName"));
events.addAll(ParsingUtils.keyValueEntries(myEnum, methodDeclaration, Observation.Event.class, "getContextualName"));
}
}
else if ("getPrefix".equals(methodName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package io.micrometer.docs.spans.test1;

import io.micrometer.common.Event;
import io.micrometer.observation.Observation;
import io.micrometer.observation.docs.DocumentedObservation;

enum EventObservation implements DocumentedObservation {
Expand All @@ -36,15 +36,15 @@ public String getContextualName() {
}

@Override
public Event[] getEvents() {
public Observation.Event[] getEvents() {
return Events.values();
}
};

/**
* Observation events.
*/
enum Events implements Event {
enum Events implements Observation.Event {

/**
* Start event.
Expand Down

0 comments on commit c5e12fe

Please sign in to comment.