From 5fe8c6e49dd9df628e6c7e5a5c684b126a7ea57c Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 20 Jun 2023 11:20:31 +0200 Subject: [PATCH] add to span context --- dart/lib/src/sentry_span_context.dart | 5 +++++ dart/test/sentry_span_context_test.dart | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dart/lib/src/sentry_span_context.dart b/dart/lib/src/sentry_span_context.dart index 253ae53977..56fcdb7170 100644 --- a/dart/lib/src/sentry_span_context.dart +++ b/dart/lib/src/sentry_span_context.dart @@ -20,6 +20,8 @@ class SentrySpanContext { /// consistent across instances of the span. final String? description; + final String? origin; + /// Item encoded as JSON Map toJson() { return { @@ -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, }; } @@ -37,6 +40,7 @@ class SentrySpanContext { this.parentSpanId, required this.operation, this.description, + this.origin, }) : traceId = traceId ?? SentryId.newId(), spanId = spanId ?? SpanId.newId(); @@ -53,6 +57,7 @@ class SentrySpanContext { parentSpanId: parentSpanId, sampled: sampled, status: status, + origin: origin, ); } } diff --git a/dart/test/sentry_span_context_test.dart b/dart/test/sentry_span_context_test.dart index 22d7657a00..f19b867554 100644 --- a/dart/test/sentry_span_context_test.dart +++ b/dart/test/sentry_span_context_test.dart @@ -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( @@ -31,6 +32,7 @@ void main() { expect(traceContext.parentSpanId, isNotNull); expect(traceContext.description, 'desc'); expect(traceContext.status, aborted); + expect(traceContext.origin, 'manual'); }); } @@ -40,6 +42,7 @@ class Fixture { operation: 'op', parentSpanId: SpanId.newId(), description: 'desc', + origin: 'manual' ); } }