Skip to content
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

[telemetry] Centralize (as much as is practical) the creation of spans to ease upgrades #13887

Merged
merged 55 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from 50 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 Feb 19, 2021
d00744f
Formatting
richardpark-msft Feb 19, 2021
96f7c97
Updating the package reference to be the new core-tracing version (wh…
richardpark-msft Feb 19, 2021
13d5b35
Formatting
richardpark-msft Feb 19, 2021
450e1ba
core-http compatible!
richardpark-msft Feb 19, 2021
88b5783
Formatting
richardpark-msft Feb 19, 2021
724092a
Centralize most of the createSpan logic (except for keyvault, which i…
richardpark-msft Feb 19, 2021
7092a57
Formatting
richardpark-msft Feb 19, 2021
df7f0e1
Service Bus was using the properties from createSpan() with a differe…
richardpark-msft Feb 19, 2021
cca3325
Formatting
richardpark-msft Feb 19, 2021
89da87e
Remove unneeded OperationTracingOptionsLike (the same package already…
richardpark-msft Feb 20, 2021
fd10725
Formatting
richardpark-msft Feb 20, 2021
b00a413
identity: the deconstructed names are different (and null checks need…
richardpark-msft Feb 20, 2021
ee2b382
Formatting
richardpark-msft Feb 20, 2021
2aea35c
Update storage-blob for the pending update to the latest OpenTelemetr…
richardpark-msft Feb 20, 2021
4dc72d8
Formatting
richardpark-msft Feb 20, 2021
42ff058
Update to use the core-tracing version of createSpan
richardpark-msft Feb 20, 2021
6f99488
Formatting
richardpark-msft Feb 20, 2021
ee8c6f0
Formatting
richardpark-msft Feb 20, 2021
7edc5dd
storage-queue: same story, just swapping to core-tracing's versions.
richardpark-msft Feb 20, 2021
63b013d
storage-file-datalike now using the core-tracing functions
richardpark-msft Feb 20, 2021
68c5ce0
Formatting
richardpark-msft Feb 20, 2021
7031b79
storage-file-share: ported to using core-tracing
richardpark-msft Feb 20, 2021
4bd5363
Formatting
richardpark-msft Feb 20, 2021
b9c51e6
Removing export of core-tracing functions from core-client and core-http
richardpark-msft Feb 22, 2021
6365b72
Formatting
richardpark-msft Feb 22, 2021
f645aec
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft Feb 22, 2021
4b0e99e
- createSpa now guarantees it's return value is not null (eliminates …
richardpark-msft Feb 22, 2021
3404d31
Formatting
richardpark-msft Feb 22, 2021
7887702
synapse-access-control: use core-tracing createSpan
richardpark-msft Feb 22, 2021
5a71f92
Formatting
richardpark-msft Feb 22, 2021
e86b11d
synapse-managed-privateendpoints: update to use core-tracing
richardpark-msft Feb 22, 2021
36e30c1
Formatting
richardpark-msft Feb 22, 2021
5e3fada
synapse-monitoring: change to use core-tracing
richardpark-msft Feb 22, 2021
fc4e05f
synapse-spark: changed to use core-tracing
richardpark-msft Feb 22, 2021
3785e5e
Formatting
richardpark-msft Feb 22, 2021
00cbaba
Updated to use core-tracing directly
richardpark-msft Feb 22, 2021
81d17b7
our semver rule was tripping over using preview.10 as the version. Ju…
richardpark-msft Feb 22, 2021
b48f98c
Bring back a compatible createSpan function so we don't cause runtime…
richardpark-msft Feb 23, 2021
5cf9288
After talking with @joheredi it's obvious we can't remove this functi…
richardpark-msft Feb 23, 2021
0b5e2d6
Formatting
richardpark-msft Feb 23, 2021
bd1a4e8
Change name from SpanConfig (which is too generic!) to CreateSpanFunc…
richardpark-msft Feb 23, 2021
b168a32
Formatting again.
richardpark-msft Feb 23, 2021
bed4e50
Updating changelog for core-client to note that createSpanFunction ha…
richardpark-msft Feb 23, 2021
af57992
Renamed SpanOptions to CreateSpanFunctionArgs
richardpark-msft Feb 23, 2021
bf06056
Simplified the signature for createSpanFunction
richardpark-msft Feb 23, 2021
0e3b80f
Formatting
richardpark-msft Feb 23, 2021
4900eb1
Formalizing the deprecated'ness of the core-http exports by adding in…
richardpark-msft Feb 23, 2021
caf7f63
Formatting
richardpark-msft Feb 23, 2021
7f7ecc5
Formatting of the breaking changes was incorrect.
richardpark-msft Feb 23, 2021
fe61219
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft Feb 24, 2021
d8dd23b
Merge remote-tracking branch 'upstream/master' into ot-upgrading-step1
richardpark-msft Feb 24, 2021
8f62518
Removed unused import
richardpark-msft Feb 24, 2021
fce3238
Remove unused functions.
richardpark-msft Feb 24, 2021
72d141f
Remove two unused imports
richardpark-msft Feb 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/anomalydetector/ai-anomaly-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
"tslib": "^2.0.0",
"@azure/core-tracing": "1.0.0-preview.9"
"@azure/core-tracing": "1.0.0-beta.1"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
Expand Down
55 changes: 5 additions & 50 deletions sdk/anomalydetector/ai-anomaly-detector/src/tracing.ts
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({
richardpark-msft marked this conversation as resolved.
Show resolved Hide resolved
packagePrefix: "Azure.CognitiveServices.AnomalyDetector",
namespace: "Microsoft.CognitiveServices"
});
2 changes: 1 addition & 1 deletion sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@azure/core-asynciterator-polyfill": "^1.0.0",
"@azure/core-http": "^1.2.0",
"@azure/core-paging": "^1.1.1",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@opentelemetry/api": "^0.10.2",
"tslib": "^2.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@azure/core-lro": "^1.0.2",
"@azure/core-paging": "^1.1.1",
"@azure/logger": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@opentelemetry/api": "^0.10.2",
"events": "^3.0.0",
"tslib": "^2.0.0"
Expand Down
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.
Show resolved Hide resolved
packagePrefix: "Azure.Communication",
namespace: "Microsoft.Communication"
});
2 changes: 1 addition & 1 deletion sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@azure/communication-signaling": "1.0.0-beta.2",
"@azure/core-auth": "^1.2.0",
"@azure/core-http": "^1.2.0",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
"events": "^3.0.0",
Expand Down
54 changes: 5 additions & 49 deletions sdk/communication/communication-chat/src/tracing.ts
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"
});
2 changes: 1 addition & 1 deletion sdk/communication/communication-identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@azure/core-lro": "^1.0.2",
"@azure/core-paging": "^1.1.1",
"@azure/logger": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@opentelemetry/api": "^0.10.2",
"events": "^3.0.0",
"tslib": "^2.0.0"
Expand Down
54 changes: 5 additions & 49 deletions sdk/communication/communication-identity/src/common/tracing.ts
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"
});
2 changes: 1 addition & 1 deletion sdk/communication/communication-sms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@azure/communication-common": "1.0.0-beta.6",
"@azure/core-auth": "^1.2.0",
"@azure/core-http": "^1.2.0",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
"events": "^3.0.0",
Expand Down
54 changes: 5 additions & 49 deletions sdk/communication/communication-sms/src/tracing.ts
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"
});
3 changes: 3 additions & 0 deletions sdk/core/core-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## 1.0.0-beta.2 (Unreleased)

- [Breaking] Removed `createSpanFunction` and `SpanConfig`. These have been moved into
`@azure/core-tracing`.

## 1.0.0-beta.1 (2021-02-04)

- First release of package, see README.md for details.
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@azure/abort-controller": "^1.0.0",
"@azure/core-auth": "^1.2.0",
"@azure/core-https": "1.0.0-beta.2",
"@azure/core-tracing": "1.0.0-preview.9",
"@azure/core-tracing": "1.0.0-beta.1",
"@opentelemetry/api": "^0.10.2",
"tslib": "^2.0.0"
},
Expand Down
Loading