-
Notifications
You must be signed in to change notification settings - Fork 35
/
meter_provider.dart
40 lines (33 loc) · 1.34 KB
/
meter_provider.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
36
37
38
39
40
import 'package:opentelemetry/api.dart' as api;
import 'package:opentelemetry/src/experimental_api.dart' as api;
import 'package:opentelemetry/src/experimental_sdk.dart' as sdk;
import 'package:logging/logging.dart';
import 'package:opentelemetry/src/sdk/common/instrumentation_scope.dart';
import 'package:opentelemetry/src/sdk/metrics/state/meter_provider_shared_state.dart';
const invalidMeterNameMessage = 'Invalid Meter Name';
class MeterProvider implements api.MeterProvider {
final _logger = Logger('opentelemetry.sdk.metrics.meterprovider');
final _shutdown = false;
final MeterProviderSharedState _sharedState;
sdk.Resource get resource => _sharedState.resource;
MeterProvider({sdk.Resource resource})
: _sharedState = MeterProviderSharedState(resource);
@override
api.Meter get(String name,
{String version = '',
String schemaUrl = '',
List<api.Attribute> attributes = const []}) {
if (name == null || name == '') {
name = '';
_logger.warning(invalidMeterNameMessage, '', StackTrace.current);
}
if (_shutdown) {
_logger.warning('A shutdown MeterProvider cannot provide a Meter', '',
StackTrace.current);
return api.NoopMeter();
}
return _sharedState
.getMeterSharedState(InstrumentationScope(name, version, schemaUrl, attributes))
.meter;
}
}