@glasstrace/sdk 1.0.1 → 1.1.0

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/dist/cli/init.cjs CHANGED
@@ -18492,7 +18492,7 @@ async function verifyAnonKeyRegistration(projectRoot) {
18492
18492
  }
18493
18493
  const baseConfig = resolveConfig({ apiKey: devKey });
18494
18494
  const config2 = { ...baseConfig, apiKey: devKey };
18495
- const sdkVersion = true ? "1.0.1" : "0.0.0-dev";
18495
+ const sdkVersion = true ? "1.1.0" : "0.0.0-dev";
18496
18496
  const result = await verifyInitReachable(config2, anonKey, sdkVersion);
18497
18497
  if (result.ok) {
18498
18498
  return { outcome: "verified" };
package/dist/cli/init.js CHANGED
@@ -610,7 +610,7 @@ async function verifyAnonKeyRegistration(projectRoot) {
610
610
  }
611
611
  const baseConfig = resolveConfig({ apiKey: devKey });
612
612
  const config = { ...baseConfig, apiKey: devKey };
613
- const sdkVersion = true ? "1.0.1" : "0.0.0-dev";
613
+ const sdkVersion = true ? "1.1.0" : "0.0.0-dev";
614
614
  const result = await verifyInitReachable(config, anonKey, sdkVersion);
615
615
  if (result.ok) {
616
616
  return { outcome: "verified" };
package/dist/index.cjs CHANGED
@@ -18532,7 +18532,7 @@ function getStringFromEnv(key) {
18532
18532
  }
18533
18533
 
18534
18534
  // ../../node_modules/@opentelemetry/core/build/esm/version.js
18535
- var VERSION2 = "2.6.1";
18535
+ var VERSION2 = "2.7.0";
18536
18536
 
18537
18537
  // ../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js
18538
18538
  var ATTR_EXCEPTION_MESSAGE = "exception.message";
@@ -18696,6 +18696,9 @@ function mergeTwoObjects(one, two, level = 0, objects) {
18696
18696
  const keys = Object.keys(two);
18697
18697
  for (let i = 0, j = keys.length; i < j; i++) {
18698
18698
  const key = keys[i];
18699
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
18700
+ continue;
18701
+ }
18699
18702
  result[key] = takeValue(two[key]);
18700
18703
  }
18701
18704
  }
@@ -18708,6 +18711,9 @@ function mergeTwoObjects(one, two, level = 0, objects) {
18708
18711
  const keys = Object.keys(two);
18709
18712
  for (let i = 0, j = keys.length; i < j; i++) {
18710
18713
  const key = keys[i];
18714
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
18715
+ continue;
18716
+ }
18711
18717
  const twoValue = two[key];
18712
18718
  if (isPrimitive(twoValue)) {
18713
18719
  if (typeof twoValue === "undefined") {
@@ -18919,95 +18925,6 @@ function createOtlpExportDelegate(components, settings) {
18919
18925
  return new OTLPExportDelegate(components.transport, components.serializer, createLoggingPartialSuccessResponseHandler(), components.promiseHandler, settings.timeout);
18920
18926
  }
18921
18927
 
18922
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
18923
- function createResource(resource, encoder) {
18924
- const result = {
18925
- attributes: toAttributes(resource.attributes, encoder),
18926
- droppedAttributesCount: 0
18927
- };
18928
- const schemaUrl = resource.schemaUrl;
18929
- if (schemaUrl && schemaUrl !== "")
18930
- result.schemaUrl = schemaUrl;
18931
- return result;
18932
- }
18933
- function createInstrumentationScope(scope) {
18934
- return {
18935
- name: scope.name,
18936
- version: scope.version
18937
- };
18938
- }
18939
- function toAttributes(attributes, encoder) {
18940
- return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key], encoder));
18941
- }
18942
- function toKeyValue(key, value, encoder) {
18943
- return {
18944
- key,
18945
- value: toAnyValue(value, encoder)
18946
- };
18947
- }
18948
- function toAnyValue(value, encoder) {
18949
- const t = typeof value;
18950
- if (t === "string")
18951
- return { stringValue: value };
18952
- if (t === "number") {
18953
- if (!Number.isInteger(value))
18954
- return { doubleValue: value };
18955
- return { intValue: value };
18956
- }
18957
- if (t === "boolean")
18958
- return { boolValue: value };
18959
- if (value instanceof Uint8Array)
18960
- return { bytesValue: encoder.encodeUint8Array(value) };
18961
- if (Array.isArray(value)) {
18962
- const values = new Array(value.length);
18963
- for (let i = 0; i < value.length; i++) {
18964
- values[i] = toAnyValue(value[i], encoder);
18965
- }
18966
- return { arrayValue: { values } };
18967
- }
18968
- if (t === "object" && value != null) {
18969
- const keys = Object.keys(value);
18970
- const values = new Array(keys.length);
18971
- for (let i = 0; i < keys.length; i++) {
18972
- values[i] = {
18973
- key: keys[i],
18974
- value: toAnyValue(value[keys[i]], encoder)
18975
- };
18976
- }
18977
- return { kvlistValue: { values } };
18978
- }
18979
- return {};
18980
- }
18981
-
18982
- // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
18983
- function hrTimeToNanos(hrTime2) {
18984
- const NANOSECONDS = BigInt(1e9);
18985
- return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
18986
- }
18987
- function encodeAsString(hrTime2) {
18988
- const nanos = hrTimeToNanos(hrTime2);
18989
- return nanos.toString();
18990
- }
18991
- var encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds;
18992
- function identity(value) {
18993
- return value;
18994
- }
18995
- var JSON_ENCODER = {
18996
- encodeHrTime: encodeTimestamp,
18997
- encodeSpanContext: identity,
18998
- encodeOptionalSpanContext: identity,
18999
- encodeUint8Array: (bytes) => {
19000
- if (typeof Buffer !== "undefined") {
19001
- return Buffer.from(bytes).toString("base64");
19002
- }
19003
- const chars = new Array(bytes.length);
19004
- for (let i = 0; i < bytes.length; i++) {
19005
- chars[i] = String.fromCharCode(bytes[i]);
19006
- }
19007
- return btoa(chars.join(""));
19008
- }
19009
- };
19010
-
19011
18928
  // ../../node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js
19012
18929
  init_esm();
19013
18930
 
@@ -19152,6 +19069,95 @@ function mergeSchemaUrl(old, updating) {
19152
19069
  return void 0;
19153
19070
  }
19154
19071
 
19072
+ // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/internal.js
19073
+ function createResource(resource, encoder) {
19074
+ const result = {
19075
+ attributes: toAttributes(resource.attributes, encoder),
19076
+ droppedAttributesCount: 0
19077
+ };
19078
+ const schemaUrl = resource.schemaUrl;
19079
+ if (schemaUrl && schemaUrl !== "")
19080
+ result.schemaUrl = schemaUrl;
19081
+ return result;
19082
+ }
19083
+ function createInstrumentationScope(scope) {
19084
+ return {
19085
+ name: scope.name,
19086
+ version: scope.version
19087
+ };
19088
+ }
19089
+ function toAttributes(attributes, encoder) {
19090
+ return Object.keys(attributes).map((key) => toKeyValue(key, attributes[key], encoder));
19091
+ }
19092
+ function toKeyValue(key, value, encoder) {
19093
+ return {
19094
+ key,
19095
+ value: toAnyValue(value, encoder)
19096
+ };
19097
+ }
19098
+ function toAnyValue(value, encoder) {
19099
+ const t = typeof value;
19100
+ if (t === "string")
19101
+ return { stringValue: value };
19102
+ if (t === "number") {
19103
+ if (!Number.isInteger(value))
19104
+ return { doubleValue: value };
19105
+ return { intValue: value };
19106
+ }
19107
+ if (t === "boolean")
19108
+ return { boolValue: value };
19109
+ if (value instanceof Uint8Array)
19110
+ return { bytesValue: encoder.encodeUint8Array(value) };
19111
+ if (Array.isArray(value)) {
19112
+ const values = new Array(value.length);
19113
+ for (let i = 0; i < value.length; i++) {
19114
+ values[i] = toAnyValue(value[i], encoder);
19115
+ }
19116
+ return { arrayValue: { values } };
19117
+ }
19118
+ if (t === "object" && value != null) {
19119
+ const keys = Object.keys(value);
19120
+ const values = new Array(keys.length);
19121
+ for (let i = 0; i < keys.length; i++) {
19122
+ values[i] = {
19123
+ key: keys[i],
19124
+ value: toAnyValue(value[keys[i]], encoder)
19125
+ };
19126
+ }
19127
+ return { kvlistValue: { values } };
19128
+ }
19129
+ return {};
19130
+ }
19131
+
19132
+ // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/common/utils.js
19133
+ function hrTimeToNanos(hrTime2) {
19134
+ const NANOSECONDS = BigInt(1e9);
19135
+ return BigInt(Math.trunc(hrTime2[0])) * NANOSECONDS + BigInt(Math.trunc(hrTime2[1]));
19136
+ }
19137
+ function encodeAsString(hrTime2) {
19138
+ const nanos = hrTimeToNanos(hrTime2);
19139
+ return nanos.toString();
19140
+ }
19141
+ var encodeTimestamp = typeof BigInt !== "undefined" ? encodeAsString : hrTimeToNanoseconds;
19142
+ function identity(value) {
19143
+ return value;
19144
+ }
19145
+ var JSON_ENCODER = {
19146
+ encodeHrTime: encodeTimestamp,
19147
+ encodeSpanContext: identity,
19148
+ encodeOptionalSpanContext: identity,
19149
+ encodeUint8Array: (bytes) => {
19150
+ if (typeof Buffer !== "undefined") {
19151
+ return Buffer.from(bytes).toString("base64");
19152
+ }
19153
+ const chars = new Array(bytes.length);
19154
+ for (let i = 0; i < bytes.length; i++) {
19155
+ chars[i] = String.fromCharCode(bytes[i]);
19156
+ }
19157
+ return btoa(chars.join(""));
19158
+ }
19159
+ };
19160
+
19155
19161
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/internal.js
19156
19162
  var SPAN_FLAGS_CONTEXT_HAS_IS_REMOTE_MASK = 256;
19157
19163
  var SPAN_FLAGS_CONTEXT_IS_REMOTE_MASK = 512;
@@ -19266,6 +19272,7 @@ function spanRecordsToResourceSpans(readableSpans, encoder) {
19266
19272
  }
19267
19273
 
19268
19274
  // ../../node_modules/@opentelemetry/otlp-transformer/build/esm/trace/json/trace.js
19275
+ init_esm();
19269
19276
  var JsonTraceSerializer = {
19270
19277
  serializeRequest: (arg) => {
19271
19278
  const request = createExportTraceServiceRequest(arg, JSON_ENCODER);
@@ -19277,7 +19284,12 @@ var JsonTraceSerializer = {
19277
19284
  return {};
19278
19285
  }
19279
19286
  const decoder = new TextDecoder();
19280
- return JSON.parse(decoder.decode(arg));
19287
+ try {
19288
+ return JSON.parse(decoder.decode(arg));
19289
+ } catch (err) {
19290
+ diag2.warn(`Failed to parse trace export response: ${err.message}. Returning empty response`);
19291
+ return {};
19292
+ }
19281
19293
  }
19282
19294
  };
19283
19295
 
@@ -19388,10 +19400,11 @@ function parseRetryAfterToMills(retryAfter) {
19388
19400
  }
19389
19401
 
19390
19402
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/version.js
19391
- var VERSION3 = "0.214.0";
19403
+ var VERSION3 = "0.215.0";
19392
19404
 
19393
19405
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
19394
19406
  var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION3}`;
19407
+ var MAX_RESPONSE_BODY_SIZE = 4 * 1024 * 1024;
19395
19408
  function sendWithHttp(request, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
19396
19409
  return new Promise((resolve3) => {
19397
19410
  const parsedUrl = new URL(url2);
@@ -19410,7 +19423,17 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
19410
19423
  };
19411
19424
  const req = request(options, (res) => {
19412
19425
  const responseData = [];
19413
- res.on("data", (chunk) => responseData.push(chunk));
19426
+ let responseSize = 0;
19427
+ res.on("data", (chunk) => {
19428
+ responseSize += chunk.length;
19429
+ if (responseSize > MAX_RESPONSE_BODY_SIZE) {
19430
+ const sizeError = new Error(`OTLP export response body exceeded size limit of ${MAX_RESPONSE_BODY_SIZE} bytes`);
19431
+ resolve3({ status: "failure", error: sizeError });
19432
+ res.destroy();
19433
+ return;
19434
+ }
19435
+ responseData.push(chunk);
19436
+ });
19414
19437
  res.on("end", () => {
19415
19438
  if (res.statusCode && res.statusCode <= 299) {
19416
19439
  resolve3({
@@ -20613,7 +20636,7 @@ function samplingDecisionToString(decision) {
20613
20636
  }
20614
20637
 
20615
20638
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/version.js
20616
- var VERSION4 = "2.6.1";
20639
+ var VERSION4 = "2.7.0";
20617
20640
 
20618
20641
  // ../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Tracer.js
20619
20642
  var Tracer = class {
@@ -21380,24 +21403,24 @@ function detectSentry() {
21380
21403
  }
21381
21404
 
21382
21405
  // src/otel-config.ts
21383
- var _resolvedApiKey = API_KEY_PENDING;
21384
- var _activeExporter = null;
21385
- var _additionalExporters = [];
21386
- var _injectedProcessor = null;
21406
+ var resolvedApiKey = API_KEY_PENDING;
21407
+ var activeExporter = null;
21408
+ var additionalExporters = [];
21409
+ var injectedProcessor = null;
21387
21410
  function setResolvedApiKey(key) {
21388
- _resolvedApiKey = key;
21411
+ resolvedApiKey = key;
21389
21412
  }
21390
21413
  function getResolvedApiKey() {
21391
- return _resolvedApiKey;
21414
+ return resolvedApiKey;
21392
21415
  }
21393
21416
  function notifyApiKeyResolved() {
21394
- _activeExporter?.notifyKeyResolved();
21395
- for (const exporter of _additionalExporters) {
21417
+ activeExporter?.notifyKeyResolved();
21418
+ for (const exporter of additionalExporters) {
21396
21419
  exporter.notifyKeyResolved();
21397
21420
  }
21398
21421
  }
21399
21422
  function registerExporterForKeyNotification(exporter) {
21400
- _additionalExporters.push(exporter);
21423
+ additionalExporters.push(exporter);
21401
21424
  }
21402
21425
  async function tryImport(moduleId) {
21403
21426
  try {
@@ -21440,7 +21463,7 @@ async function runCoexistencePath(existingProvider, config2) {
21440
21463
  return;
21441
21464
  }
21442
21465
  if (result !== null) {
21443
- _injectedProcessor = result.processor;
21466
+ injectedProcessor = result.processor;
21444
21467
  if (config2.verbose) {
21445
21468
  sdkLog(
21446
21469
  "info",
@@ -21451,8 +21474,8 @@ async function runCoexistencePath(existingProvider, config2) {
21451
21474
  name: "coexistence-flush",
21452
21475
  priority: 5,
21453
21476
  fn: async () => {
21454
- if (_injectedProcessor) {
21455
- await _injectedProcessor.forceFlush();
21477
+ if (injectedProcessor) {
21478
+ await injectedProcessor.forceFlush();
21456
21479
  }
21457
21480
  }
21458
21481
  });
@@ -21488,7 +21511,7 @@ async function runRegistrationPath(config2, sessionManager) {
21488
21511
  createDelegate: createOtlpExporter,
21489
21512
  verbose: config2.verbose
21490
21513
  });
21491
- _activeExporter = glasstraceExporter;
21514
+ activeExporter = glasstraceExporter;
21492
21515
  const vercelOtel = await tryImport("@vercel/otel");
21493
21516
  if (vercelOtel && typeof vercelOtel.registerOTel === "function") {
21494
21517
  const otelConfig = {
@@ -21821,7 +21844,7 @@ function registerGlasstrace(options) {
21821
21844
  setCoreState(CoreState.REGISTERING);
21822
21845
  startRuntimeStateWriter({
21823
21846
  projectRoot: process.cwd(),
21824
- sdkVersion: "1.0.1"
21847
+ sdkVersion: "1.1.0"
21825
21848
  });
21826
21849
  const config2 = resolveConfig(options);
21827
21850
  if (config2.verbose) {
@@ -21987,8 +22010,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
21987
22010
  if (config2.verbose) {
21988
22011
  console.info("[glasstrace] Background init firing.");
21989
22012
  }
21990
- const healthReport = collectHealthReport("1.0.1");
21991
- const initResult = await performInit(config2, anonKeyForInit, "1.0.1", healthReport);
22013
+ const healthReport = collectHealthReport("1.1.0");
22014
+ const initResult = await performInit(config2, anonKeyForInit, "1.1.0", healthReport);
21992
22015
  if (generation !== registrationGeneration) return;
21993
22016
  const currentState = getCoreState();
21994
22017
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22011,7 +22034,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22011
22034
  }
22012
22035
  maybeInstallConsoleCapture();
22013
22036
  if (didLastInitSucceed()) {
22014
- startHeartbeat(config2, anonKeyForInit, "1.0.1", generation, (newApiKey, accountId) => {
22037
+ startHeartbeat(config2, anonKeyForInit, "1.1.0", generation, (newApiKey, accountId) => {
22015
22038
  setAuthState(AuthState.CLAIMING);
22016
22039
  emitLifecycleEvent("auth:claim_started", { accountId });
22017
22040
  setResolvedApiKey(newApiKey);