-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked observability integration to create Observations rather than traces directly. Additional metrics and counters and an Observation.Context to potentially customize the metrics exposed.
- Loading branch information
1 parent
163673a
commit 738ad3f
Showing
20 changed files
with
566 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...java/org/springframework/modulith/observability/DefaultModulithObservationConvention.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.springframework.modulith.observability; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import io.micrometer.common.KeyValues; | ||
|
||
import org.springframework.modulith.observability.ModulithObservations.HighKeys; | ||
import org.springframework.modulith.observability.ModulithObservations.LowKeys; | ||
|
||
/** | ||
* Default implementation of {@link ModulithObservationConvention}. | ||
* | ||
* @author Marcin Grzejszczak | ||
* @since 1.4 | ||
*/ | ||
public class DefaultModulithObservationConvention implements ModulithObservationConvention { | ||
|
||
@Override | ||
public KeyValues getLowCardinalityKeyValues(ModulithContext context) { | ||
KeyValues keyValues = KeyValues.of(LowKeys.MODULE_KEY.withValue(context.getModule().getIdentifier().toString())); | ||
if (isEventListener(context)) { | ||
return keyValues.and(LowKeys.INVOCATION_TYPE.withValue("event-listener")); | ||
} | ||
return keyValues; | ||
} | ||
|
||
private boolean isEventListener(ModulithContext context) { | ||
try { | ||
return context.getModule().isEventListenerInvocation(context.getInvocation()); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public KeyValues getHighCardinalityKeyValues(ModulithContext context) { | ||
Method method = context.getInvocation().getMethod(); | ||
return KeyValues.of(HighKeys.MODULE_METHOD.withValue(method.getName())); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "module.requests"; | ||
} | ||
|
||
@Override | ||
public String getContextualName(ModulithContext context) { | ||
return "[" + context.getApplicationName() + "] " + context.getModule().getDisplayName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.