-
-
Notifications
You must be signed in to change notification settings - Fork 279
feat: trace connected metrics #3450
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
base: main
Are you sure you want to change the base?
Changes from 34 commits
1a4b78b
3897122
2c617bb
6ef8c3c
3ca4c08
9b34042
e0b564c
6da49c8
1b97198
82a4374
1a48756
1081ca3
ffd9fc7
b56a272
586ae3d
26d0577
1f7ba8f
33f991f
b6bff0d
95fb48d
435917d
07b5051
875ca84
b5eee19
61bb4bc
5b55d0a
264f72b
f49e371
5cfeba6
ee01dbb
fbfcc74
c7ca90c
7f3b491
c4221aa
2a553a2
ba9930c
e3e55a5
e92efaf
d530afc
eb2cad9
3282f7a
71e67b7
cd836b5
2648213
98f48fd
747259d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,6 +129,21 @@ class SentryEnvelope { | |
| ); | ||
| } | ||
|
|
||
| /// Create a [SentryEnvelope] containing raw metric data payload. | ||
| /// This is used by the log batcher to send pre-encoded metric batches. | ||
| @internal | ||
| factory SentryEnvelope.fromMetricsData( | ||
| List<List<int>> encodedMetrics, | ||
| SdkVersion sdkVersion, | ||
| ) => | ||
| SentryEnvelope( | ||
| SentryEnvelopeHeader(null, sdkVersion), | ||
| [ | ||
| SentryEnvelopeItem.fromMetricsData( | ||
| _buildItemsPayload(encodedMetrics), encodedMetrics.length) | ||
| ], | ||
| ); | ||
|
|
||
| /// Stream binary data representation of `Envelope` file encoded. | ||
| Stream<List<int>> envelopeStream(SentryOptions options) async* { | ||
| yield utf8JsonEncoder.convert(header.toJson()); | ||
|
|
@@ -160,6 +175,20 @@ class SentryEnvelope { | |
| } | ||
| } | ||
|
|
||
| /// Builds a payload in the format {"items": [item1, item2, ...]} | ||
| static Uint8List _buildItemsPayload(List<List<int>> encodedItems) { | ||
buenaflor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| final builder = BytesBuilder(copy: false); | ||
| builder.add(utf8.encode('{"items":[')); | ||
| for (int i = 0; i < encodedItems.length; i++) { | ||
| if (i > 0) { | ||
| builder.add(utf8.encode(',')); | ||
| } | ||
| builder.add(encodedItems[i]); | ||
| } | ||
| builder.add(utf8.encode(']}')); | ||
| return builder.takeBytes(); | ||
| } | ||
|
Comment on lines
+162
to
+174
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is taken from the span-first branch |
||
|
|
||
| /// Add an envelope item containing client report data. | ||
| void addClientReport(ClientReport? clientReport) { | ||
| if (clientReport != null) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,5 +6,6 @@ class SentryItemType { | |
| static const String profile = 'profile'; | ||
| static const String statsd = 'statsd'; | ||
| static const String log = 'log'; | ||
| static const String metric = 'trace_metric'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to update naming, this should also be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can keep it as metric:
|
||
| static const String unknown = '__unknown__'; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other types are called like the raw value, so in this case it should be 'traceMetric'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep it as metrics as per spec: