Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aurox/telemetry

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aurox/telemetry - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

42

dist/tracer/setup.d.ts
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import { ExporterConfig } from '@opentelemetry/exporter-jaeger';
import { TraceAPI, ContextAPI, Span, Context, SpanStatusCode } from '@opentelemetry/api';
import { TraceAPI, ContextAPI, Span, Context, SpanStatusCode, Tracer as OpentelemetryTracer } from '@opentelemetry/api';
import { Beacon } from '../beacon';

@@ -11,7 +11,41 @@ export { SpanStatusCode, SemanticAttributes, TraceAPI, ContextAPI, Span, Context };

}
export interface Tracer {
trace: TraceAPI;
context: ContextAPI;
export interface Tracer extends OpentelemetryTracer {
getTracerAPI: () => OpentelemetryTracer;
traceAPI: TraceAPI;
contextAPI: ContextAPI;
ready: Promise<void>;
/**
* Get the currently active context
*/
active(): Context;
/**
* Execute a function with an active context
*
* @param context context to be active during function execution
* @param fn function to execute in a context
* @param thisArg optional receiver to be used for calling fn
* @param args optional arguments forwarded to fn
*/
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
/**
* Bind a context to a target function or event emitter
*
* @param context context to bind to the event emitter or function. Defaults to the currently active context
* @param target function or event emitter to bind
*/
bind<T>(context: Context, target: T): T;
/**
* Return the span if one exists
*
* @param context context to get span from
*/
getSpan(context: Context): Span | undefined;
/**
* Set the span on a context
*
* @param context context to use as parent
* @param span span to set active
*/
setSpan(context: Context, span: Span): Context;
}
export declare function setupTracer(beacon: Beacon, options?: SetupTracerOptions): Tracer;

@@ -19,4 +19,39 @@ "use strict";

const sampleRate = options?.sampleRate ?? config_1.tracerSampleRate;
let tracer = api_1.trace.getTracer(config_1.instanceName);
const getTracerAPI = () => tracer;
function startSpan(name, options, context) {
return tracer.startSpan(name, options, context);
}
function startActiveSpan(...arg) {
return tracer.startActiveSpan(...arg);
}
function getSpan(context) {
return api_1.trace.getSpan(context);
}
function setSpan(context, span) {
return api_1.trace.setSpan(context, span);
}
function active() {
return api_1.context.active();
}
function withFn(...args) {
return api_1.context.with(...args);
}
function bind(ctx, target) {
return api_1.context.bind(ctx, target);
}
if (config_1.tracerDisabled) {
return { trace: api_1.trace, context: api_1.context, ready: Promise.resolve() };
return {
getTracerAPI,
getSpan,
setSpan,
startSpan,
startActiveSpan,
active,
bind,
with: withFn,
traceAPI: api_1.trace,
contextAPI: api_1.context,
ready: Promise.resolve(),
};
}

@@ -51,5 +86,20 @@ if (config_1.tracerDebug) {

const ready = sdk.start();
return { trace: api_1.trace, context: api_1.context, ready };
ready.then(() => {
tracer = api_1.trace.getTracer(config_1.instanceName);
});
return {
getTracerAPI,
getSpan,
setSpan,
startSpan,
startActiveSpan,
active,
bind,
with: withFn,
traceAPI: api_1.trace,
contextAPI: api_1.context,
ready,
};
}
exports.setupTracer = setupTracer;
//# sourceMappingURL=setup.js.map

2

package.json
{
"name": "@aurox/telemetry",
"version": "0.2.10",
"version": "0.2.11",
"description": "A universal solution for logging, tracing, metrics, health-checks and more",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -21,2 +21,4 @@ import { SemanticAttributes, SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';

SpanStatusCode,
SpanOptions,
Tracer as OpentelemetryTracer,
} from '@opentelemetry/api';

@@ -35,6 +37,51 @@

export interface Tracer {
trace: TraceAPI;
context: ContextAPI;
export interface Tracer extends OpentelemetryTracer {
getTracerAPI: () => OpentelemetryTracer;
traceAPI: TraceAPI;
contextAPI: ContextAPI;
ready: Promise<void>;
// Context Helpers
/**
* Get the currently active context
*/
active(): Context;
/**
* Execute a function with an active context
*
* @param context context to be active during function execution
* @param fn function to execute in a context
* @param thisArg optional receiver to be used for calling fn
* @param args optional arguments forwarded to fn
*/
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(
context: Context,
fn: F,
thisArg?: ThisParameterType<F>,
...args: A
): ReturnType<F>;
/**
* Bind a context to a target function or event emitter
*
* @param context context to bind to the event emitter or function. Defaults to the currently active context
* @param target function or event emitter to bind
*/
bind<T>(context: Context, target: T): T;
// TraceAPI helpers
/**
* Return the span if one exists
*
* @param context context to get span from
*/
getSpan(context: Context): Span | undefined;
/**
* Set the span on a context
*
* @param context context to use as parent
* @param span span to set active
*/
setSpan(context: Context, span: Span): Context;
}

@@ -46,4 +93,48 @@

let tracer = trace.getTracer(instanceName);
const getTracerAPI = () => tracer;
function startSpan(name: string, options?: SpanOptions, context?: Context): Span {
return tracer.startSpan(name, options, context);
}
function startActiveSpan(...arg: any[]): any {
return (tracer.startActiveSpan as any)(...arg);
}
function getSpan(context: Context): Span | undefined {
return trace.getSpan(context);
}
function setSpan(context: Context, span: Span): Context {
return trace.setSpan(context, span);
}
function active(): Context {
return context.active();
}
function withFn(...args: any[]): any {
return (context.with as any)(...args);
}
function bind<T>(ctx: Context, target: T): T {
return context.bind(ctx, target);
}
if (tracerDisabled) {
return { trace, context, ready: Promise.resolve() };
return {
getTracerAPI,
getSpan,
setSpan,
startSpan,
startActiveSpan,
active,
bind,
with: withFn,
traceAPI: trace,
contextAPI: context,
ready: Promise.resolve(),
};
}

@@ -86,3 +177,19 @@

return { trace, context, ready };
ready.then(() => {
tracer = trace.getTracer(instanceName);
});
return {
getTracerAPI,
getSpan,
setSpan,
startSpan,
startActiveSpan,
active,
bind,
with: withFn,
traceAPI: trace,
contextAPI: context,
ready,
};
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc