Skip to content

Commit

Permalink
Fix core-tracing duplication (#5389)
Browse files Browse the repository at this point in the history
This PR fixes duplication issues with core-tracing.

core-http was inlining core-tracing, which caused get/setTracer to no longer be a global singleton.
  • Loading branch information
xirzec authored Oct 4, 2019
1 parent 671522a commit c355805
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 49 deletions.
1 change: 0 additions & 1 deletion sdk/core/core-http/lib/coreHttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,3 @@ export { ApiKeyCredentials, ApiKeyCredentialOptions } from "./credentials/apiKey
export { ServiceClientCredentials } from "./credentials/serviceClientCredentials";
export { TopicCredentials } from "./credentials/topicCredentials";
export { Authenticator } from "./credentials/credentials";
export * from "@azure/core-tracing";
1 change: 1 addition & 0 deletions sdk/core/core-http/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const nodeConfig = {
"tunnel",
"uuid/v4",
"xml2js",
"@azure/core-tracing"
],
output: {
file: "./dist/coreHttp.node.js",
Expand Down
15 changes: 2 additions & 13 deletions sdk/core/core-http/test/policies/tracingPolicyTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,8 @@
// Licensed under the MIT License.

import { assert } from "chai";
import {
RequestPolicy,
WebResource,
HttpOperationResponse,
HttpHeaders,
setTracer,
RequestPolicyOptions,
TraceFlags,
NoOpTracer,
SpanOptions,
SpanContext,
NoOpSpan
} from "../../lib/coreHttp";
import { RequestPolicy, WebResource, HttpOperationResponse, HttpHeaders, RequestPolicyOptions } from "../../lib/coreHttp";
import { setTracer, TraceFlags, NoOpTracer, SpanOptions, SpanContext, NoOpSpan } from "@azure/core-tracing";
import { tracingPolicy } from "../../lib/policies/tracingPolicy";

class MockSpan extends NoOpSpan {
Expand Down
1 change: 1 addition & 0 deletions sdk/identity/identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"sideEffects": false,
"dependencies": {
"@azure/core-http": "1.0.0-preview.4",
"@azure/core-tracing": "1.0.0-preview.3",
"events": "^3.0.0",
"jws": "^3.2.2",
"msal": "^1.0.2",
Expand Down
2 changes: 1 addition & 1 deletion sdk/identity/identity/src/client/identityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
WebResource,
RequestPrepareOptions,
GetTokenOptions,
CanonicalCode,
tracingPolicy,
RequestPolicyFactory
} from "@azure/core-http";
import { CanonicalCode } from "@azure/core-tracing";
import { AuthenticationError, AuthenticationErrorName } from "./errors";
import { createSpan } from "../util/tracing";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import qs from "qs";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { TokenCredential, GetTokenOptions, AccessToken, CanonicalCode } from "@azure/core-http";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient, TokenResponse } from "../client/identityClient";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables authentication to Azure Active Directory using an authorization code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { AccessToken, TokenCredential, GetTokenOptions, CanonicalCode } from "@azure/core-http";
import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
import { AggregateAuthenticationError } from "../client/errors";
import { createSpan } from "../util/tracing";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables multiple {@link TokenCredential} implementations to be tried in order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import jws from "jws";
import uuid from "uuid";
import { readFileSync } from "fs";
import { createHash } from "crypto";
import { TokenCredential, GetTokenOptions, AccessToken, CanonicalCode } from "@azure/core-http";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";

const SelfSignedJwtLifetimeMins = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Licensed under the MIT License.

import qs from "qs";
import { TokenCredential, GetTokenOptions, AccessToken, CanonicalCode } from "@azure/core-http";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables authentication to Azure Active Directory using a client secret
Expand Down
9 changes: 2 additions & 7 deletions sdk/identity/identity/src/credentials/deviceCodeCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
// Licensed under the MIT License.

import qs from "qs";
import {
TokenCredential,
GetTokenOptions,
AccessToken,
delay,
CanonicalCode
} from "@azure/core-http";
import { TokenCredential, GetTokenOptions, AccessToken, delay } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient, TokenResponse } from "../client/identityClient";
import { AuthenticationError, AuthenticationErrorName } from "../client/errors";
import { createSpan } from "../util/tracing";
import { CanonicalCode } from "@azure/core-tracing";

/**
* An internal interface that contains the verbatim devicecode response.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { AccessToken, TokenCredential, GetTokenOptions, CanonicalCode } from "@azure/core-http";
import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
import { IdentityClientOptions } from "../client/identityClient";
import { ClientSecretCredential } from "./clientSecretCredential";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables authentication to Azure Active Directory using client secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
// Licensed under the MIT License.

import * as msal from "msal";
import { AccessToken, TokenCredential, GetTokenOptions, CanonicalCode } from "@azure/core-http";
import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
import { IdentityClient } from "../client/identityClient";
import {
BrowserLoginStyle,
InteractiveBrowserCredentialOptions
} from "./interactiveBrowserCredentialOptions";
import { createSpan } from "../util/tracing";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables authentication to Azure Active Directory inside of the web browser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
GetTokenOptions,
RequestPrepareOptions,
RestError,
TokenCredential,
CanonicalCode
TokenCredential
} from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";

const DefaultScopeSuffix = "/.default";
export const ImdsEndpoint = "http://169.254.169.254/metadata/identity/oauth2/token";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
// Licensed under the MIT License.

import qs from "qs";
import { TokenCredential, GetTokenOptions, AccessToken, CanonicalCode } from "@azure/core-http";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";

/**
* Enables authentication to Azure Active Directory with a user's
Expand Down
3 changes: 2 additions & 1 deletion sdk/identity/identity/src/util/tracing.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { getTracer, Span, GetTokenOptions, SpanOptions, SpanKind } from "@azure/core-http";
import { GetTokenOptions } from "@azure/core-http";
import { getTracer, Span, SpanOptions, SpanKind } from "@azure/core-tracing";

/**
* Creates a span using the global tracer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import assert from "assert";
import { AuthorizationCodeCredential } from "../../src";
import { TestTracer, setTracer, SpanGraph } from "@azure/core-http";
import { TestTracer, setTracer, SpanGraph } from "@azure/core-tracing";
import { MockAuthHttpClient, assertClientCredentials } from "../authTestUtils";

describe("AuthorizationCodeCredential", function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from "path";
import assert from "assert";
import { ClientCertificateCredential } from "../../src";
import { MockAuthHttpClient } from "../authTestUtils";
import { setTracer, TestTracer, SpanGraph } from "@azure/core-http";
import { setTracer, TestTracer, SpanGraph } from "@azure/core-tracing";

describe("ClientCertificateCredential", function() {
it("loads a PEM-formatted certificate from a file", () => {
Expand Down
3 changes: 2 additions & 1 deletion sdk/identity/identity/test/node/deviceCodeCredential.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Licensed under the MIT License.

import assert from "assert";
import { delay, TestTracer, setTracer, SpanGraph } from "@azure/core-http";
import { delay } from "@azure/core-http";
import { TestTracer, setTracer, SpanGraph } from "@azure/core-tracing";
import { AbortController } from "@azure/abort-controller";
import { MockAuthHttpClient, assertRejects } from "../authTestUtils";
import { AuthenticationError, ErrorResponse } from "../../src/client/errors";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import assert from "assert";
import { EnvironmentCredential } from "../../src";
import { MockAuthHttpClient, assertClientCredentials } from "../authTestUtils";
import { TestTracer, setTracer, SpanGraph } from "@azure/core-http";
import { TestTracer, setTracer, SpanGraph } from "@azure/core-tracing";

describe("EnvironmentCredential", function() {
it("finds and uses client credential environment variables", async () => {
Expand Down
1 change: 1 addition & 0 deletions sdk/keyvault/keyvault-certificates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@azure/core-arm": "1.0.0-preview.4",
"@azure/core-http": "1.0.0-preview.4",
"@azure/core-paging": "1.0.0-preview.3",
"@azure/core-tracing": "1.0.0-preview.3",
"tslib": "^1.9.3"
},
"devDependencies": {
Expand Down
7 changes: 5 additions & 2 deletions sdk/keyvault/keyvault-certificates/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ import {
isNode,
userAgentPolicy,
RequestOptionsBase,
tracingPolicy,
tracingPolicy
} from "@azure/core-http";

import {
getTracer,
Span
} from "@azure/core-http";
} from "@azure/core-tracing";

import {
Certificate,
Expand Down
1 change: 1 addition & 0 deletions sdk/keyvault/keyvault-keys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"@azure/core-http": "1.0.0-preview.4",
"@azure/core-paging": "1.0.0-preview.3",
"@azure/identity": "1.0.0-preview.4",
"@azure/core-tracing": "1.0.0-preview.3",
"tslib": "^1.9.3"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions sdk/keyvault/keyvault-keys/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
isNode,
userAgentPolicy,
RequestOptionsBase,
tracingPolicy,
getTracer,
Span
tracingPolicy
} from "@azure/core-http";

import { getTracer, Span } from "@azure/core-tracing";

import "@azure/core-paging";
import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging";

Expand Down
1 change: 1 addition & 0 deletions sdk/keyvault/keyvault-secrets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@azure/core-http": "1.0.0-preview.4",
"@azure/core-paging": "1.0.0-preview.3",
"@azure/identity": "1.0.0-preview.4",
"@azure/core-tracing": "1.0.0-preview.3",
"tslib": "^1.9.3"
},
"devDependencies": {
Expand Down
12 changes: 4 additions & 8 deletions sdk/keyvault/keyvault-secrets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import {
getDefaultProxySettings,
isNode,
userAgentPolicy,
tracingPolicy,
getTracer,
Span
tracingPolicy
} from "@azure/core-http";

import { getTracer, Span } from "@azure/core-tracing";

import "@azure/core-paging";
import { PageSettings, PagedAsyncIterableIterator } from "@azure/core-paging";
import {
Expand Down Expand Up @@ -77,11 +77,7 @@ export {
UpdateSecretOptions
};

export {
ProxyOptions,
RetryOptions,
TelemetryOptions
};
export { ProxyOptions, RetryOptions, TelemetryOptions };

/**
* The client to interact with the KeyVault secrets functionality
Expand Down

0 comments on commit c355805

Please sign in to comment.