Skip to content

Commit

Permalink
add to span context
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jun 20, 2023
1 parent 5edb1b2 commit 5fe8c6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dart/lib/src/sentry_span_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SentrySpanContext {
/// consistent across instances of the span.
final String? description;

final String? origin;

/// Item encoded as JSON
Map<String, dynamic> toJson() {
return {
Expand All @@ -28,6 +30,7 @@ class SentrySpanContext {
'op': operation,
if (parentSpanId != null) 'parent_span_id': parentSpanId.toString(),
if (description != null) 'description': description,
if (origin != null) 'origin': origin,
};
}

Expand All @@ -37,6 +40,7 @@ class SentrySpanContext {
this.parentSpanId,
required this.operation,
this.description,
this.origin,
}) : traceId = traceId ?? SentryId.newId(),
spanId = spanId ?? SpanId.newId();

Expand All @@ -53,6 +57,7 @@ class SentrySpanContext {
parentSpanId: parentSpanId,
sampled: sampled,
status: status,
origin: origin,
);
}
}
5 changes: 4 additions & 1 deletion dart/test/sentry_span_context_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ void main() {
expect(map['op'], 'op');
expect(map['parent_span_id'], isNotNull);
expect(map['description'], 'desc');
expect(map['origin'], 'manual');
});

test('toTraceContext gets sampled and status', () {
test('toTraceContext gets sampled, status, and origin', () {
final sut = fixture.getSut();
final aborted = SpanStatus.aborted();
final traceContext = sut.toTraceContext(
Expand All @@ -31,6 +32,7 @@ void main() {
expect(traceContext.parentSpanId, isNotNull);
expect(traceContext.description, 'desc');
expect(traceContext.status, aborted);
expect(traceContext.origin, 'manual');
});
}

Expand All @@ -40,6 +42,7 @@ class Fixture {
operation: 'op',
parentSpanId: SpanId.newId(),
description: 'desc',
origin: 'manual'
);
}
}

0 comments on commit 5fe8c6e

Please sign in to comment.