Skip to content

Commit 2bd0e54

Browse files
authored
Document Jakarta Mail instrumentation (#7256)
* add a new reference page for Jakarta Mail instrumentation * register the page in docs navigation * add Jakarta Mail to the Observation instrumented projects table Closes gh-6485 Signed-off-by: ddingjoo <ddingsha9@teambind.co.kr>
1 parent 12d451c commit 2bd0e54

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

docs/modules/ROOT/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
** xref:reference/jms.adoc[JMS]
5050
** xref:reference/jvm.adoc[JVM]
5151
** xref:reference/kafka.adoc[Kafka]
52+
** xref:reference/mail.adoc[Jakarta Mail]
5253
** xref:reference/logging.adoc[Logging]
5354
** xref:reference/mongodb.adoc[MongoDB]
5455
** xref:reference/netty.adoc[Netty]

docs/modules/ROOT/pages/observation/projects.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Micrometer Observation is used to instrument various projects. Below you can fin
2323
| Jersey | https://github.com/eclipse-ee4j/jersey/pull/5391[PR]
2424
| Jetty | https://github.com/micrometer-metrics/micrometer/pull/3416[PR]
2525
| JMS | https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/jms/JmsInstrumentation.java[Repo]
26+
| Jakarta Mail | https://github.com/micrometer-metrics/micrometer/tree/main/micrometer-jakarta9/src/main/java/io/micrometer/jakarta9/instrument/mail[Repo]
2627
| Kotlin Coroutines | https://github.com/micrometer-metrics/micrometer/pull/3256[PR]
2728
| Lettuce | https://github.com/lettuce-io/lettuce-core/commit/6604fbe9e9cff476806c50716e17803e11d1e0ca[Commit]
2829
| Micronaut | https://github.com/micronaut-projects/micronaut-micrometer/issues/492[Issue]
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
[[overview]]
2+
= Jakarta Mail Instrumentation
3+
4+
Micrometer provides Jakarta Mail instrumentation.
5+
6+
== Installing
7+
8+
It is recommended to use the BOM provided by Micrometer (or your framework if any), you can see how to configure it xref:../installing.adoc[here]. The examples below assume you are using a BOM.
9+
10+
=== Gradle
11+
12+
After the BOM is xref:../installing.adoc[configured], add the following dependency:
13+
14+
[source,groovy]
15+
----
16+
implementation 'io.micrometer:micrometer-jakarta9'
17+
----
18+
19+
NOTE: The version is not needed for this dependency since it is defined by the BOM.
20+
21+
=== Maven
22+
23+
After the BOM is xref:../installing.adoc[configured], add the following dependency:
24+
25+
[source,xml]
26+
----
27+
<dependency>
28+
<groupId>io.micrometer</groupId>
29+
<artifactId>micrometer-jakarta9</artifactId>
30+
</dependency>
31+
----
32+
33+
NOTE: The version is not needed for this dependency since it is defined by the BOM.
34+
35+
== Usage
36+
37+
Here is how a Jakarta Mail `Transport` can be instrumented for observability:
38+
39+
[source,java]
40+
----
41+
import io.micrometer.jakarta9.instrument.mail.InstrumentedTransport;
42+
43+
Session session = Session.getInstance(new Properties());
44+
ObservationRegistry registry = ...
45+
46+
Transport original = session.getTransport("smtp");
47+
Transport transport = new InstrumentedTransport(session, original, registry);
48+
49+
transport.connect("smtp.example.com", 587, "username", "password");
50+
51+
MimeMessage message = new MimeMessage(session);
52+
message.setFrom("from@example.com");
53+
message.setRecipients(Message.RecipientType.TO, "to@example.com");
54+
message.setSubject("Hello");
55+
message.setText("Mail from Micrometer instrumentation");
56+
57+
// this operation will create a "mail.send" observation
58+
transport.sendMessage(message, message.getAllRecipients());
59+
----
60+
61+
== Observations
62+
63+
This instrumentation creates the `"mail.send"` observation when
64+
`jakarta.mail.Transport.sendMessage` is called.
65+
66+
.Low cardinality keys
67+
[cols="a,a"]
68+
|===
69+
|Name | Description
70+
|`server.address` |(SMTP) server address used for sending mails.
71+
|`server.port` |(SMTP) server port used for sending mails.
72+
|`network.protocol.name` |Network protocol used for sending mails.
73+
|===
74+
75+
.High cardinality keys
76+
[cols="a,a"]
77+
|===
78+
|Name | Description
79+
|`smtp.message.from` |Sender of the mail.
80+
|`smtp.message.to` |Primary (TO) recipient(s) of the mail.
81+
|`smtp.message.cc` |Carbon copy (CC) recipient(s) of the mail.
82+
|`smtp.message.bcc` |Blind carbon copy (BCC) recipient(s) of the mail.
83+
|`smtp.message.newsgroups` |Newsgroup (Usenet news) recipient(s) of the mail.
84+
|`smtp.message.subject` |Subject line of the mail.
85+
|`smtp.message.id` |Message ID received from the SMTP server.
86+
|===

0 commit comments

Comments
 (0)