Skip to content

feat(tracing): Allow storing span metadata #5464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2022
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
8 changes: 6 additions & 2 deletions packages/tracing/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export class Transaction extends SpanClass implements TransactionInterface {

this._name = transactionContext.name || '';

this.metadata = transactionContext.metadata || {};
this.metadata = {
...transactionContext.metadata,
spanMetadata: {},
};

this._trimEnd = transactionContext.trimEnd;

// this is because transactions are also spans, and spans have a transaction pointer
Expand Down Expand Up @@ -89,7 +93,7 @@ export class Transaction extends SpanClass implements TransactionInterface {
/**
* @inheritDoc
*/
public setMetadata(newMetadata: TransactionMetadata): void {
public setMetadata(newMetadata: Partial<TransactionMetadata>): void {
this.metadata = { ...this.metadata, ...newMetadata };
}

Expand Down
7 changes: 5 additions & 2 deletions packages/types/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface TransactionContext extends SpanContext {
/**
* Metadata associated with the transaction, for internal SDK use.
*/
metadata?: TransactionMetadata;
metadata?: Partial<TransactionMetadata>;
}

/**
Expand Down Expand Up @@ -93,7 +93,7 @@ export interface Transaction extends TransactionContext, Span {
* Set metadata for this transaction.
* @hidden
*/
setMetadata(newMetadata: TransactionMetadata): void;
setMetadata(newMetadata: Partial<TransactionMetadata>): void;

/** return the baggage for dynamic sampling and trace propagation */
getBaggage(): Baggage;
Expand Down Expand Up @@ -147,6 +147,9 @@ export interface TransactionMetadata {

/** Information on how a transaction name was generated. */
source?: TransactionSource;

/** Metadata for the transaction's spans, keyed by spanId */
spanMetadata: { [spanId: string]: { [key: string]: unknown } };
}

/**
Expand Down