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

[tracing] updating to opentelemetry 1.0.0-rc.0 #14208

Merged
merged 37 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6a8b437
Upgrading to opentelemetry 1.0.0 (rc.0)
richardpark-msft Mar 11, 2021
004ea11
Mike's right. Don't trust those pre-release dependencies!
Mar 26, 2021
5254d1f
rush update after taking master changes.
Mar 26, 2021
a1ec159
Fix formatting
Mar 26, 2021
749328f
Missing import.
Mar 26, 2021
cfa7a66
Merge remote-tracking branch 'upstream/master' into ot-upgrading-0.18
Mar 26, 2021
3daf277
Merge remote-tracking branch 'upstream/master' into ot-upgrading-0.18
Mar 26, 2021
1666ddf
rush update
Mar 26, 2021
7539204
Remove opentelemetry dependencies in the OpenCensusSpanWrapper (as po…
Mar 26, 2021
9225f90
Reference core-tracing explicitly (source of opentelemetry and tracin…
Mar 26, 2021
65df3c0
Missing import of dev-tool in the rollup configs.
Mar 26, 2021
ca1fc3c
identity: resolving a circular dependency. Some packages (like storag…
Mar 26, 2021
b127a7b
Talked with @sadasant, he prefers just moving everything into utils.t…
Mar 26, 2021
e656916
Merge remote-tracking branch 'upstream/master' into ot-upgrading-0.18
Mar 26, 2021
92c23f4
rush update after merge
Mar 26, 2021
a4ae936
Swap out even _more_ of the public surface with the interfaces.ts rat…
Mar 26, 2021
d46a554
use @maorleger's technique to make the matching more lax (for now!)
Mar 26, 2021
f44f1d9
Missed propagation after context -> tracingContext rename
Mar 26, 2021
0094f56
Update to latest identity
Mar 26, 2021
9b1199e
rush update
Mar 26, 2021
a0c71ca
Reverting back to the production version of identity. There are rollu…
Mar 27, 2021
3349d9a
Merge branch 'ot-upgrading-0.18' of github.com:richardpark-msft/azure…
Mar 27, 2021
f3f1f7c
Field rename!
Mar 27, 2021
16f5183
Remove the console.log!
Mar 27, 2021
d123e23
Named exports needed for node as well.
Mar 27, 2021
2a60134
Adding in named exports.
Mar 27, 2021
39eba54
No guarantee that the tracer set for "v3" is compatible with "v4".
Mar 27, 2021
7602803
Fix lint errors
Mar 28, 2021
1d2d95b
Types didn't match but apprently not fatal.
Mar 28, 2021
1777bac
Fixing lint errors
Mar 28, 2021
e1f881e
Format file to fix failing check-format
ramya-rao-a Mar 28, 2021
a88e395
Update changelog for core-tracing 1.0.0-preview.11
ramya-rao-a Mar 29, 2021
635bfcf
Merge remote-tracking branch 'upstream/master' into ot-upgrading-0.18
Mar 29, 2021
011c656
`npm run build` to regenerate the API.md
Mar 29, 2021
d751533
Addressing feedback from Chris:
Mar 29, 2021
583c0c3
Merge remote-tracking branch 'upstream/master' into ot-upgrading-0.18
Mar 29, 2021
7c7e2b2
CanonicalCode is now SpanStatusCode
Mar 29, 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
114 changes: 60 additions & 54 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

45 changes: 42 additions & 3 deletions common/tools/dev-tool/src/config/rollup.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,47 @@ interface PackageJson {
devDependencies: Record<string, string>;
}

/**
* Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api.
*
* NOTE: this manual configuration is only needed because OpenTelemetry uses an
* __exportStar downleveled helper function to declare its exports which confuses
richardpark-msft marked this conversation as resolved.
Show resolved Hide resolved
* rollup's automatic discovery mechanism.
*
* @returns an object reference that can be `...`'d into your cjs() configuration.
*/
export function openTelemetryCommonJs(): Record<string, string[]> {
const namedExports: Record<string, string[]> = {};

for (const key of ["@opentelemetry/api", "@azure/core-tracing/node_modules/@opentelemetry/api"]) {
namedExports[key] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"SpanStatusCode",
"getSpanContext",
"setSpanContext"
];
}

namedExports[
// working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path.
"../../../common/temp/node_modules/.pnpm/@opentelemetry/[email protected]/node_modules/@opentelemetry/api/build/src/index.js"
] = [
"SpanKind",
"TraceFlags",
"getSpan",
"setSpan",
"StatusCode",
"CanonicalCode",
"getSpanContext",
"setSpanContext"
];

return namedExports;
}

// #region Warning Handler

/**
Expand Down Expand Up @@ -80,9 +121,7 @@ function makeBrowserTestConfig() {
// Chai's strange internal architecture makes it impossible to statically
// analyze its exports.
chai: ["version", "use", "util", "config", "expect", "should", "assert"],
// OpenTelemetry uses an __exportStar downleveled helper function to
// declare its exports, and so we have to add them here as well.
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
...openTelemetryCommonJs()
}
}),
json(),
Expand Down
3 changes: 1 addition & 2 deletions sdk/anomalydetector/ai-anomaly-detector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
"@azure/core-http": "^1.2.0",
"@azure/core-auth": "^1.2.0",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
"tslib": "^2.0.0",
"@azure/core-tracing": "1.0.0-preview.10"
"@azure/core-tracing": "1.0.0-preview.11"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { terser } from "rollup-plugin-terser";
import shim from "rollup-plugin-shim";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";

const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
Expand Down Expand Up @@ -101,7 +102,7 @@ export function browserConfig(test = false) {
cjs({
namedExports: {
chai: ["assert"],
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
...openTelemetryCommonJs()
}
}),
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { createAnomalyDetectorAzureKeyCredentialPolicy } from "./azureKeyCredentialPolicy";
import { logger } from "./logger";
import { createSpan } from "./tracing";
import { CanonicalCode } from "@opentelemetry/api";
import { SpanStatusCode } from "@azure/core-tracing";

export type DetectEntireSeriesOptions = OperationOptions;
export type DetectLastPointOptions = OperationOptions;
Expand Down Expand Up @@ -125,7 +125,7 @@ export class AnomalyDetectorClient {
return this.client.detectEntireSeries(body, finalOptions);
} catch (error) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: error.message
});
throw error;
Expand Down Expand Up @@ -156,7 +156,7 @@ export class AnomalyDetectorClient {
return this.client.detectLastPoint(body, finalOptions);
} catch (error) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: error.message
});
throw error;
Expand Down Expand Up @@ -185,7 +185,7 @@ export class AnomalyDetectorClient {
return this.client.detectChangePoint(body, finalOptions);
} catch (error) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: error.message
});
throw error;
Expand Down
3 changes: 1 addition & 2 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +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.10",
"@opentelemetry/api": "^0.10.2",
"@azure/core-tracing": "1.0.0-preview.11",
"tslib": "^2.0.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion sdk/appconfiguration/app-configuration/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import shim from "rollup-plugin-shim";
import json from "@rollup/plugin-json";
import * as path from "path";
import inject from "@rollup/plugin-inject";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";

const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
Expand Down Expand Up @@ -123,7 +124,7 @@ export function browserConfig(test = false) {
chai: ["assert", "expect", "use"],
assert: ["ok", "equal", "strictEqual", "deepEqual", "fail", "throws", "notEqual"],
events: ["EventEmitter"],
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
...openTelemetryCommonJs()
}
}),

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { Span, CanonicalCode } from "@opentelemetry/api";
import { Span, SpanStatusCode } from "@azure/core-tracing";

import { RestError, OperationOptions } from "@azure/core-http";
import { createSpanFunction } from "@azure/core-tracing";
Expand Down Expand Up @@ -35,14 +35,13 @@ export async function trace<ReturnT>(
// close the span.
const result = await fn(updatedOptions, span);

// otel 0.16+ needs this or else the code ends up being set as UNSET
span.setStatus({
code: CanonicalCode.OK
code: SpanStatusCode.OK
});
return result;
} catch (err) {
span.setStatus({
code: CanonicalCode.INTERNAL, // TODO: StatusCode.ERROR in otel 0.16+
code: SpanStatusCode.ERROR,
message: err.message
});
throw err;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import { createSpan, trace } from "../../src/internal/tracingHelpers";
import { Span, Status, CanonicalCode } from "@opentelemetry/api";
import { Span, SpanStatus, SpanStatusCode } from "@azure/core-tracing";

import * as assert from "assert";
import sinon from "sinon";
Expand All @@ -12,7 +12,7 @@ import { OperationTracingOptions } from "@azure/core-tracing";

describe("tracingHelpers", () => {
it("trace OK", async () => {
let setStatusStub: sinon.SinonStub<[Status], Span> | undefined;
let setStatusStub: sinon.SinonStub<[SpanStatus], Span> | undefined;
let endStub: sinon.SinonStub | undefined;

const fakeCreateSpan = <
Expand Down Expand Up @@ -49,12 +49,12 @@ describe("tracingHelpers", () => {

const [status] = setStatusStub!.args[0];

assert.equal(status.code, CanonicalCode.OK);
assert.equal(status.code, SpanStatusCode.OK);
assert.equal(endStub?.called, true);
});

it("trace ERROR", async () => {
let setStatusStub: sinon.SinonStub<[Status], Span> | undefined;
let setStatusStub: sinon.SinonStub<[SpanStatus], Span> | undefined;
let endStub: sinon.SinonStub | undefined;

try {
Expand Down Expand Up @@ -96,7 +96,7 @@ describe("tracingHelpers", () => {
assert.ok(setStatusStub, "setStatus should have been called");
assert.equal(
setStatusStub?.args[0][0].code,
CanonicalCode.INTERNAL,
SpanStatusCode.ERROR,
"Any thrown exception causes the span status to be set to an error"
);

Expand Down
4 changes: 2 additions & 2 deletions sdk/attestation/attestation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "1.0.0-beta.3",
"dependencies": {
"@azure/core-http": "^1.2.0",
"@azure/identity": "^1.1.0",
"@azure/core-tracing": "1.0.0-preview.11",
"tslib": "^2.0.0"
},
"keywords": [
Expand All @@ -25,11 +25,11 @@
"node": ">=8.0.0"
},
"devDependencies": {
"@azure/identity": "^1.1.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/test-utils-recorder": "^1.0.0",
"@microsoft/api-extractor": "7.7.11",
"@opentelemetry/api": "^0.10.2",
"@types/chai": "^4.1.6",
"@types/chai-as-promised": "^7.1.0",
"@types/jsrsasign": "^8.0.9",
Expand Down
3 changes: 1 addition & 2 deletions sdk/communication/communication-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@
"@azure/communication-signaling": "1.0.0-beta.3",
"@azure/core-auth": "^1.2.0",
"@azure/core-http": "^1.2.0",
"@azure/core-tracing": "1.0.0-preview.10",
"@azure/core-tracing": "1.0.0-preview.11",
"@azure/logger": "^1.0.0",
"@opentelemetry/api": "^0.10.2",
"events": "^3.0.0",
"tslib": "^2.0.0",
"@azure/core-paging": "^1.1.1"
Expand Down
3 changes: 2 additions & 1 deletion sdk/communication/communication-chat/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { terser } from "rollup-plugin-terser";
import sourcemaps from "rollup-plugin-sourcemaps";
import viz from "rollup-plugin-visualizer";
import shim from "rollup-plugin-shim";
import { openTelemetryCommonJs } from "@azure/dev-tool/shared-config/rollup";

const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
Expand Down Expand Up @@ -100,7 +101,7 @@ export function browserConfig(test = false) {
chai: ["assert"],
events: ["EventEmitter"],
"@azure/communication-signaling": ["CommunicationSignalingClient", "SignalingClient"],
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
...openTelemetryCommonJs()
}
}),
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
Expand Down
8 changes: 4 additions & 4 deletions sdk/communication/communication-chat/src/chatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from "@azure/core-http";
import "@azure/core-paging";
import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { CanonicalCode } from "@opentelemetry/api";
import { SpanStatusCode } from "@azure/core-tracing";
import { createSpan } from "./tracing";
import { ChatThreadClient } from "./chatThreadClient";
import {
Expand Down Expand Up @@ -142,7 +142,7 @@ export class ChatClient {
return mapToCreateChatThreadResultSdkModel(result);
} catch (e) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: e.message
});
throw e;
Expand Down Expand Up @@ -209,7 +209,7 @@ export class ChatClient {
};
} catch (e) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: e.message
});
throw e;
Expand All @@ -236,7 +236,7 @@ export class ChatClient {
);
} catch (e) {
span.setStatus({
code: CanonicalCode.UNKNOWN,
code: SpanStatusCode.ERROR,
message: e.message
});
throw e;
Expand Down
Loading