Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apm-agent-api/src/main/java/co/elastic/apm/api/Span.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package co.elastic.apm.api;

/**
* A span contains information about a specific code path, executed as part of a {@link Transaction}.
* <p>
* If for example a database query happens within a recorded transaction,
* a span representing this database query may be created.
* In such a case the name of the span will contain information about the query itself,
* and the type will hold information about the database type.
* </p>
*/
public interface Span extends AutoCloseable {

/**
* The name of the transaction.
* The name of the span.
*
* @param name the name of the span
*/
Expand All @@ -30,7 +39,7 @@ public interface Span extends AutoCloseable {
void end();

/**
* An alias for {@link #end()}
* An alias for {@link #end()} to make a {@link Span} work in try-with-resources statements.
*/
@Override
void close();
Expand Down
29 changes: 22 additions & 7 deletions apm-agent-api/src/main/java/co/elastic/apm/api/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package co.elastic.apm.api;

/**
* Data captured by an agent representing an event occurring in a monitored service
*/
public interface Transaction extends AutoCloseable {

String TYPE_REQUEST = "request";
Expand All @@ -14,7 +17,7 @@ public interface Transaction extends AutoCloseable {
* Transactions with the same name and type are grouped together.
* </p>
*
* @param name
* @param name The name of the transaction.
*/
void setName(String name);

Expand All @@ -25,11 +28,23 @@ public interface Transaction extends AutoCloseable {
* when an incoming HTTP request is detected.
* </p>
*
* @param type
* @param type The type of the transaction.
*/
void setType(String type);


/**
* A flat mapping of user-defined tags with string values.
* <p>
* Note: the tags are indexed in Elasticsearch so that they are searchable and aggregatable.
* By all means,
* you should avoid that user specified data,
* like URL parameters,
* is used as a tag key as it can lead to mapping explosions.
* </p>
*
* @param key The tag key.
* @param value The tag value.
*/
void addTag(String key, String value);

/**
Expand All @@ -48,9 +63,9 @@ public interface Transaction extends AutoCloseable {
* </p>
* The provided user context is stored under context.user in Elasticsearch on both errors and transactions.
*
* @param id the user's id or <code>null</code>, if not applicable
* @param email the user's email address or <code>null</code>, if not applicable
* @param username the user's name or <code>null</code>, if not applicable
* @param id The user's id or <code>null</code>, if not applicable.
* @param email The user's email address or <code>null</code>, if not applicable.
* @param username The user's name or <code>null</code>, if not applicable.
*/
void setUser(String id, String email, String username);

Expand All @@ -60,7 +75,7 @@ public interface Transaction extends AutoCloseable {
void end();

/**
* An alias for {@link #end()}
* An alias for {@link #end()} to make a {@link Transaction} work in try-with-resources statements.
*/
@Override
void close();
Expand Down