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

Update opentelemetry-js: 1.18.0 -> 1.24.0 #5

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion hack/bundle-opentelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ async function buildModuleWithRollup(directory: string, modName: string, externa
return match[0].slice(0, start) + newImport + match[0].slice(end);
});

text = text.replace(`import { randomUUID } from 'crypto';`, '');
text = text.replace(` randomUUID()`, ` crypto.randomUUID()`);
text = text.replace(`typeof process !== 'undefined' && process && process.env\n ? parseEnvironment(process.env)\n : parseEnvironment(_globalThis$1);`, `parseEnvironment(Deno.env.toObject())`);
text = text.replace(`(process.env)`, `(Deno.env.toObject())`);
text = text.replace(`os.hostname()`, `Deno.hostname?.()`);
Expand Down Expand Up @@ -236,7 +238,13 @@ await Deno.writeTextFile('hack/opentelemetry-js/tsconfig.esnext.deno.json', JSON
console.error(`Running npm install...`);
{
const npm = new Deno.Command('npm', {
args: ['install', /*'--production',*/ '--ignore-scripts'],
args: [
'install',
// '--production',
'--ignore-scripts',
'--no-audit',
'--no-fund',
],
cwd: 'hack/opentelemetry-js',
stdout: 'inherit',
stderr: 'inherit',
Expand Down
2 changes: 1 addition & 1 deletion hack/opentelemetry-js
Submodule opentelemetry-js updated 359 files
45 changes: 25 additions & 20 deletions opentelemetry/api-events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { Attributes } from './api.d.ts';
import { AnyValue } from './api-logs.d.ts';

interface Event {
/**
Expand All @@ -26,6 +27,11 @@ interface Event {
*/
name: string;
/**
* Data that describes the event.
* Intended to be used by instrumentation libraries.
*/
data?: AnyValue;
/**
* Additional attributes that describe the event.
*/
attributes?: Attributes;
Expand All @@ -43,7 +49,7 @@ interface Event {
spanId?: string;
}

interface EventEmitter {
interface EventLogger {
/**
* Emit an event. This method should only be used by instrumentations emitting events.
*
Expand All @@ -52,7 +58,7 @@ interface EventEmitter {
emit(event: Event): void;
}

interface EventEmitterOptions {
interface EventLoggerOptions {
/**
* The schemaUrl of the tracer or instrumentation library
* @default ''
Expand All @@ -65,43 +71,42 @@ interface EventEmitterOptions {
}

/**
* A registry for creating named {@link EventEmitter}s.
* A registry for creating named {@link EventLogger}s.
*/
interface EventEmitterProvider {
interface EventLoggerProvider {
/**
* Returns an EventEmitter, creating one if one with the given name, version, and
* Returns an EventLogger, creating one if one with the given name, version, and
* schemaUrl pair is not already created.
*
* @param name The name of the event emitter or instrumentation library.
* @param domain The domain for events created by the event emitter.
* @param version The version of the event emitter or instrumentation library.
* @param options The options of the event emitter or instrumentation library.
* @returns EventEmitter An event emitter with the given name and version.
* @param name The name of the event logger or instrumentation library.
* @param version The version of the event logger or instrumentation library.
* @param options The options of the event logger or instrumentation library.
* @returns EventLogger An event logger with the given name and version.
*/
getEventEmitter(name: string, domain: string, version?: string, options?: EventEmitterOptions): EventEmitter;
getEventLogger(name: string, version?: string, options?: EventLoggerOptions): EventLogger;
}

declare class EventsAPI {
private static _instance?;
private constructor();
static getInstance(): EventsAPI;
setGlobalEventEmitterProvider(provider: EventEmitterProvider): EventEmitterProvider;
setGlobalEventLoggerProvider(provider: EventLoggerProvider): EventLoggerProvider;
/**
* Returns the global event emitter provider.
* Returns the global event logger provider.
*
* @returns EventEmitterProvider
* @returns EventLoggerProvider
*/
getEventEmitterProvider(): EventEmitterProvider;
getEventLoggerProvider(): EventLoggerProvider;
/**
* Returns a event emitter from the global event emitter provider.
* Returns a event logger from the global event logger provider.
*
* @returns EventEmitter
* @returns EventLogger
*/
getEventEmitter(name: string, domain: string, version?: string, options?: EventEmitterOptions): EventEmitter;
/** Remove the global event emitter provider */
getEventLogger(name: string, version?: string, options?: EventLoggerOptions): EventLogger;
/** Remove the global event logger provider */
disable(): void;
}

declare const events: EventsAPI;

export { Event, EventEmitter, EventEmitterOptions, EventEmitterProvider, events };
export { Event, EventLogger, EventLoggerOptions, EventLoggerProvider, events };
24 changes: 12 additions & 12 deletions opentelemetry/api-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ function makeGetter(requiredVersion, instance, fallback) {
}
const API_BACKWARDS_COMPATIBILITY_VERSION = 1;

class NoopEventEmitter {
class NoopEventLogger {
emit(_event) { }
}

class NoopEventEmitterProvider {
getEventEmitter(_name, _domain, _version, _options) {
return new NoopEventEmitter();
class NoopEventLoggerProvider {
getEventLogger(_name, _version, _options) {
return new NoopEventLogger();
}
}
const NOOP_EVENT_EMITTER_PROVIDER = new NoopEventEmitterProvider();
const NOOP_EVENT_LOGGER_PROVIDER = new NoopEventLoggerProvider();

class EventsAPI {
constructor() { }
Expand All @@ -43,19 +43,19 @@ class EventsAPI {
}
return this._instance;
}
setGlobalEventEmitterProvider(provider) {
setGlobalEventLoggerProvider(provider) {
if (_global[GLOBAL_EVENTS_API_KEY]) {
return this.getEventEmitterProvider();
return this.getEventLoggerProvider();
}
_global[GLOBAL_EVENTS_API_KEY] = makeGetter(API_BACKWARDS_COMPATIBILITY_VERSION, provider, NOOP_EVENT_EMITTER_PROVIDER);
_global[GLOBAL_EVENTS_API_KEY] = makeGetter(API_BACKWARDS_COMPATIBILITY_VERSION, provider, NOOP_EVENT_LOGGER_PROVIDER);
return provider;
}
getEventEmitterProvider() {
getEventLoggerProvider() {
return (_global[GLOBAL_EVENTS_API_KEY]?.(API_BACKWARDS_COMPATIBILITY_VERSION) ??
NOOP_EVENT_EMITTER_PROVIDER);
NOOP_EVENT_LOGGER_PROVIDER);
}
getEventEmitter(name, domain, version, options) {
return this.getEventEmitterProvider().getEventEmitter(name, domain, version, options);
getEventLogger(name, version, options) {
return this.getEventLoggerProvider().getEventLogger(name, version, options);
}
disable() {
delete _global[GLOBAL_EVENTS_API_KEY];
Expand Down
25 changes: 17 additions & 8 deletions opentelemetry/api-logs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
* limitations under the License.
*/

import { AttributeValue, Context, Attributes } from './api.d.ts';
import { AttributeValue, TimeInput, Context, Attributes } from './api.d.ts';

declare type LogAttributeValue = AttributeValue | LogAttributes;
interface LogAttributes {
[attributeKey: string]: LogAttributeValue | undefined;
/**
* AnyValueMap is a map from string to AnyValue (attribute value or a nested map)
*/
interface AnyValueMap {
[attributeKey: string]: AnyValue | undefined;
}
/**
* AnyValue is a either an attribute value or a map of AnyValue(s)
*/
declare type AnyValue = AttributeValue | AnyValueMap;

declare type LogBody = AnyValue;
declare type LogAttributes = AnyValueMap;
declare enum SeverityNumber {
UNSPECIFIED = 0,
TRACE = 1,
Expand Down Expand Up @@ -51,11 +60,11 @@ interface LogRecord {
/**
* The time when the log record occurred as UNIX Epoch time in nanoseconds.
*/
timestamp?: number;
timestamp?: TimeInput;
/**
* Time when the event was observed by the collection system.
*/
observedTimestamp?: number;
observedTimestamp?: TimeInput;
/**
* Numerical value of the severity.
*/
Expand All @@ -67,7 +76,7 @@ interface LogRecord {
/**
* A value containing the body of the log record.
*/
body?: string;
body?: LogBody;
/**
* Attributes that define the log record.
*/
Expand Down Expand Up @@ -153,4 +162,4 @@ declare class LogsAPI {

declare const logs: LogsAPI;

export { LogAttributeValue, LogAttributes, LogRecord, Logger, LoggerOptions, LoggerProvider, NOOP_LOGGER, NOOP_LOGGER_PROVIDER, NoopLogger, NoopLoggerProvider, SeverityNumber, logs };
export { AnyValue, AnyValueMap, LogAttributes, LogBody, LogRecord, Logger, LoggerOptions, LoggerProvider, NOOP_LOGGER, NOOP_LOGGER_PROVIDER, NoopLogger, NoopLoggerProvider, SeverityNumber, logs };
2 changes: 1 addition & 1 deletion opentelemetry/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

const _globalThis = typeof globalThis === 'object' ? globalThis : global;

const VERSION = "1.7.0";
const VERSION = "1.8.0";

const re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
function _makeCompatibilityCheck(ownVersion) {
Expand Down
13 changes: 9 additions & 4 deletions opentelemetry/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ declare function isTimeInput(value: unknown): value is api.HrTime | number | Dat
*/
declare function addHrTimes(time1: api.HrTime, time2: api.HrTime): api.HrTime;

declare function hexToBinary(hexStr: string): Uint8Array;

interface ExportResult {
code: ExportResultCode;
error?: Error;
Expand Down Expand Up @@ -359,7 +361,10 @@ declare const otperformance: Performance;

/** Constants describing the SDK in use */
declare const SDK_INFO: {
[x: string]: string;
"telemetry.sdk.name": string;
"process.runtime.name": string;
"telemetry.sdk.language": "nodejs";
"telemetry.sdk.version": string;
};

declare function unrefTimer(timer: any): void;
Expand Down Expand Up @@ -592,19 +597,19 @@ declare class BindOnceFuture<R, This = unknown, T extends (this: This, ...args:
call(...args: Parameters<T>): Promise<R>;
}

declare const VERSION = "1.18.0";
declare const VERSION = "1.24.0";

interface Exporter<T> {
export(arg: T, resultCallback: (result: ExportResult) => void): void;
}
/**
* @internal
* Shared functionality used by Exporters while exporting data, including suppresion of Traces.
* Shared functionality used by Exporters while exporting data, including suppression of Traces.
*/
declare function _export<T>(exporter: Exporter<T>, arg: T): Promise<ExportResult>;

declare const internal: {
_export: typeof _export;
};

export { AlwaysOffSampler, AlwaysOnSampler, AnchoredClock, BindOnceFuture, Clock, CompositePropagator, CompositePropagatorConfig, DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, DEFAULT_ENVIRONMENT, DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT, ENVIRONMENT, ErrorHandler, ExportResult, ExportResultCode, IdGenerator, InstrumentationLibrary, InstrumentationScope, ParentBasedSampler, RAW_ENVIRONMENT, RPCMetadata, RPCType, RandomIdGenerator, SDK_INFO, ShimWrapped, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, TimeOriginLegacy, TimeoutError, TraceIdRatioBasedSampler, TraceState, TracesSamplerValues, VERSION, W3CBaggagePropagator, W3CTraceContextPropagator, _globalThis, addHrTimes, utils_d as baggageUtils, callWithTimeout, deleteRPCMetadata, getEnv, getEnvWithoutDefaults, getRPCMetadata, getTimeOrigin, globalErrorHandler, hexToBase64, hrTime, hrTimeDuration, hrTimeToMicroseconds, hrTimeToMilliseconds, hrTimeToNanoseconds, hrTimeToTimeStamp, internal, isAttributeKey, isAttributeValue, isTimeInput, isTimeInputHrTime, isTracingSuppressed, isUrlIgnored, isWrapped, loggingErrorHandler, merge, millisToHrTime, otperformance, parseEnvironment, parseTraceParent, sanitizeAttributes, setGlobalErrorHandler, setRPCMetadata, suppressTracing, timeInputToHrTime, unrefTimer, unsuppressTracing, urlMatches };
export { AlwaysOffSampler, AlwaysOnSampler, AnchoredClock, BindOnceFuture, Clock, CompositePropagator, CompositePropagatorConfig, DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, DEFAULT_ENVIRONMENT, DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT, ENVIRONMENT, ErrorHandler, ExportResult, ExportResultCode, IdGenerator, InstrumentationLibrary, InstrumentationScope, ParentBasedSampler, RAW_ENVIRONMENT, RPCMetadata, RPCType, RandomIdGenerator, SDK_INFO, ShimWrapped, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, TimeOriginLegacy, TimeoutError, TraceIdRatioBasedSampler, TraceState, TracesSamplerValues, VERSION, W3CBaggagePropagator, W3CTraceContextPropagator, _globalThis, addHrTimes, utils_d as baggageUtils, callWithTimeout, deleteRPCMetadata, getEnv, getEnvWithoutDefaults, getRPCMetadata, getTimeOrigin, globalErrorHandler, hexToBase64, hexToBinary, hrTime, hrTimeDuration, hrTimeToMicroseconds, hrTimeToMilliseconds, hrTimeToNanoseconds, hrTimeToTimeStamp, internal, isAttributeKey, isAttributeValue, isTimeInput, isTimeInputHrTime, isTracingSuppressed, isUrlIgnored, isWrapped, loggingErrorHandler, merge, millisToHrTime, otperformance, parseEnvironment, parseTraceParent, sanitizeAttributes, setGlobalErrorHandler, setRPCMetadata, suppressTracing, timeInputToHrTime, unrefTimer, unsuppressTracing, urlMatches };
38 changes: 24 additions & 14 deletions opentelemetry/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
/// <reference types="./core.d.ts" />

import { createContextKey, baggageEntryMetadataFromString, propagation, diag, DiagLogLevel, trace, isSpanContextValid, TraceFlags, SamplingDecision, isValidTraceId, context } from './api.js';

import { SemanticResourceAttributes, TelemetrySdkLanguageValues } from './semantic-conventions.js';

const SUPPRESS_TRACING_KEY = createContextKey('OpenTelemetry SDK Context Key SUPPRESS_TRACING');
Expand Down Expand Up @@ -482,22 +481,33 @@ function getEnvWithoutDefaults() {

function getEnv() {
const processEnv = parseEnvironment(Deno.env.toObject());
return Object.assign({
HOSTNAME: Deno.hostname?.(),
}, DEFAULT_ENVIRONMENT, processEnv);
return Object.assign({}, DEFAULT_ENVIRONMENT, processEnv);
}

const _globalThis = typeof globalThis === 'object' ? globalThis : global;

function hexToBase64(hexStr) {
const hexStrLen = hexStr.length;
let hexAsciiCharsStr = '';
for (let i = 0; i < hexStrLen; i += 2) {
const hexPair = hexStr.substring(i, i + 2);
const hexVal = parseInt(hexPair, 16);
hexAsciiCharsStr += String.fromCharCode(hexVal);
function intValue(charCode) {
if (charCode >= 48 && charCode <= 57) {
return charCode - 48;
}
if (charCode >= 97 && charCode <= 102) {
return charCode - 87;
}
return charCode - 55;
}
function hexToBinary(hexStr) {
const buf = new Uint8Array(hexStr.length / 2);
let offset = 0;
for (let i = 0; i < hexStr.length; i += 2) {
const hi = intValue(hexStr.charCodeAt(i));
const lo = intValue(hexStr.charCodeAt(i + 1));
buf[offset++] = (hi << 4) | lo;
}
return btoa(hexAsciiCharsStr);
return buf;
}

function hexToBase64(hexStr) {
return btoa(String.fromCharCode(...hexToBinary(hexStr)));
}

const SPAN_ID_BYTES = 8;
Expand All @@ -523,7 +533,7 @@ function getIdGenerator(bytes) {

const otperformance = performance;

const VERSION$1 = "1.18.0";
const VERSION$1 = "1.24.0";

const SDK_INFO = {
[SemanticResourceAttributes.TELEMETRY_SDK_NAME]: 'opentelemetry',
Expand Down Expand Up @@ -1204,4 +1214,4 @@ const internal = {
_export,
};

export { AlwaysOffSampler, AlwaysOnSampler, AnchoredClock, BindOnceFuture, CompositePropagator, DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, DEFAULT_ENVIRONMENT, DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT, ExportResultCode, ParentBasedSampler, RPCType, RandomIdGenerator, SDK_INFO, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, TimeoutError, TraceIdRatioBasedSampler, TraceState, TracesSamplerValues, VERSION$1 as VERSION, W3CBaggagePropagator, W3CTraceContextPropagator, _globalThis, addHrTimes, utils as baggageUtils, callWithTimeout, deleteRPCMetadata, getEnv, getEnvWithoutDefaults, getRPCMetadata, getTimeOrigin, globalErrorHandler, hexToBase64, hrTime, hrTimeDuration, hrTimeToMicroseconds, hrTimeToMilliseconds, hrTimeToNanoseconds, hrTimeToTimeStamp, internal, isAttributeKey, isAttributeValue, isTimeInput, isTimeInputHrTime, isTracingSuppressed, isUrlIgnored, isWrapped, loggingErrorHandler, merge, millisToHrTime, otperformance, parseEnvironment, parseTraceParent, sanitizeAttributes, setGlobalErrorHandler, setRPCMetadata, suppressTracing, timeInputToHrTime, unrefTimer, unsuppressTracing, urlMatches };
export { AlwaysOffSampler, AlwaysOnSampler, AnchoredClock, BindOnceFuture, CompositePropagator, DEFAULT_ATTRIBUTE_COUNT_LIMIT, DEFAULT_ATTRIBUTE_VALUE_LENGTH_LIMIT, DEFAULT_ENVIRONMENT, DEFAULT_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, DEFAULT_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT, ExportResultCode, ParentBasedSampler, RPCType, RandomIdGenerator, SDK_INFO, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, TimeoutError, TraceIdRatioBasedSampler, TraceState, TracesSamplerValues, VERSION$1 as VERSION, W3CBaggagePropagator, W3CTraceContextPropagator, _globalThis, addHrTimes, utils as baggageUtils, callWithTimeout, deleteRPCMetadata, getEnv, getEnvWithoutDefaults, getRPCMetadata, getTimeOrigin, globalErrorHandler, hexToBase64, hexToBinary, hrTime, hrTimeDuration, hrTimeToMicroseconds, hrTimeToMilliseconds, hrTimeToNanoseconds, hrTimeToTimeStamp, internal, isAttributeKey, isAttributeValue, isTimeInput, isTimeInputHrTime, isTracingSuppressed, isUrlIgnored, isWrapped, loggingErrorHandler, merge, millisToHrTime, otperformance, parseEnvironment, parseTraceParent, sanitizeAttributes, setGlobalErrorHandler, setRPCMetadata, suppressTracing, timeInputToHrTime, unrefTimer, unsuppressTracing, urlMatches };
5 changes: 4 additions & 1 deletion opentelemetry/exporter-metrics-otlp-http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/

import { OTLPExporterConfigBase, OTLPExporterBase } from './otlp-exporter-base.d.ts';
import { AggregationTemporality, AggregationTemporalitySelector, ResourceMetrics, PushMetricExporter, InstrumentType } from './sdk-metrics.d.ts';
import { AggregationTemporality, AggregationSelector, AggregationTemporalitySelector, ResourceMetrics, PushMetricExporter, InstrumentType, Aggregation } from './sdk-metrics.d.ts';
import { ExportResult } from './core.d.ts';
import { IExportMetricsServiceRequest } from './otlp-transformer.d.ts';

interface OTLPMetricExporterOptions extends OTLPExporterConfigBase {
temporalityPreference?: AggregationTemporalityPreference | AggregationTemporality;
aggregationPreference?: AggregationSelector;
}
declare enum AggregationTemporalityPreference {
DELTA = 0,
Expand All @@ -34,10 +35,12 @@ declare const LowMemoryTemporalitySelector: AggregationTemporalitySelector;
declare class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions, ResourceMetrics, IExportMetricsServiceRequest>> implements PushMetricExporter {
_otlpExporter: T;
private _aggregationTemporalitySelector;
private _aggregationSelector;
constructor(exporter: T, config?: OTLPMetricExporterOptions);
export(metrics: ResourceMetrics, resultCallback: (result: ExportResult) => void): void;
shutdown(): Promise<void>;
forceFlush(): Promise<void>;
selectAggregation(instrumentType: InstrumentType): Aggregation;
selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
}

Expand Down
Loading
Loading