@azure/core-tracing 1.0.0-preview.10 → 1.0.0-preview.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +68 -52
- package/dist/index.js +147 -648
- package/dist/index.js.map +1 -1
- package/dist-esm/src/index.js +2 -11
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/instrumenter.js +61 -0
- package/dist-esm/src/instrumenter.js.map +1 -0
- package/dist-esm/src/interfaces.js.map +1 -1
- package/dist-esm/src/tracingClient.js +74 -0
- package/dist-esm/src/tracingClient.js.map +1 -0
- package/dist-esm/src/tracingContext.js +52 -0
- package/dist-esm/src/tracingContext.js.map +1 -0
- package/package.json +45 -39
- package/types/core-tracing.d.ts +189 -405
- package/dist-esm/src/createSpan.js +0 -46
- package/dist-esm/src/createSpan.js.map +0 -1
- package/dist-esm/src/tracerProxy.js +0 -31
- package/dist-esm/src/tracerProxy.js.map +0 -1
- package/dist-esm/src/tracers/noop/noOpSpan.js +0 -74
- package/dist-esm/src/tracers/noop/noOpSpan.js.map +0 -1
- package/dist-esm/src/tracers/noop/noOpTracer.js +0 -44
- package/dist-esm/src/tracers/noop/noOpTracer.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusSpanWrapper.js +0 -113
- package/dist-esm/src/tracers/opencensus/openCensusSpanWrapper.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusTraceStateWrapper.js +0 -25
- package/dist-esm/src/tracers/opencensus/openCensusTraceStateWrapper.js.map +0 -1
- package/dist-esm/src/tracers/opencensus/openCensusTracerWrapper.js +0 -54
- package/dist-esm/src/tracers/opencensus/openCensusTracerWrapper.js.map +0 -1
- package/dist-esm/src/tracers/test/testSpan.js +0 -93
- package/dist-esm/src/tracers/test/testSpan.js.map +0 -1
- package/dist-esm/src/tracers/test/testTracer.js +0 -127
- package/dist-esm/src/tracers/test/testTracer.js.map +0 -1
- package/dist-esm/src/utils/cache.js +0 -43
- package/dist-esm/src/utils/cache.js.map +0 -1
- package/dist-esm/src/utils/global.browser.js +0 -6
- package/dist-esm/src/utils/global.browser.js.map +0 -1
- package/dist-esm/src/utils/global.js +0 -6
- package/dist-esm/src/utils/global.js.map +0 -1
- package/dist-esm/src/utils/traceParentHeader.js +0 -48
- package/dist-esm/src/utils/traceParentHeader.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
## 1.0.0-preview.14 (2022-02-03)
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- @azure/core-tracing has been rewritten in order to provide cleaner abstractions for client libraries as well as remove @opentelemetry/api as a direct dependency.
|
|
8
|
+
- @opentelemetry/api is no longer a direct dependency of @azure/core-tracing providing for smaller bundle sizes and lower incidence of version conflicts
|
|
9
|
+
- `createSpanFunction` has been removed and replaced with a stateful `TracingClient` which can be created using the `createTracingClient` function.
|
|
10
|
+
- `TracingClient` introduces a new API for creating tracing spans. Use `TracingClient#withSpan` to wrap an invocation in a span, ensuring the span is ended and exceptions are captured.
|
|
11
|
+
- `TracingClient` also provides the lower-level APIs necessary to start a span without making it active, create request headers, serialize `traceparent` header, and wrapping a callback with an active context.
|
|
12
|
+
|
|
13
|
+
### Other Changes
|
|
14
|
+
|
|
15
|
+
- Updates package to work with the react native bundler. [PR #17783](https://github.com/Azure/azure-sdk-for-js/pull/17783)
|
|
16
|
+
|
|
17
|
+
## 1.0.0-preview.13 (2021-07-15)
|
|
18
|
+
|
|
19
|
+
### Features Added
|
|
20
|
+
|
|
21
|
+
- Added support for disabling distributed tracing using the AZURE_TRACING_DISABLED environment variable.
|
|
22
|
+
|
|
23
|
+
### Breaking Changes
|
|
24
|
+
|
|
25
|
+
- Removed `TestTracer` and `TestSpan` from public API and into `@azure/test-utils`. [PR #16315](https://github.com/Azure/azure-sdk-for-js/pull/16315)
|
|
26
|
+
- `TestTracer` and `TestSpan` are intended for test support when used by other Azure packages and not intended for use by end users.
|
|
27
|
+
- Removed `setTracer`, @azure/core-tracing will now rely on the `trace` API to fetch a tracer from the global tracer provider. [PR #16347](https://github.com/Azure/azure-sdk-for-js/pull/16347)
|
|
28
|
+
- If you are using `setTracer`, please use `trace.setGlobalTracerProvider(provider)` instead as described in the OpenTelemetry documentation.
|
|
29
|
+
- Removed `NoOpTracer` and `NoOpSpan` from the public API. Please use `trace.wrapSpanContext(INVALID_SPAN_CONTEXT)` from `@opentelemetry/api` instead. [PR #16315](https://github.com/Azure/azure-sdk-for-js/pull/16315)
|
|
30
|
+
|
|
31
|
+
## 1.0.0-preview.12 (2021-06-30)
|
|
32
|
+
|
|
33
|
+
- Update `@opentelemetry/api` to version 1.0.0 [PR #15883](https://github.com/Azure/azure-sdk-for-js/pull/15883)
|
|
34
|
+
- This version ships with ESM modules and fixes an issue where Angular projects would warn ab out optimization bailouts due to dependencies on CommonJS or AMD.
|
|
35
|
+
|
|
36
|
+
### Breaking Changes
|
|
37
|
+
|
|
38
|
+
- Removed `OpenCensusSpanWrapper` and `OpenCensusTracerWrapper` from the public API. Customers using these wrappers should migrate to using `OpenTelemetry` directly. [PR #15770](https://github.com/Azure/azure-sdk-for-js/pull/15770)
|
|
39
|
+
- Update `@azure/core-tracing` to version 1.0.0-preview.12. This brings core-tracing up to date with `@opentelemetry/api@1.0.0`.
|
|
40
|
+
- `Span#context` was renamed to `Span#spanContext`. This change is supported in `@azure/core-http@1.2.7`.
|
|
41
|
+
|
|
42
|
+
## 1.0.0-preview.11 (2021-03-30)
|
|
43
|
+
|
|
44
|
+
### Breaking Changes
|
|
45
|
+
|
|
46
|
+
- Update @azure/core-tracing to version 1.0.0-preview.11. This brings core-tracing up to date with @opentelemetry/api@1.0.0-rc.0.
|
|
47
|
+
There are two scenarios that will require changes if you are using tracing:
|
|
48
|
+
- Previously, you would pass a parent span using the `OperationOptions.tracingOptions.spanOptions.parentSpan` property. This has been
|
|
49
|
+
changed so that you now specify a parent `Context` using the `OperationOptions.tracingOptions.tracingContext` property instead.
|
|
50
|
+
- The status code for Spans is no longer of type `CanonicalCode`. Instead, it's now `SpanStatusCode`, which also has a smaller range of values.
|
|
51
|
+
|
|
3
52
|
## 1.0.0-preview.10 (2021-03-04)
|
|
4
53
|
|
|
5
54
|
- Internal improvements to make future opentelemetry updates simpler.
|
package/README.md
CHANGED
|
@@ -14,77 +14,93 @@ npm install @azure/core-tracing
|
|
|
14
14
|
|
|
15
15
|
## Key Concepts
|
|
16
16
|
|
|
17
|
-
The `@azure/core-tracing` package supports enabling tracing for Azure SDK packages, using an [OpenTelemetry](https://opentelemetry.io/) `Tracer`.
|
|
17
|
+
The `@azure/core-tracing` package supports enabling tracing for Azure SDK packages, using an [OpenTelemetry](https://opentelemetry.io/) `Tracer`.
|
|
18
18
|
|
|
19
|
-
By default, all libraries log with a `NoOpTracer` that takes no action.
|
|
20
|
-
To change this, you have to use `setTracer` to set a new default `Tracer`.
|
|
19
|
+
By default, all libraries log with a `NoOpTracer` that takes no action. To enable tracing, you will need to set a global tracer provider following the instructions in the [OpenTelemetry getting started guide](https://opentelemetry.io/docs/js/getting_started/nodejs) or the [Enabling Tracing using OpenTelemetry example](#enabling-tracing-using-opentelemetry) below.
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
### Span Propagation
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
Core Tracing supports both automatic and manual span propagation. Automatic propagation is handled using OpenTelemetry's API and will work well in most scenarios when run in `Node.js`.
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
const opentelemetry = require("@opentelemetry/core");
|
|
28
|
-
const { BasicTracer, SimpleSpanProcessor } = require("@opentelemetry/tracing");
|
|
29
|
-
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
|
|
30
|
-
const { setTracer } = require("@azure/core-tracing");
|
|
25
|
+
For customers who require manual propagation, or to provide context propagation in the browser, all client library operations accept an optional options collection where a tracingContext can be passed in and used as the currently active context. Please see the [Manual Span Propagation example](#manual-span-propagation-using-opentelemetry) below for more details.
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
serviceName: "azure-tracing-sample"
|
|
34
|
-
});
|
|
35
|
-
const tracer = new BasicTracer();
|
|
36
|
-
tracer.addSpanProcessor(new SimpleSpanProcessor(exporter));
|
|
27
|
+
### OpenTelemetry Compatibility
|
|
37
28
|
|
|
38
|
-
opentelemetry.
|
|
29
|
+
Most Azure SDKs and Microsoft's [Application Insights](https://www.npmjs.com/package/applicationinsights) use [OpenTelemetry](https://opentelemetry.io/) to support tracing. Specifically, we depend on the [@opentelemetry/api](https://www.npmjs.com/package/@opentelemetry/api) npm package.
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
As OpenTelemetry iterated on their API towards their 1.0 GA release, our libraries were updated to match.
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
Some incompatibility between the libraries is due to mismatches between the OpenTelemetry versions used in either `@azure/core-tracing` or `applicationinsights` when the two are used side-by-side. For folks who are using both an Azure Client Library (and transitively, `@azure/core-tracing`) and Application Insights in the same application, we recommend using the same version of OpenTelemetry for both libraries by upgrading to their latest versions.
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
exporter.shutdown();
|
|
46
|
-
```
|
|
35
|
+
> Please note that we do not foresee any future compatibility concerns now that OpenTelemetry 1.0.0 has been released and the API considered stable.
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
37
|
+
#### Compatibility Matrix
|
|
38
|
+
|
|
39
|
+
| Core Tracing | Application Insights | @opentelemetry/api |
|
|
40
|
+
| ---------------- | -------------------- | ------------------ |
|
|
41
|
+
| 1.0.0-preview.10 | | 0.10.2 |
|
|
42
|
+
| 1.0.0-preview.11 | 2.1.0-2.1.3 | 1.0.0-rc.0 |
|
|
43
|
+
| 1.0.0-preview.12 | ^2.1.4 | ^1.0.0 |
|
|
44
|
+
| 1.0.0-preview.13 | ^2.1.4 | ^1.0.0 |
|
|
45
|
+
|
|
46
|
+
Please see the [troubleshooting](#troubleshooting) section for additional information about handling compatibility errors.
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
### Enabling tracing using OpenTelemetry
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
const opentelemetry = require("@opentelemetry/api");
|
|
54
|
+
const { SimpleSpanProcessor, ConsoleSpanExporter } = require("@opentelemetry/tracing");
|
|
55
|
+
|
|
56
|
+
const provider = new NodeTracerProvider();
|
|
57
|
+
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
|
|
58
|
+
provider.register();
|
|
59
|
+
|
|
60
|
+
// Call some client library methods using automatic span propagation.
|
|
73
61
|
```
|
|
74
62
|
|
|
75
|
-
###
|
|
63
|
+
### Manual Span Propagation using OpenTelemetry
|
|
76
64
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
65
|
+
```ts
|
|
66
|
+
const opentelemetry = require("@opentelemetry/api");
|
|
67
|
+
// Get a tracer from a registered provider, create a span, and get the current context
|
|
68
|
+
const tracer = opentelemetry.trace.getTracer("my-tracer");
|
|
69
|
+
const span = tracer.startSpan("main");
|
|
70
|
+
const ctx = opentelemetry.trace.setSpan(opentelemetry.context.active(), span);
|
|
71
|
+
|
|
72
|
+
// Assuming we have an existing BlobClient, let's see if the blob exists.
|
|
73
|
+
// The context is passed to the client library as a tracingContext option and will be propagated downstream to any child spans.
|
|
74
|
+
const result = await blobClient.exists({
|
|
80
75
|
tracingOptions: {
|
|
81
|
-
|
|
76
|
+
tracingContext: ctx
|
|
82
77
|
}
|
|
83
78
|
});
|
|
84
79
|
```
|
|
85
80
|
|
|
81
|
+
## Next steps
|
|
82
|
+
|
|
83
|
+
You can build and run the tests locally by executing `rushx test`. Explore the `test` folder to see advanced usage and behavior of the public classes.
|
|
84
|
+
|
|
85
|
+
## Troubleshooting
|
|
86
|
+
|
|
87
|
+
If you run into issues while using this library, please feel free to [file an issue](https://github.com/Azure/azure-sdk-for-js/issues/new).
|
|
88
|
+
|
|
89
|
+
### OpenTelemetry Compatibility Errors
|
|
90
|
+
|
|
91
|
+
Errors such as `span.spanContext is not a function` or `span.context is not a function` are likely due to a mismatch of OpenTelemetry versions between two libraries.
|
|
92
|
+
|
|
93
|
+
To resolve this, please ensure that all Azure client libraries are using a compatible version of OpenTelemetry as per the [compatibility matrix](#compatibility-matrix). If you are using `applicationinsights` please ensure that you are using the same version of OpenTelemetry as the Azure client libraries.
|
|
94
|
+
|
|
95
|
+
> Ideally you'd want to use OpenTelemetry 1.0.0 or higher.
|
|
96
|
+
|
|
97
|
+
- If you are using `npm` you may run `npm ls @opentelemetry/api` to see the version of OpenTelemetry you are using and which client libraries are using it.
|
|
98
|
+
- For `yarn` users, `yarn why @opentelemetry/api` will show you the version of OpenTelemetry you are using and which client libraries are using it.
|
|
99
|
+
|
|
100
|
+
You may then upgrade client libraries as needed to ensure compatibility. Things should work as expected when the above command returns a version of OpenTelemetry that is >= 1.0.0.
|
|
101
|
+
|
|
86
102
|
## Contributing
|
|
87
103
|
|
|
88
|
-
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/
|
|
104
|
+
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
89
105
|
|
|
90
106
|

|