Skip to content

Commit ae75732

Browse files
committed
Revert "ref: Amend span creation names for RFC 101"
This reverts commit 519729f.
1 parent 519729f commit ae75732

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

text/0101-revamping-the-sdk-performance-api.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Note: In a previous version of this RFC there was a focus on updating the span s
1818

1919
# Planned Work
2020

21-
The primary planned work in this RFC is to introduce three new top-level methods, `Sentry.startSpan` and `Sentry.startInactiveSpan` and their language-specific variants as well as `Sentry.setMeasurement`.
21+
The primary planned work in this RFC is to introduce three new top-level methods, `Sentry.startActiveSpan` and `Sentry.startSpan` and their language-specific variants as well as `Sentry.setMeasurement`.
2222

23-
This allows us to de-emphasize the concept of hubs, scopes, and transactions from users, and instead have them think about just spans. Under the hood, `Sentry.startSpan` and `Sentry.startInactiveSpan` should create transactions/spans as appropriate. `Sentry.setMeasurement` is used to abstract away `transaction.setMeasurement` and similar.
23+
This allows us to de-emphasize the concept of hubs, scopes, and transactions from users, and instead have them think about just spans. Under the hood, `Sentry.startActiveSpan` and `Sentry.startSpan` should create transactions/spans as appropriate. `Sentry.setMeasurement` is used to abstract away `transaction.setMeasurement` and similar.
2424

2525
In a previous version of the RFC, there was a follow-up step to update the span schema. This will be focused on later and for now, is not in scope for performance API improvements.
2626

@@ -111,13 +111,13 @@ The new SDK API has the following requirements:
111111
112112
### Span Creators
113113
114-
There are two top-level methods we'll be introducing to achieve this: `Sentry.startSpan` and `Sentry.startInactiveSpan`. `Sentry.startSpan` will take a callback and start/stop a span automatically. In addition, it'll also set the span on the current scope. Under the hood, the SDK will create a transaction or span based on if there is already an existing span on the scope.
114+
There are two top-level methods we'll be introducing to achieve this: `Sentry.startActiveSpan` and `Sentry.startSpan`. `Sentry.startActiveSpan` will take a callback and start/stop a span automatically. In addition, it'll also set the span on the current scope. Under the hood, the SDK will create a transaction or span based on if there is already an existing span on the scope.
115115
116-
The reason for electing to have `startSpan` and `startInactiveSpan` as separate top-level methods is to not burden the user with having to know about scope propagation, since the concept of a scope might change in future versions of the unified API. If this is not viable at all for a language or certain frameworks, SDK authors can opt to include the `onScope` parameter to the `startInactiveSpan` call that will automatically set the span on the current scope, but this is not recommended.
116+
The reason for electing to have `startActiveSpan` and `startSpan` as separate top-level methods is to not burden the user with having to know about scope propagation, since the concept of a scope might change in future versions of the unified API. If this is not viable at all for a language or certain frameworks, SDK authors can opt to include the `onScope` parameter to the `startSpan` call that will automatically set the span on the current scope, but this is not recommended.
117117
118118
```ts
119119
namespace Sentry {
120-
declare function startSpan<T>(
120+
declare function startActiveSpan<T>(
121121
spanContext: SpanContext,
122122
callback: (span: Span) => T
123123
): T;
@@ -126,8 +126,9 @@ namespace Sentry {
126126
// span that is created is provided to callback in case additional
127127
// attributes have to be added.
128128
// ideally callback can be async/sync
129-
const returnVal = Sentry.startSpan({ name: "expensiveCalc" }, (span: Span) =>
130-
expensiveCalc()
129+
const returnVal = Sentry.startActiveSpan(
130+
{ name: "expensiveCalc" },
131+
(span: Span) => expensiveCalc()
131132
);
132133

133134
// If the SDK needs async/sync typed differently it can be exposed as `startActiveSpanAsync`
@@ -137,46 +138,46 @@ const returnVal = Sentry.startSpan({ name: "expensiveCalc" }, (span: Span) =>
137138
// ): Promise<T>;
138139
```
139140
140-
In the ideal case, `startSpan` should generally follow this code path.
141+
In the ideal case, `startActiveSpan` should generally follow this code path.
141142
142143
1. Get the active span from the current scope
143144
2. If the active span is defined, create a child span of that active span based on the provided `spanContext`, otherwise create a transaction based on the provided `spanContext`.
144145
3. Run the provided callback
145146
4. Finish the child span/transaction created in Step 2
146147
5. Remove the child span/transaction from the current scope and if it exists, set the previous active span as the active span in the current scope.
147148
148-
If the provided callback throws an exception, the span/transaction created in Step 2 should be marked as errored. This error should not be swallowed by `startSpan`.
149+
If the provided callback throws an exception, the span/transaction created in Step 2 should be marked as errored. This error should not be swallowed by `startActiveSpan`.
149150
150-
`startSpan` only provides the correct parent-child relationship if your platform has proper support for forking scopes. For platforms that have a single hub/scope (like the mobile SDKs), this method will not lead to the correct parent-child relationship. The SDK will have to provide a different method for these platforms. The recommended option here is for `startSpan` to always attach the span it creates to the root span (the transaction), which means users don't get exact parent-child relationships, but they do get relative relationships between spans using relative durations.
151+
`startActiveSpan` only provides the correct parent-child relationship if your platform has proper support for forking scopes. For platforms that have a single hub/scope (like the mobile SDKs), this method will not lead to the correct parent-child relationship. The SDK will have to provide a different method for these platforms. The recommended option here is for `startActiveSpan` to always attach the span it creates to the root span (the transaction), which means users don't get exact parent-child relationships, but they do get relative relationships between spans using relative durations.
151152
152-
`Sentry.startInactiveSpan` will create a span, but not set it as the active span in the current scope.
153+
`Sentry.startSpan` will create a span, but not set it as the active span in the current scope.
153154
154155
```ts
155156
namespace Sentry {
156-
declare function startInactiveSpan(spanContext: SpanContext): Span;
157+
declare function startSpan(spanContext: SpanContext): Span;
157158
}
158159

159160
// does not get put on the scope
160-
const span = Sentry.startInactiveSpan({ name: "expensiveCalc" });
161+
const span = Sentry.startSpan({ name: "expensiveCalc" });
161162

162163
expensiveCalc();
163164

164165
span.finish();
165166
```
166167
167-
The goal here is to make span creation consistent across all SDKs, but we also want to make sure that the SDKs are idiomatic for their language/runtime. SDK authors are free to add additional methods to start spans if they feel that `startSpan` and `startInactiveSpan` are not appropriate for their language/framework/runtime.
168+
The goal here is to make span creation consistent across all SDKs, but we also want to make sure that the SDKs are idiomatic for their language/runtime. SDK authors are free to add additional methods to start spans if they feel that `startActiveSpan` and `startSpan` are not appropriate for their language/framework/runtime.
168169
169170
For example, with go we could have a method that starts a span from a go context:
170171
171172
```go
172173
sentry.StartSpanFromContext(ctx, spanCtx)
173174
```
174175
175-
SDK authors can also change the behaviour of `startSpan` and `startInactiveSpan` if they feel that the outlined behaviour is not idiomatic for their language/framework/runtime, but this is not recommended and should be discussed with the greater SDK team before being implemented.
176+
SDK authors can also change the behaviour of `startActiveSpan` and `startSpan` if they feel that the outlined behaviour is not idiomatic for their language/framework/runtime, but this is not recommended and should be discussed with the greater SDK team before being implemented.
176177
177178
### Span Name
178179
179-
To accommodate the inclusion of `Sentry.startSpan` and `Sentry.startInactiveSpan`, the `span.name` field should be used and is an alias for `span.description`. Span name should become required for the span context argument that is accepted by `Sentry.startSpan` and `Sentry.startInactiveSpan`.
180+
To accommodate the inclusion of `Sentry.startActiveSpan` and `Sentry.startSpan`, the `span.name` field should be used and is an alias for `span.description`. Span name should become required for the span context argument that is accepted by `Sentry.startActiveSpan` and `Sentry.startSpan`.
180181
181182
This means methods for setting a span name should be added to the span interface.
182183

0 commit comments

Comments
 (0)