Skip to content

Commit 735e2f9

Browse files
committed
Log domainUID
1 parent 909d0f3 commit 735e2f9

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

json-schema/src/main/java/oracle/kubernetes/json/YamlDocGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ private List<String> getSortedKeys(Map<String, Object> properties) {
104104

105105
String generateForProperty(String fieldName, Map<String, Object> subSchema) {
106106
return "| "
107-
+ "`" + fieldName + "`"
107+
+ "`"
108+
+ fieldName
109+
+ "`"
108110
+ " | "
109111
+ emptyIfNull(getType(fieldName, subSchema))
110112
+ " | "

operator/src/main/java/oracle/kubernetes/operator/logging/LoggingFormatter.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import java.util.Map;
2020
import java.util.logging.Formatter;
2121
import java.util.logging.LogRecord;
22+
import oracle.kubernetes.operator.helpers.DomainPresenceInfo;
2223
import oracle.kubernetes.operator.work.Fiber;
24+
import oracle.kubernetes.operator.work.Packet;
2325

2426
/** Custom log formatter to format log messages in JSON format. */
2527
public class LoggingFormatter extends Formatter {
@@ -29,6 +31,7 @@ public class LoggingFormatter extends Formatter {
2931
private static final String TIMESTAMP = "timestamp";
3032
private static final String THREAD = "thread";
3133
private static final String FIBER = "fiber";
34+
private static final String DOMAIN_UID = "domainUID";
3235
private static final String SOURCE_CLASS = "class";
3336
private static final String SOURCE_METHOD = "method";
3437
private static final String TIME_IN_MILLIS = "timeInMillis";
@@ -109,6 +112,7 @@ public String format(LogRecord record) {
109112
map.put(TIMESTAMP, dateString);
110113
map.put(THREAD, thread);
111114
map.put(FIBER, fiber != null ? fiber.toString() : "");
115+
map.put(DOMAIN_UID, getDomainUID(fiber));
112116
map.put(LOG_LEVEL, level);
113117
map.put(SOURCE_CLASS, sourceClassName);
114118
map.put(SOURCE_METHOD, sourceMethodName);
@@ -138,4 +142,21 @@ public String format(LogRecord record) {
138142
}
139143
return json + "\n";
140144
}
145+
146+
/**
147+
* Get the domain UID currently being used by the step executing for the Fiber.
148+
*
149+
* @param fiber The current Fiber
150+
* @return the domain UID or empty string
151+
*/
152+
private String getDomainUID(Fiber fiber) {
153+
154+
Packet packet = fiber == null ? null : fiber.getPacket();
155+
if (packet != null) {
156+
DomainPresenceInfo info = packet.getSPI(DomainPresenceInfo.class);
157+
return info == null ? "" : info.getDomainUID();
158+
} else {
159+
return "";
160+
}
161+
}
141162
}

0 commit comments

Comments
 (0)