-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[telemetry] Centralize (as much as is practical) the creation of spans to ease upgrades #13887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
richardpark-msft
merged 55 commits into
Azure:master
from
richardpark-msft:ot-upgrading-step1
Feb 26, 2021
Merged
Changes from 10 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
2ccc04f
Centralize createSpan code into core-tracing, update the minimum need…
richardpark-msft d00744f
Formatting
richardpark-msft 96f7c97
Updating the package reference to be the new core-tracing version (wh…
richardpark-msft 13d5b35
Formatting
richardpark-msft 450e1ba
core-http compatible!
richardpark-msft 88b5783
Formatting
richardpark-msft 724092a
Centralize most of the createSpan logic (except for keyvault, which i…
richardpark-msft 7092a57
Formatting
richardpark-msft df7f0e1
Service Bus was using the properties from createSpan() with a differe…
richardpark-msft cca3325
Formatting
richardpark-msft 89da87e
Remove unneeded OperationTracingOptionsLike (the same package already…
richardpark-msft fd10725
Formatting
richardpark-msft b00a413
identity: the deconstructed names are different (and null checks need…
richardpark-msft ee2b382
Formatting
richardpark-msft 2aea35c
Update storage-blob for the pending update to the latest OpenTelemetr…
richardpark-msft 4dc72d8
Formatting
richardpark-msft 42ff058
Update to use the core-tracing version of createSpan
richardpark-msft 6f99488
Formatting
richardpark-msft ee8c6f0
Formatting
richardpark-msft 7edc5dd
storage-queue: same story, just swapping to core-tracing's versions.
richardpark-msft 63b013d
storage-file-datalike now using the core-tracing functions
richardpark-msft 68c5ce0
Formatting
richardpark-msft 7031b79
storage-file-share: ported to using core-tracing
richardpark-msft 4bd5363
Formatting
richardpark-msft b9c51e6
Removing export of core-tracing functions from core-client and core-http
richardpark-msft 6365b72
Formatting
richardpark-msft f645aec
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft 4b0e99e
- createSpa now guarantees it's return value is not null (eliminates …
richardpark-msft 3404d31
Formatting
richardpark-msft 7887702
synapse-access-control: use core-tracing createSpan
richardpark-msft 5a71f92
Formatting
richardpark-msft e86b11d
synapse-managed-privateendpoints: update to use core-tracing
richardpark-msft 36e30c1
Formatting
richardpark-msft 5e3fada
synapse-monitoring: change to use core-tracing
richardpark-msft fc4e05f
synapse-spark: changed to use core-tracing
richardpark-msft 3785e5e
Formatting
richardpark-msft 00cbaba
Updated to use core-tracing directly
richardpark-msft 81d17b7
our semver rule was tripping over using preview.10 as the version. Ju…
richardpark-msft b48f98c
Bring back a compatible createSpan function so we don't cause runtime…
richardpark-msft 5cf9288
After talking with @joheredi it's obvious we can't remove this functi…
richardpark-msft 0b5e2d6
Formatting
richardpark-msft bd1a4e8
Change name from SpanConfig (which is too generic!) to CreateSpanFunc…
richardpark-msft b168a32
Formatting again.
richardpark-msft bed4e50
Updating changelog for core-client to note that createSpanFunction ha…
richardpark-msft af57992
Renamed SpanOptions to CreateSpanFunctionArgs
richardpark-msft bf06056
Simplified the signature for createSpanFunction
richardpark-msft 0e3b80f
Formatting
richardpark-msft 4900eb1
Formalizing the deprecated'ness of the core-http exports by adding in…
richardpark-msft caf7f63
Formatting
richardpark-msft 7f7ecc5
Formatting of the breaking changes was incorrect.
richardpark-msft fe61219
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft d8dd23b
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft 8f62518
Removed unused import
richardpark-msft fce3238
Remove unused functions.
richardpark-msft 72d141f
Remove two unused imports
richardpark-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,58 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { getTracer, OperationTracingOptions } from "@azure/core-tracing"; | ||
| import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; | ||
| import { OperationOptions } from "@azure/core-http"; | ||
| import { createSpanFunction } from "@azure/core-tracing"; | ||
|
|
||
| /** | ||
| * Creates a span using the global tracer. | ||
| * @internal | ||
| * @param name - The name of the operation being performed. | ||
| * @param tracingOptions - The options for the underlying http request. | ||
| */ | ||
| export function createSpan<T extends OperationOptions>( | ||
| operationName: string, | ||
| operationOptions: T | ||
| ): { span: Span; updatedOptions: T } { | ||
| const tracer = getTracer(); | ||
| const tracingOptions = operationOptions.tracingOptions || {}; | ||
| const spanOptions: SpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| kind: SpanKind.INTERNAL | ||
| }; | ||
|
|
||
| const span = tracer.startSpan( | ||
| `Azure.CognitiveServices.AnomalyDetector.${operationName}`, | ||
| spanOptions | ||
| ); | ||
|
|
||
| span.setAttribute("az.namespace", "Microsoft.CognitiveServices"); | ||
|
|
||
| let newSpanOptions = tracingOptions.spanOptions || {}; | ||
| if (span.isRecording()) { | ||
| newSpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| parent: span.context(), | ||
| attributes: { | ||
| ...spanOptions.attributes, | ||
| "az.namespace": "Microsoft.CognitiveServices" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| const newTracingOptions: OperationTracingOptions = { | ||
| ...tracingOptions, | ||
| spanOptions: newSpanOptions | ||
| }; | ||
|
|
||
| const newOperationOptions: T = { | ||
| ...operationOptions, | ||
| tracingOptions: newTracingOptions | ||
| }; | ||
|
|
||
| return { | ||
| span, | ||
| updatedOptions: newOperationOptions | ||
| }; | ||
| } | ||
| export const createSpan = createSpanFunction({ | ||
| packagePrefix: "Azure.CognitiveServices.AnomalyDetector", | ||
| namespace: "Microsoft.CognitiveServices" | ||
| }); | ||
This file contains hidden or 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 hidden or 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
54 changes: 5 additions & 49 deletions
54
sdk/communication/communication-administration/src/common/tracing.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,57 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { OperationOptions } from "@azure/core-http"; | ||
| import { getTracer } from "@azure/core-tracing"; | ||
| import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; | ||
|
|
||
| type OperationTracingOptions = OperationOptions["tracingOptions"]; | ||
| import { createSpanFunction } from "@azure/core-tracing"; | ||
|
|
||
| /** | ||
| * Creates a span using the global tracer. | ||
| * @internal | ||
| * @param name - The name of the operation being performed. | ||
| * @param tracingOptions - The options for the underlying http request. | ||
| */ | ||
| export function createSpan<T extends OperationOptions>( | ||
| operationName: string, | ||
| operationOptions: T | ||
| ): { span: Span; updatedOptions: T } { | ||
| const tracer = getTracer(); | ||
| const tracingOptions = operationOptions.tracingOptions || {}; | ||
| const spanOptions: SpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| kind: SpanKind.INTERNAL | ||
| }; | ||
|
|
||
| const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); | ||
|
|
||
| span.setAttribute("az.namespace", "Microsoft.Communication"); | ||
|
|
||
| let newSpanOptions = tracingOptions.spanOptions || {}; | ||
| if (span.isRecording()) { | ||
| newSpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| parent: span.context(), | ||
| attributes: { | ||
| ...spanOptions.attributes, | ||
| "az.namespace": "Microsoft.Communication" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| const newTracingOptions: OperationTracingOptions = { | ||
| ...tracingOptions, | ||
| spanOptions: newSpanOptions | ||
| }; | ||
|
|
||
| const newOperationOptions: T = { | ||
| ...operationOptions, | ||
| tracingOptions: newTracingOptions | ||
| }; | ||
|
|
||
| return { | ||
| span, | ||
| updatedOptions: newOperationOptions | ||
| }; | ||
| } | ||
| export const createSpan = createSpanFunction({ | ||
|
richardpark-msft marked this conversation as resolved.
|
||
| packagePrefix: "Azure.Communication", | ||
| namespace: "Microsoft.Communication" | ||
| }); | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,57 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { getTracer } from "@azure/core-tracing"; | ||
| import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; | ||
| import { OperationOptions } from "@azure/core-http"; | ||
|
|
||
| type OperationTracingOptions = OperationOptions["tracingOptions"]; | ||
| import { createSpanFunction } from "@azure/core-tracing"; | ||
|
|
||
| /** | ||
| * Creates a span using the global tracer. | ||
| * @internal | ||
| * @param name - The name of the operation being performed. | ||
| * @param tracingOptions - The options for the underlying http request. | ||
| */ | ||
| export function createSpan<T extends OperationOptions>( | ||
| operationName: string, | ||
| operationOptions: T | ||
| ): { span: Span; updatedOptions: T } { | ||
| const tracer = getTracer(); | ||
| const tracingOptions = operationOptions.tracingOptions || {}; | ||
| const spanOptions: SpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| kind: SpanKind.INTERNAL | ||
| }; | ||
|
|
||
| const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); | ||
|
|
||
| span.setAttribute("az.namespace", "Microsoft.Communication"); | ||
|
|
||
| let newSpanOptions = tracingOptions.spanOptions || {}; | ||
| if (span.isRecording()) { | ||
| newSpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| parent: span.context(), | ||
| attributes: { | ||
| ...spanOptions.attributes, | ||
| "az.namespace": "Microsoft.Communication" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| const newTracingOptions: OperationTracingOptions = { | ||
| ...tracingOptions, | ||
| spanOptions: newSpanOptions | ||
| }; | ||
|
|
||
| const newOperationOptions: T = { | ||
| ...operationOptions, | ||
| tracingOptions: newTracingOptions | ||
| }; | ||
|
|
||
| return { | ||
| span, | ||
| updatedOptions: newOperationOptions | ||
| }; | ||
| } | ||
| export const createSpan = createSpanFunction({ | ||
| packagePrefix: "Azure.Communication", | ||
| namespace: "Microsoft.Communication" | ||
| }); |
This file contains hidden or 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
54 changes: 5 additions & 49 deletions
54
sdk/communication/communication-identity/src/common/tracing.ts
This file contains hidden or 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 |
|---|---|---|
| @@ -1,57 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { OperationOptions } from "@azure/core-http"; | ||
| import { getTracer } from "@azure/core-tracing"; | ||
| import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; | ||
|
|
||
| type OperationTracingOptions = OperationOptions["tracingOptions"]; | ||
| import { createSpanFunction } from "@azure/core-tracing"; | ||
|
|
||
| /** | ||
| * Creates a span using the global tracer. | ||
| * @internal | ||
| * @param name - The name of the operation being performed. | ||
| * @param tracingOptions - The options for the underlying http request. | ||
| */ | ||
| export function createSpan<T extends OperationOptions>( | ||
| operationName: string, | ||
| operationOptions: T | ||
| ): { span: Span; updatedOptions: T } { | ||
| const tracer = getTracer(); | ||
| const tracingOptions = operationOptions.tracingOptions || {}; | ||
| const spanOptions: SpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| kind: SpanKind.INTERNAL | ||
| }; | ||
|
|
||
| const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); | ||
|
|
||
| span.setAttribute("az.namespace", "Microsoft.Communication"); | ||
|
|
||
| let newSpanOptions = tracingOptions.spanOptions || {}; | ||
| if (span.isRecording()) { | ||
| newSpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| parent: span.context(), | ||
| attributes: { | ||
| ...spanOptions.attributes, | ||
| "az.namespace": "Microsoft.Communication" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| const newTracingOptions: OperationTracingOptions = { | ||
| ...tracingOptions, | ||
| spanOptions: newSpanOptions | ||
| }; | ||
|
|
||
| const newOperationOptions: T = { | ||
| ...operationOptions, | ||
| tracingOptions: newTracingOptions | ||
| }; | ||
|
|
||
| return { | ||
| span, | ||
| updatedOptions: newOperationOptions | ||
| }; | ||
| } | ||
| export const createSpan = createSpanFunction({ | ||
| packagePrefix: "Azure.Communication", | ||
| namespace: "Microsoft.Communication" | ||
| }); |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,57 +1,13 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| import { OperationOptions } from "@azure/core-http"; | ||
| import { getTracer } from "@azure/core-tracing"; | ||
| import { Span, SpanOptions, SpanKind } from "@opentelemetry/api"; | ||
|
|
||
| type OperationTracingOptions = OperationOptions["tracingOptions"]; | ||
| import { createSpanFunction } from "@azure/core-tracing"; | ||
|
|
||
| /** | ||
| * Creates a span using the global tracer. | ||
| * @internal | ||
| * @param name - The name of the operation being performed. | ||
| * @param tracingOptions - The options for the underlying http request. | ||
| */ | ||
| export function createSpan<T extends OperationOptions>( | ||
| operationName: string, | ||
| operationOptions: T | ||
| ): { span: Span; updatedOptions: T } { | ||
| const tracer = getTracer(); | ||
| const tracingOptions = operationOptions.tracingOptions || {}; | ||
| const spanOptions: SpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| kind: SpanKind.INTERNAL | ||
| }; | ||
|
|
||
| const span = tracer.startSpan(`Azure.Communication.${operationName}`, spanOptions); | ||
|
|
||
| span.setAttribute("az.namespace", "Microsoft.Communication"); | ||
|
|
||
| let newSpanOptions = tracingOptions.spanOptions || {}; | ||
| if (span.isRecording()) { | ||
| newSpanOptions = { | ||
| ...tracingOptions.spanOptions, | ||
| parent: span.context(), | ||
| attributes: { | ||
| ...spanOptions.attributes, | ||
| "az.namespace": "Microsoft.Communication" | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| const newTracingOptions: OperationTracingOptions = { | ||
| ...tracingOptions, | ||
| spanOptions: newSpanOptions | ||
| }; | ||
|
|
||
| const newOperationOptions: T = { | ||
| ...operationOptions, | ||
| tracingOptions: newTracingOptions | ||
| }; | ||
|
|
||
| return { | ||
| span, | ||
| updatedOptions: newOperationOptions | ||
| }; | ||
| } | ||
| export const createSpan = createSpanFunction({ | ||
| packagePrefix: "Azure.Communication", | ||
| namespace: "Microsoft.Communication" | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.