Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
@azure/core-tracing
Advanced tools
Provides low-level interfaces and helper methods for tracing in Azure SDK
The @azure/core-tracing package provides a common interface for adding tracing to Azure SDKs. It allows developers to collect detailed information about operations performed by Azure SDKs, making it easier to diagnose issues and optimize performance. The package is built on OpenTelemetry, a set of APIs, libraries, agents, and instrumentation that provide observability for applications.
Creating and managing spans
This feature allows developers to create and manage spans, which represent individual operations. Spans can be nested to represent complex operations composed of multiple steps. The code sample demonstrates how to create a tracing client, start a new span, and then end the span.
const { createTracingClient } = require('@azure/core-tracing');
const tracingClient = createTracingClient({
namespace: 'Microsoft.Azure',
packageName: 'AzureExample',
packageVersion: '1.0.0'
});
// Start a new span
cost span = tracingClient.startSpan('myOperation');
// End the span
span.end();
Integrating with Azure SDKs
This feature demonstrates how to integrate the @azure/core-tracing package with other Azure SDKs, such as Azure Storage Blobs. By passing a tracing client to the SDK's client constructor, developers can automatically collect tracing information for operations performed by the SDK.
const { DefaultAzureCredential } = require('@azure/identity');
const { BlobServiceClient } = require('@azure/storage-blob');
const { createTracingClient } = require('@azure/core-tracing');
const tracingClient = createTracingClient({
namespace: 'Microsoft.Azure',
packageName: 'Azure.Storage.Blobs',
packageVersion: '12.0.0'
});
const blobServiceClient = new BlobServiceClient(
'https://<my-storage-account>.blob.core.windows.net/',
new DefaultAzureCredential(),
{
tracingOptions: { tracingClient }
}
);
Jaeger client is a distributed tracing system that can be used to monitor and troubleshoot transactions in complex distributed systems. While it provides similar functionality to @azure/core-tracing in terms of tracing operations, Jaeger is a standalone system with its own backend and UI for visualizing traces, making it more suited for end-to-end tracing across multiple services and platforms.
This is the core tracing library that provides low-level interfaces and helper methods for tracing in Azure SDK JavaScript libraries which work in the browser and Node.js.
Install this library using npm as follows
npm install @azure/core-tracing
The @azure/core-tracing
package supports enabling tracing for Azure SDK packages, using an OpenTelemetry Tracer
. If you are using OpenCensus instead, we provide an OpenCensusTracerWrapper
that allows you to convert an OpenCensus Tracer
into an OpenTelemetry Tracer
.
By default, all libraries log with a NoOpTracer
that takes no action.
To change this, you have to use setTracer
to set a new default Tracer
.
const opentelemetry = require("@opentelemetry/core");
const { BasicTracer, SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { setTracer } = require("@azure/core-tracing");
const exporter = new ZipkinExporter({
serviceName: "azure-tracing-sample"
});
const tracer = new BasicTracer();
tracer.addSpanProcessor(new SimpleSpanProcessor(exporter));
opentelemetry.initGlobalTracer(tracer);
const rootSpan = opentelemetry.getTracer().startSpan("root");
// Call some client library methods and pass rootSpan via tracingOptions.
rootSpan.end();
exporter.shutdown();
const tracing = require("@opencensus/nodejs");
const { ZipkinTraceExporter } = require("@opencensus/exporter-zipkin");
const {
setTracer,
OpenCensusTracerWrapper,
OpenCensusSpanWrapper
} = require("@azure/core-tracing");
const tracer = tracing.start({ samplingRate: 1 }).tracer;
tracer.registerSpanEventListener(
new ZipkinTraceExporter({
serviceName: "azure-tracing-sample",
bufferTimeout: 2
})
);
setTracer(new OpenCensusTracerWrapper(tracer));
tracer.startRootSpan({ name: "root" }, async (rootSpanEx) => {
const rootSpan = new OpenCensusSpanWrapper(rootSpanEx);
// Call some client library methods and pass rootSpan via tracingOptions.
rootSpanEx.end(); // rootSpan.end() should work as well
});
// Given a BlobClient from @azure/storage-blob
const result = await blobClient.download(undefined, undefined, {
tracingOptions: {
spanOptions: { parent: rootSpan }
}
});
If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.
FAQs
Provides low-level interfaces and helper methods for tracing in Azure SDK
The npm package @azure/core-tracing receives a total of 4,876,973 weekly downloads. As such, @azure/core-tracing popularity was classified as popular.
We found that @azure/core-tracing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.