-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathattributes.dart
35 lines (27 loc) · 1.1 KB
/
attributes.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2021-2022 Workiva.
// Licensed under the Apache License, Version 2.0. Please see https://github.com/Workiva/opentelemetry-dart/blob/master/LICENSE for more information
import '../../../api.dart';
/// A representation of a collection of metadata attached to a trace span.
class Attributes {
Map<String, Object> _attributes = {};
/// Instantiate an empty Attributes.
Attributes.empty() {
_attributes = {};
}
/// Retrieve the value associated with the Attribute with key [key].
Object get(String key) => _attributes[key];
///
int get length => _attributes.length;
/// Retrieve the keys of all Attributes in this collection.
Iterable<String> get keys => _attributes.keys;
/// Add an Attribute [attribute].
/// If an Attribute with the same key already exists, it will be overwritten.
void add(Attribute attribute) {
_attributes[attribute.key] = attribute.value;
}
/// Add all Attributes in List [attributes].
/// If an Attribute with the same key already exists, it will be overwritten.
void addAll(List<Attribute> attributes) {
attributes.forEach(add);
}
}