Skip to content

Commit

Permalink
add origin to SentryTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jun 26, 2023
1 parent f2d527a commit cf9ff62
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions dart/lib/src/sentry_trace_origins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ class SentryTraceOrigins {
static const autoNavigationSentryNavigatorObserver = 'auto.navigation.sentry_navigator_observer';
static const autoHttpHttpTracingClient = 'auto.http.http.tracing_client';
static const autoHttpDioTracingClientAdapter = 'auto.http.dio.tracing_client_adapter';
static const autoHttpDioSentryTransformer = 'auto.http.dio.sentry_transformer';
static const autoFileAssetBundle = 'auto.file.asset_bundle';
}
6 changes: 6 additions & 0 deletions dio/lib/src/sentry_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class SentryTransformer implements Transformer {
);

span?.setData('http.method', options.method);
// ignore: invalid_use_of_internal_member
span?.origin = SentryTraceOrigins.autoHttpDioSentryTransformer;

urlDetails?.applyToSpan(span);

String? request;
Expand Down Expand Up @@ -63,6 +66,9 @@ class SentryTransformer implements Transformer {
);

span?.setData('http.method', options.method);
// ignore: invalid_use_of_internal_member
span?.origin = SentryTraceOrigins.autoHttpDioSentryTransformer;

urlDetails?.applyToSpan(span);

dynamic transformedResponse;
Expand Down
5 changes: 5 additions & 0 deletions dio/test/sentry_transformer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ void main() {
expect(span.data['url'], 'https://example.com');
expect(span.data['http.query'], 'foo=bar');
expect(span.data['http.fragment'], 'baz');
expect(span.data['http.fragment'], 'baz');
expect(span.origin, SentryTraceOrigins.autoHttpDioSentryTransformer);
});

test('transformRequest finish span if errored request', () async {
Expand Down Expand Up @@ -70,6 +72,7 @@ void main() {
expect(span.data['http.query'], 'foo=bar');
expect(span.data['http.fragment'], 'baz');
expect(span.finished, true);
expect(span.origin, SentryTraceOrigins.autoHttpDioSentryTransformer);
});

test('transformResponse creates span', () async {
Expand Down Expand Up @@ -97,6 +100,7 @@ void main() {
expect(span.data['url'], 'https://example.com');
expect(span.data['http.query'], 'foo=bar');
expect(span.data['http.fragment'], 'baz');
expect(span.origin, SentryTraceOrigins.autoHttpDioSentryTransformer);
});

test('transformResponse finish span if errored request', () async {
Expand Down Expand Up @@ -127,6 +131,7 @@ void main() {
expect(span.data['http.query'], 'foo=bar');
expect(span.data['http.fragment'], 'baz');
expect(span.finished, true);
expect(span.origin, SentryTraceOrigins.autoHttpDioSentryTransformer);
});
});
}
Expand Down

0 comments on commit cf9ff62

Please sign in to comment.