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

[core-tracing] Update to OpenTelemetry 0.6 #7998

Merged
merged 38 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
113e8e4
Move to core-tracing to OpenTelemetry 0.5
xirzec Mar 24, 2020
513a49a
Migrate all packages to OpenTelemetry 0.5
xirzec Mar 24, 2020
4b4533c
Bump version of core-tracing
xirzec Mar 24, 2020
d7d5691
Bump cache version
xirzec Mar 24, 2020
37cb01b
Fixup changelog
xirzec Mar 25, 2020
ac2011a
Fix build breaks
xirzec Mar 25, 2020
a06d2e5
Fix named export
xirzec Mar 25, 2020
f2b1a77
Revert using OT noop
xirzec Mar 25, 2020
8e455ba
fix build break
xirzec Mar 25, 2020
3f4d0f4
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Mar 26, 2020
3bb121d
update lockfil
xirzec Mar 26, 2020
2b85d20
Create new tracing interfaces
xirzec Mar 27, 2020
f508508
Try to adopt
xirzec Mar 27, 2020
15d6c1c
Fix build breaks
xirzec Mar 27, 2020
2109b5b
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Mar 27, 2020
e2d872b
Update lockfile
xirzec Mar 27, 2020
5fa208d
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Mar 27, 2020
ad0301d
Update lockfile
xirzec Mar 28, 2020
7cb934f
Merge branch 'master' into OT05
xirzec Mar 28, 2020
5d40a9b
Merge branch 'master' into OT05
xirzec Mar 30, 2020
04e4699
Update lockfile
xirzec Mar 30, 2020
4b49cf7
Fix test break
xirzec Mar 30, 2020
d203333
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Apr 16, 2020
e53ce32
fixup
xirzec Apr 16, 2020
3bbb73c
update lockfile
xirzec Apr 16, 2020
b04875e
Fix identity and search
xirzec Apr 16, 2020
76c875a
Fix form recognizer
xirzec Apr 16, 2020
d96896b
Update min version of core-http
xirzec Apr 17, 2020
00be357
Update to OpenTelemetry 0.6.1
xirzec Apr 17, 2020
3fee5c8
Merge remote-tracking branch 'origin' into pr/xirzec/7998
ramya-rao-a Apr 20, 2020
a01b8eb
Update sdk/core/core-tracing/CHANGELOG.md
xirzec Apr 21, 2020
0831e8b
Update sdk/core/core-tracing/src/utils/cache.ts
xirzec Apr 21, 2020
938ea38
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Apr 22, 2020
1ed0928
Fix merge conflicts
xirzec Apr 22, 2020
e09ff90
Fix broken eventhubs test
xirzec Apr 22, 2020
bd0a000
Ensure datalake depends on latest blob
xirzec Apr 23, 2020
3aed715
Merge remote-tracking branch 'upstream/master' into OT05
xirzec Apr 23, 2020
ab0796a
Update deps
xirzec Apr 23, 2020
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
76 changes: 55 additions & 21 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 4 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
4 changes: 2 additions & 2 deletions sdk/appconfiguration/app-configuration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,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(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect the parent of a span to also be of type span... this would be one of the things the user can pass in right?
We are changing that now, or was that never the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenTelemetry lets you pass either a Span or a SpanContext. This is mostly for convenience as it is not hard to get the context.

However, since Span is a much bigger surface area than context, the proposal is to not support direct passing of spans in our options in order to avoid having to risk breaking changes in Span.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes, this is a breaking change.

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"]
ramya-rao-a marked this conversation as resolved.
Show resolved Hide resolved
}
}),
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";
ramya-rao-a marked this conversation as resolved.
Show resolved Hide resolved
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
67 changes: 42 additions & 25 deletions sdk/core/core-tracing/review/core-tracing.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

```ts

import { Attributes } from '@opentelemetry/types';
import { BinaryFormat } from '@opentelemetry/types';
import { HttpTextFormat } from '@opentelemetry/types';
import { Attributes } from '@opentelemetry/api';
import { Span as OpenCensusSpan } from '@opencensus/web-types';
import { Tracer as OpenCensusTracer } from '@opencensus/web-types';
import { Span } from '@opentelemetry/types';
import { SpanContext } from '@opentelemetry/types';
import { SpanKind } from '@opentelemetry/types';
import { SpanOptions } from '@opentelemetry/types';
import { Status } from '@opentelemetry/types';
import { TimeInput } from '@opentelemetry/types';
import { Tracer } from '@opentelemetry/types';
import { SpanContext as OTSpanContext } from '@opentelemetry/api';
import { SpanOptions as OTSpanOptions } from '@opentelemetry/api';
import { Span } from '@opentelemetry/api';
import { SpanKind } from '@opentelemetry/api';
import { Status } from '@opentelemetry/api';
import { TimeInput } from '@opentelemetry/api';
import { Tracer } from '@opentelemetry/api';
import { TracerBase } from '@opencensus/web-types';

// @public
Expand All @@ -30,7 +28,7 @@ export function getTracer(): Tracer;
// @public
export class NoOpSpan implements Span {
addEvent(_name: string, _attributes?: Attributes): this;
context(): SpanContext;
context(): OTSpanContext;
end(_endTime?: number): void;
isRecording(): boolean;
setAttribute(_key: string, _value: unknown): this;
Expand All @@ -42,11 +40,8 @@ export class NoOpSpan implements Span {
// @public
export class NoOpTracer implements Tracer {
bind<T>(target: T, _span?: Span): T;
getBinaryFormat(): BinaryFormat;
getCurrentSpan(): Span;
getHttpTextFormat(): HttpTextFormat;
recordSpanData(_span: Span): void;
startSpan(_name: string, _options?: SpanOptions): Span;
startSpan(_name: string, _options?: OTSpanOptions): Span;
withSpan<T extends (...args: unknown[]) => ReturnType<T>>(_span: Span, fn: T): ReturnType<T>;
}

Expand All @@ -55,9 +50,9 @@ export { OpenCensusSpan }
// @public
export class OpenCensusSpanWrapper implements Span {
constructor(span: OpenCensusSpan);
constructor(tracer: OpenCensusTracerWrapper, name: string, options?: SpanOptions);
constructor(tracer: OpenCensusTracerWrapper, name: string, options?: OTSpanOptions);
addEvent(_name: string, _attributes?: Attributes): this;
context(): SpanContext;
context(): OTSpanContext;
end(_endTime?: number): void;
getWrappedSpan(): OpenCensusSpan;
isRecording(): boolean;
Expand All @@ -73,12 +68,9 @@ export { OpenCensusTracer }
export class OpenCensusTracerWrapper implements Tracer {
constructor(tracer: TracerBase);
bind<T>(_target: T, _span?: Span): T;
getBinaryFormat(): BinaryFormat;
getCurrentSpan(): Span | null;
getHttpTextFormat(): HttpTextFormat;
ramya-rao-a marked this conversation as resolved.
Show resolved Hide resolved
getCurrentSpan(): Span | undefined;
getWrappedTracer(): TracerBase;
recordSpanData(_span: Span): void;
startSpan(name: string, options?: SpanOptions): Span;
startSpan(name: string, options?: OTSpanOptions): Span;
withSpan<T extends (...args: unknown[]) => unknown>(_span: Span, _fn: T): ReturnType<T>;
}

Expand All @@ -87,9 +79,20 @@ export interface OperationTracingOptions {
spanOptions?: SpanOptions;
}

export { OTSpanContext }

export { OTSpanOptions }

// @public
export function setTracer(tracer: Tracer): void;

// @public
export interface SpanContext {
spanId: string;
traceFlags: number;
traceId: string;
}

// @public
export interface SpanGraph {
roots: SpanGraphNode[];
Expand All @@ -101,11 +104,19 @@ export interface SpanGraphNode {
name: string;
}

// @public
export interface SpanOptions {
attributes?: {
[key: string]: unknown;
};
parent?: SpanContext | null;
}

// @public
export class TestSpan extends NoOpSpan {
constructor(parentTracer: TestTracer, name: string, context: SpanContext, kind: SpanKind, parentSpanId?: string, startTime?: TimeInput);
constructor(parentTracer: TestTracer, name: string, context: OTSpanContext, kind: SpanKind, parentSpanId?: string, startTime?: TimeInput);
readonly attributes: Attributes;
context(): SpanContext;
context(): OTSpanContext;
end(_endTime?: number): void;
endCalled: boolean;
isRecording(): boolean;
Expand All @@ -126,9 +137,15 @@ export class TestTracer extends NoOpTracer {
getKnownSpans(): TestSpan[];
getRootSpans(): TestSpan[];
getSpanGraph(traceId: string): SpanGraph;
startSpan(name: string, options?: SpanOptions): TestSpan;
startSpan(name: string, options?: OTSpanOptions): TestSpan;
}

// @public
export const enum TraceFlags {
NONE = 0,
SAMPLED = 1
}


// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion sdk/core/core-tracing/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function browserConfig(test = false) {
}),
cjs({
namedExports: {
"@opentelemetry/types": ["CanonicalCode", "SpanKind", "TraceFlags"],
"@opentelemetry/api": ["CanonicalCode", "SpanKind", "TraceFlags"],
assert: ["ok", "fail", "equal", "deepEqual", "deepStrictEqual", "strictEqual"]
}
}),
Expand Down
Loading