-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92a84a6
commit aa95d5a
Showing
11 changed files
with
242 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 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 | ||
|
||
class ExportResult { | ||
final ExportResultCode code; | ||
final Exception? error; | ||
final StackTrace? stackTrace; | ||
|
||
ExportResult({required this.code, this.error, this.stackTrace}); | ||
} | ||
|
||
enum ExportResultCode { | ||
success, | ||
failed, | ||
} |
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,102 @@ | ||
// 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 'package:opentelemetry/api.dart' as api; | ||
import 'package:opentelemetry/sdk.dart' as sdk; | ||
|
||
enum Severity { | ||
unspecified, | ||
trace, | ||
trace2, | ||
trace3, | ||
trace4, | ||
debug, | ||
debug2, | ||
debug3, | ||
debug4, | ||
info, | ||
info2, | ||
info3, | ||
info4, | ||
warn, | ||
warn2, | ||
warn3, | ||
warn4, | ||
error, | ||
error2, | ||
error3, | ||
error4, | ||
fatal, | ||
fatal2, | ||
fatal3, | ||
fatal4, | ||
} | ||
|
||
abstract class LogRecord { | ||
factory LogRecord({ | ||
sdk.Attributes? attributes, | ||
api.Context? context, | ||
dynamic body, | ||
DateTime? observedTimestamp, | ||
Severity? severityNumber, | ||
String? severityText, | ||
DateTime? timeStamp, | ||
}) => | ||
_LogRecord( | ||
attributes: attributes, | ||
severityText: severityText, | ||
context: context, | ||
body: body, | ||
observedTimestamp: observedTimestamp, | ||
severityNumber: severityNumber, | ||
timeStamp: timeStamp, | ||
); | ||
|
||
DateTime? get timeStamp; | ||
|
||
DateTime? get observedTimestamp; | ||
|
||
Severity? get severityNumber; | ||
|
||
String? get severityText; | ||
|
||
dynamic get body; | ||
|
||
sdk.Attributes get attributes; | ||
|
||
api.Context get context; | ||
} | ||
|
||
class _LogRecord implements LogRecord { | ||
@override | ||
final sdk.Attributes attributes; | ||
|
||
@override | ||
final api.Context context; | ||
|
||
@override | ||
final dynamic body; | ||
|
||
@override | ||
final DateTime? observedTimestamp; | ||
|
||
@override | ||
final Severity? severityNumber; | ||
|
||
@override | ||
final String? severityText; | ||
|
||
@override | ||
final DateTime? timeStamp; | ||
|
||
_LogRecord({ | ||
this.severityText, | ||
this.body, | ||
this.observedTimestamp, | ||
this.severityNumber, | ||
this.timeStamp, | ||
sdk.Attributes? attributes, | ||
api.Context? context, | ||
}) : attributes = attributes ?? sdk.Attributes.empty(), | ||
context = context ?? api.Context.current; | ||
} |
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,8 @@ | ||
// 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 'log_record.dart'; | ||
|
||
abstract class Logger { | ||
void emit(LogRecord logRecord); | ||
} |
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,25 @@ | ||
// 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 'package:opentelemetry/api.dart'; | ||
import 'package:opentelemetry/src/api/logs/logger.dart'; | ||
|
||
abstract class LoggerProvider { | ||
/// Gets or creates a [Logger] instance. | ||
/// | ||
/// The meter is identified by the combination of [name], [version], | ||
/// [schemaUrl] and [attributes]. The [name] SHOULD uniquely identify the | ||
/// instrumentation scope, such as the instrumentation library | ||
/// (e.g. io.opentelemetry.contrib.mongodb), package, module or class name. | ||
/// The [version] specifies the version of the instrumentation scope if the | ||
/// scope has a version (e.g. a library version). The [schemaUrl] identifies | ||
/// the schema this provider adheres to. The [attributes] specifies | ||
/// attributes to associate with emitted telemetry. | ||
Logger get( | ||
String name, { | ||
String version = '', | ||
String schemaUrl = '', | ||
List<Attribute> attributes = const [], | ||
bool? includeTraceContext, | ||
}); | ||
} |
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,11 @@ | ||
// 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 'package:opentelemetry/src/api/logs/logger.dart'; | ||
import 'package:opentelemetry/src/api/logs/log_record.dart'; | ||
|
||
class NoopLogger implements Logger { | ||
const NoopLogger(); | ||
@override | ||
void emit(LogRecord logRecord) {} | ||
} |
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,19 @@ | ||
// 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 'package:opentelemetry/src/api/common/attribute.dart'; | ||
import 'package:opentelemetry/src/api/logs/logger.dart'; | ||
import 'package:opentelemetry/src/api/logs/logger_provider.dart'; | ||
import 'package:opentelemetry/src/api/logs/noop/noop_logger.dart'; | ||
|
||
class NoopLoggerProvider implements LoggerProvider { | ||
@override | ||
Logger get( | ||
String name, { | ||
String version = '', | ||
String schemaUrl = '', | ||
List<Attribute> attributes = const [], | ||
bool? includeTraceContext, | ||
}) => | ||
const NoopLogger(); | ||
} |
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,28 @@ | ||
// 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 | ||
|
||
@TestOn('vm') | ||
import 'package:opentelemetry/api.dart' as api; | ||
import 'package:opentelemetry/sdk.dart' as sdk; | ||
import 'package:opentelemetry/src/experimental_api.dart' as api; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('Verify context create root by default', () { | ||
final logRecord = api.LogRecord(); | ||
expect(logRecord.context, api.Context.root); | ||
}); | ||
|
||
test('Verify context from span', () { | ||
final tracer = sdk.TracerProviderBase().getTracer('test'); | ||
final parent = tracer.startSpan('parent'); | ||
final context = api.contextWithSpan(api.Context.current, parent); | ||
final logRecord = api.LogRecord(context: context); | ||
expect(logRecord.context, context); | ||
}); | ||
|
||
test('Verify attribute null create attribute empty', () { | ||
final logRecord = api.LogRecord(); | ||
expect(logRecord.attributes.keys, sdk.Attributes.empty().keys); | ||
}); | ||
} |
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,13 @@ | ||
// 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 | ||
|
||
@TestOn('vm') | ||
import 'package:opentelemetry/src/experimental_api.dart' as api; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('returns noop logger', () { | ||
final noopLoggerProvider = api.NoopLoggerProvider(); | ||
expect(noopLoggerProvider.get('test'), const api.NoopLogger()); | ||
}); | ||
} |