-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add SpanLimits, implement maxNumAttributes and maxNumAttributeLength
fix warnings adjust attributes.dart file, allow limits to set zero Change rebuildAttribute part of job to attribute.dart Remove access of span.attributes Keep old apis
- Loading branch information
1 parent
a57c636
commit 100448a
Showing
13 changed files
with
423 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,48 @@ | ||
import 'package:opentelemetry/src/sdk/internal/utils.dart'; | ||
|
||
/// A representation of a single piece of metadata attached to trace span. | ||
class Attribute { | ||
final String key; | ||
final Object value; | ||
|
||
/// Create an Attribute from a String value. | ||
Attribute.fromString(this.key, String this.value); | ||
Attribute.fromString(this.key, String this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a boolean value. | ||
// ignore: avoid_positional_boolean_parameters | ||
Attribute.fromBoolean(this.key, bool this.value); | ||
Attribute.fromBoolean(this.key, bool this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a double-precision floating-point value. | ||
Attribute.fromDouble(this.key, double this.value); | ||
Attribute.fromDouble(this.key, double this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from an integer value. | ||
Attribute.fromInt(this.key, int this.value); | ||
Attribute.fromInt(this.key, int this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a list of String values. | ||
Attribute.fromStringList(this.key, List<String> this.value); | ||
Attribute.fromStringList(this.key, List<String> this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a list of boolean values. | ||
Attribute.fromBooleanList(this.key, List<bool> this.value); | ||
Attribute.fromBooleanList(this.key, List<bool> this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a list of double-precision floating-point values. | ||
Attribute.fromDoubleList(this.key, List<double> this.value); | ||
Attribute.fromDoubleList(this.key, List<double> this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
|
||
/// Create an Attribute from a list of integer values. | ||
Attribute.fromIntList(this.key, List<int> this.value); | ||
Attribute.fromIntList(this.key, List<int> this.value) { | ||
Utils.checkArgument(key != null, "key can't be null"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Utils { | ||
///Check argument | ||
// ignore: avoid_positional_boolean_parameters | ||
static void checkArgument(bool isValid, String errorMessage) { | ||
if (!isValid) throw ArgumentError(errorMessage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import '../internal/utils.dart'; | ||
|
||
class SpanLimits { | ||
final _DEFAULT_MAXNUM_ATTRIBUTES = 200; | ||
final _DEFAULT_MAXNUM_EVENTS = 128; | ||
final _DEFAULT_MAXNUM_LINKS = 128; | ||
final _DEFAULT_MAXNUM_ATTRIBUTE_PER_EVENT = 128; | ||
final _DEFAULT_MAXNUM_ATTRIBUTES_PER_LINK = 128; | ||
final _DEFAULT_MAXNUM_ATTRIBUTES_LENGTH = 1000; | ||
|
||
int _maxNumAttributes; | ||
int _maxNumEvents; | ||
int _maxNumLink; | ||
int _maxNumAttributesPerEvent; | ||
int _maxNumAttributesPerLink; | ||
int _maxNumAttributeLength; | ||
|
||
///setters | ||
set maxNumAttributes(int maxNumberOfAttributes) { | ||
Utils.checkArgument(maxNumberOfAttributes >= 0, | ||
'maxNumberOfAttributes must be greater or equal to zero'); | ||
_maxNumAttributes = maxNumberOfAttributes; | ||
} | ||
|
||
set maxNumEvents(int maxNumEvents) { | ||
Utils.checkArgument( | ||
maxNumEvents >= 0, 'maxNumEvents must be greater or equal to zero'); | ||
_maxNumEvents = maxNumEvents; | ||
} | ||
|
||
set maxNumLink(int maxNumLink) { | ||
Utils.checkArgument( | ||
maxNumLink >= 0, 'maxNumLink must be greater or equal to zero'); | ||
_maxNumLink = maxNumLink; | ||
} | ||
|
||
set maxNumAttributesPerEvent(int maxNumAttributesPerEvent) { | ||
Utils.checkArgument(maxNumAttributesPerEvent >= 0, | ||
'maxNumAttributesPerEvent must be greater or equal to zero'); | ||
_maxNumAttributesPerEvent = maxNumAttributesPerEvent; | ||
} | ||
|
||
set maxNumAttributesPerLink(int maxNumAttributesPerLink) { | ||
Utils.checkArgument(maxNumAttributesPerLink >= 0, | ||
'maxNumAttributesPerLink must be greater or equal to zero'); | ||
_maxNumAttributesPerLink = maxNumAttributesPerLink; | ||
} | ||
|
||
set maxNumAttributeLength(int maxNumAttributeLength) { | ||
Utils.checkArgument(maxNumAttributesPerLink >= 0, | ||
'maxNumAttributesPerLink must be greater or equal to zero'); | ||
_maxNumAttributeLength = maxNumAttributeLength; | ||
} | ||
|
||
///getters | ||
int get maxNumAttributes => _maxNumAttributes; | ||
int get maxNumEvents => _maxNumEvents; | ||
int get maxNumLink => _maxNumLink; | ||
int get maxNumAttributesPerEvent => _maxNumAttributesPerEvent; | ||
int get maxNumAttributesPerLink => _maxNumAttributesPerLink; | ||
int get maxNumAttributeLength => _maxNumAttributeLength; | ||
|
||
///constructor | ||
///https://docs.newrelic.com/docs/data-apis/manage-data/view-system-limits/ | ||
///https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk/trace/src/main/java/io/opentelemetry/sdk/trace/SpanLimitsBuilder.java | ||
SpanLimits( | ||
{int maxNumAttributes, | ||
int maxNumEvents, | ||
int maxNumLink, | ||
int maxNumAttributesPerEvent, | ||
int maxNumAttributesPerLink, | ||
int maxNumAttributeLength}) { | ||
_maxNumAttributes = maxNumAttributes ?? _DEFAULT_MAXNUM_ATTRIBUTES; | ||
_maxNumEvents = maxNumEvents ?? _DEFAULT_MAXNUM_EVENTS; | ||
_maxNumLink = maxNumLink ?? _DEFAULT_MAXNUM_LINKS; | ||
_maxNumAttributesPerEvent = | ||
maxNumAttributesPerEvent ?? _DEFAULT_MAXNUM_ATTRIBUTE_PER_EVENT; | ||
_maxNumAttributesPerLink = | ||
maxNumAttributesPerLink ?? _DEFAULT_MAXNUM_ATTRIBUTES_PER_LINK; | ||
_maxNumAttributeLength = | ||
maxNumAttributeLength ?? _DEFAULT_MAXNUM_ATTRIBUTES_LENGTH; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.