Skip to content

Commit 67a6bf8

Browse files
committed
Move getContextualContext to conventions.
1 parent 19bddd2 commit 67a6bf8

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/DefaultKafkaListenerObservationConvention.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public KeyValues getHighCardinalityKeyValues(KafkaRecordReceiverContext context)
4444
return KeyValues.empty();
4545
}
4646

47+
@Override
48+
public String getContextualName(KafkaRecordReceiverContext context) {
49+
return context.getSource() + " receive";
50+
}
51+
4752
}

spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/DefaultKafkaTemplateObservationConvention.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public KeyValues getHighCardinalityKeyValues(KafkaRecordSenderContext context) {
4444
return KeyValues.empty();
4545
}
4646

47+
@Override
48+
public String getContextualName(KafkaRecordSenderContext context) {
49+
return context.getDestination() + " send";
50+
}
51+
4752
}

spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordReceiverContext.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ public String getName() {
5858
return "spring.kafka.listener";
5959
}
6060

61-
@Override
62-
public String getContextualName() {
63-
return this.record.topic() + " receive";
61+
/**
62+
* Return the source topic.
63+
* @return the source.
64+
*/
65+
public String getSource() {
66+
return this.record.topic();
6467
}
6568

6669
}

spring-kafka/src/main/java/org/springframework/kafka/support/micrometer/KafkaRecordSenderContext.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ public String getName() {
5151
return "spring.kafka.template";
5252
}
5353

54-
@Override
55-
public String getContextualName() {
56-
return this.destination + " send";
54+
/**
55+
* Return the destination topic.
56+
* @return the topic.
57+
*/
58+
public String getDestination() {
59+
return this.destination;
5760
}
5861

5962
}

0 commit comments

Comments
 (0)