Skip to content

Commit

Permalink
Add deprecation for context.root
Browse files Browse the repository at this point in the history
  • Loading branch information
changliu-wk committed May 14, 2024
1 parent e69ae7a commit 21c38d9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/src/api/context/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ abstract class Context {
/// Only use this context if you are certain you need to disregard the
/// current [Context]. For example, when instrumenting an asynchronous
/// event handler which may fire while an unrelated [Context] is "current".
@Deprecated(
'We are planning to remove this in the future, please use Context.current instead.')
static Context get root => _contextManager.root;

/// Returns a key to be used to read and/or write values to a context.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/api/context/context_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import 'package:opentelemetry/api.dart';

abstract class ContextManager {
@Deprecated(
'We are planning to remove this in the future, please use Context.current instead.')
Context get root;

Context get active;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/sdk/context/zone_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ZoneContext implements Context {
/// Only use this context if you are certain you need to disregard the
/// current [ZoneContext]. For example, when instrumenting an asynchronous
/// event handler which may fire while an unrelated [ZoneContext] is "current".
@Deprecated(
'We are planning to remove this in the future, please use Context.current instead.')
static ZoneContext get root => ZoneContext._(Zone.root);

/// Returns a key to be used to read and/or write values to a context.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/sdk/context/zone_context_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ZoneContextManager implements ContextManager {
@override
Context get active => ZoneContext.current;

@Deprecated(
'We are planning to remove this in the future, please use Context.current instead.')
@override
Context get root => ZoneContext.root;
}

0 comments on commit 21c38d9

Please sign in to comment.