Skip to content

Commit

Permalink
[core-tracing] Update to OpenTelemetry 0.6 (#7998)
Browse files Browse the repository at this point in the history
* Migrate all packages to OpenTelemetry 0.6.1.
* Update inter-package dependencies to express the new requirements.
  • Loading branch information
xirzec authored Apr 23, 2020
1 parent b964568 commit 1b7428d
Show file tree
Hide file tree
Showing 138 changed files with 462 additions and 412 deletions.
3 changes: 0 additions & 3 deletions common/config/rush/common-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
*/
"allowedAlternativeVersions": {
"@azure/ms-rest-js": ["^2.0.0"],
"@azure/core-http": ["^1.1.0"],
"@azure/core-auth": ["^1.1.0"],
"@azure/core-tracing": ["1.0.0-preview.7"],
/**
* For example, allow some projects to use an older TypeScript compiler
* (in addition to whatever "usual" version is being used by other projects in the repo):
Expand Down
101 changes: 69 additions & 32 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions dataplane.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
{
"path": "sdk\\eventhub\\event-processor-host"
},
{
"path": "sdk\\formrecognizer\\ai-form-recognizer",
"name": "form-recognizer"
},
{
"path": "sdk\\eventhub\\testhub"
},
Expand Down Expand Up @@ -103,6 +107,9 @@
{
"name": "eslint plugin",
"path": "common\\tools\\eslint-plugin-azure-sdk"
},
{
"path": "sdk\\test-utils\\perfstress"
}
],
"settings": {
Expand Down
4 changes: 2 additions & 2 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
},
"dependencies": {
"@azure/core-asynciterator-polyfill": "^1.0.0",
"@azure/core-http": "^1.0.0",
"@azure/core-http": "^1.1.1",
"@azure/core-paging": "^1.1.0",
"@azure/core-tracing": "1.0.0-preview.8",
"@opentelemetry/types": "^0.2.0",
"@opentelemetry/api": "^0.6.1",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Licensed under the MIT License.

import { getTracer } from "@azure/core-tracing";
import { Span, SpanOptions, SpanKind, CanonicalCode } from "@opentelemetry/types";
import { Span, SpanKind, CanonicalCode } from "@opentelemetry/api";
import { SpanOptions } from "@azure/core-tracing";

import { RestError } from "@azure/core-http";

Expand Down Expand Up @@ -90,7 +91,7 @@ export class Spanner<TClient> {
...options,
spanOptions: {
...spanOptions,
parent: span,
parent: span.context(),
attributes: {
...spanOptions.attributes,
"az.namespace": "Microsoft.AppConfiguration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import { Spanner } from "../src/internal/tracingHelpers";
import { RestError } from "@azure/core-http";
import { getTracer } from "@azure/core-tracing";
import { SpanOptions, SpanKind, CanonicalCode } from "@opentelemetry/types";
import { SpanKind, CanonicalCode } from "@opentelemetry/api";
import { SpanOptions } from "@azure/core-tracing";

import * as assert from "assert";

interface FakeOptions {
Expand All @@ -17,7 +19,6 @@ describe("tracingHelpers", () => {
const fakeOptions: FakeOptions = {
name: "fakeName",
spanOptions: {
kind: SpanKind.PRODUCER,
attributes: {
testAttribute: "testAttributeValue"
}
Expand All @@ -31,8 +32,7 @@ describe("tracingHelpers", () => {
const newOptions = Spanner["addParentToOptions"](fakeOptions, parentSpan);

assert.equal("fakeName", newOptions.name);
assert.equal(parentSpan, newOptions.spanOptions.parent);
assert.equal(SpanKind.PRODUCER, newOptions.spanOptions.kind);
assert.deepEqual(parentSpan.context(), newOptions.spanOptions.parent);
assert.ok(newOptions.spanOptions.attributes, "Should have attributes set");
if (newOptions.spanOptions.attributes) {
assert.equal("Microsoft.AppConfiguration", newOptions.spanOptions.attributes["az.namespace"]);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-arm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
]
},
"dependencies": {
"@azure/core-http": "^1.0.0",
"@azure/core-http": "^1.1.1",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-tracing": "1.0.0-preview.8",
"@opentelemetry/types": "^0.2.0",
"@opentelemetry/api": "^0.6.1",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/review/core-auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```ts

import { AbortSignalLike } from '@azure/abort-controller';
import { SpanOptions } from '@opentelemetry/types';
import { SpanOptions } from '@azure/core-tracing';

// @public
export interface AccessToken {
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-auth/src/tokenCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { AbortSignalLike } from "@azure/abort-controller";
import { SpanOptions } from "@opentelemetry/types";
import { SpanOptions } from "@azure/core-tracing";

/**
* Represents a credential capable of providing an authentication token.
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"@azure/core-auth": "^1.1.2",
"@azure/core-tracing": "1.0.0-preview.8",
"@azure/logger": "^1.0.0",
"@opentelemetry/types": "^0.2.0",
"@opentelemetry/api": "^0.6.1",
"@types/node-fetch": "^2.5.0",
"@types/tunnel": "^0.0.1",
"cross-env": "^6.0.3",
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function browserConfig(test = false, production = false) {
namedExports: {
chai: ["assert", "AssertionError", "should", "expect"],
events: ["EventEmitter"],
"@opentelemetry/types": ["CanonicalCode", "SpanKind", "TraceFlags"]
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
}
}),
viz({ filename: "dist-browser/browser-stats.html", sourcemap: false })
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/src/policies/tracingPolicy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { getTracer, getTraceParentHeader } from "@azure/core-tracing";
import { SpanOptions, SpanKind } from "@opentelemetry/types";
import { SpanOptions, SpanKind } from "@opentelemetry/api";
import {
RequestPolicyFactory,
RequestPolicy,
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-http/src/webResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HttpOperationResponse } from "./httpOperationResponse";
import { OperationResponse } from "./operationResponse";
import { ProxySettings } from "./serviceClient";
import { AbortSignalLike } from "@azure/abort-controller";
import { SpanOptions } from "@opentelemetry/types";
import { SpanOptions } from "@azure/core-tracing";

export type HttpMethods =
| "GET"
Expand Down
14 changes: 7 additions & 7 deletions sdk/core/core-http/test/policies/tracingPolicyTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
HttpHeaders,
RequestPolicyOptions
} from "../../src/coreHttp";
import { SpanOptions, SpanContext, TraceFlags } from "@opentelemetry/types";
import { SpanOptions, SpanContext, TraceFlags } from "@opentelemetry/api";
import { setTracer, NoOpTracer, NoOpSpan } from "@azure/core-tracing";
import { tracingPolicy } from "../../src/policies/tracingPolicy";

Expand Down Expand Up @@ -60,7 +60,7 @@ class MockTracer extends NoOpTracer {
constructor(
private traceId = "",
private spanId = "",
private flags = TraceFlags.UNSAMPLED,
private flags = TraceFlags.NONE,
private state = ""
) {
super();
Expand Down Expand Up @@ -114,7 +114,7 @@ describe("tracingPolicy", function() {
setTracer(mockTracer);
const request = new WebResource();
request.spanOptions = {
parent: ROOT_SPAN
parent: ROOT_SPAN.context()
};
const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions());
await policy.sendRequest(request);
Expand All @@ -141,7 +141,7 @@ describe("tracingPolicy", function() {
setTracer(mockTracer);
const request = new WebResource();
request.spanOptions = {
parent: ROOT_SPAN
parent: ROOT_SPAN.context()
};
const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions());
await policy.sendRequest(request);
Expand All @@ -168,7 +168,7 @@ describe("tracingPolicy", function() {
setTracer(mockTracer);
const request = new WebResource();
request.spanOptions = {
parent: ROOT_SPAN
parent: ROOT_SPAN.context()
};
const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions());
await policy.sendRequest(request);
Expand All @@ -195,7 +195,7 @@ describe("tracingPolicy", function() {
setTracer(mockTracer);
const request = new WebResource();
request.spanOptions = {
parent: ROOT_SPAN
parent: ROOT_SPAN.context()
};
const policy = tracingPolicy().create(
{
Expand Down Expand Up @@ -233,7 +233,7 @@ describe("tracingPolicy", function() {
setTracer(new NoOpTracer());
const request = new WebResource();
request.spanOptions = {
parent: ROOT_SPAN
parent: ROOT_SPAN.context()
};
const policy = tracingPolicy().create(mockPolicy, new RequestPolicyOptions());
await policy.sendRequest(request);
Expand Down
4 changes: 2 additions & 2 deletions sdk/core/core-lro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@
"sideEffects": false,
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-http": "^1.0.0",
"@azure/core-http": "^1.1.1",
"events": "^3.0.0",
"tslib": "^1.10.0"
},
"devDependencies": {
"@opentelemetry/types": "^0.2.0",
"@opentelemetry/api": "^0.6.1",
"@microsoft/api-extractor": "7.7.11",
"@rollup/plugin-commonjs": "^11.0.1",
"@rollup/plugin-multi-entry": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-lro/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function browserConfig(test = false) {
cjs({
namedExports: {
assert: ["ok", "equal", "strictEqual"],
"@opentelemetry/types": ["CanonicalCode", "SpanKind", "TraceFlags"]
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"]
}
})
]
Expand Down
5 changes: 5 additions & 0 deletions sdk/core/core-tracing/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## 1.0.0-preview.8 (Unreleased)

- Update `TestSpan` to allow setting span attributes [PR link](https://github.com/Azure/azure-sdk-for-js/pull/6565).
- [BREAKING] Migrate to OpenTelemetry 0.6 using the new `@opentelemetry/api` package. There were a few breaking changes:
- `SpanContext` now requires traceFlags to be set.
- `Tracer` has removed `recordSpanData`, `getBinaryFormat`, and `getHttpTextFormat`.
- `Tracer.getCurrentSpan` returns `undefined` instead of `null` when unset.
- `Link` objects renamed `spanContext` property to `context`.

## 1.0.0-preview.7 (2019-12-03)

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"sideEffects": false,
"dependencies": {
"@opencensus/web-types": "0.0.7",
"@opentelemetry/types": "^0.2.0",
"@opentelemetry/api": "^0.6.1",
"tslib": "^1.10.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 1b7428d

Please sign in to comment.