@glasstrace/sdk 1.3.4 → 1.3.5

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/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  registerGlasstrace,
13
13
  waitForReady,
14
14
  withGlasstraceConfig
15
- } from "./chunk-XFNK4YEW.js";
15
+ } from "./chunk-EK6MYHR2.js";
16
16
  import {
17
17
  GlasstraceSpanProcessor,
18
18
  SdkError,
@@ -22164,6 +22164,27 @@ function detectSentry() {
22164
22164
  }
22165
22165
  }
22166
22166
 
22167
+ // src/proxy-detection.ts
22168
+ function isProxyTracerProvider(value) {
22169
+ if (value === null || value === void 0 || typeof value !== "object") {
22170
+ return false;
22171
+ }
22172
+ return "getTracer" in value && typeof value.getTracer === "function" && "getDelegate" in value && typeof value.getDelegate === "function" && "setDelegate" in value && typeof value.setDelegate === "function" && "getDelegateTracer" in value && typeof value.getDelegateTracer === "function";
22173
+ }
22174
+ function isProxyTracer(value, ownerProvider) {
22175
+ if (value === null || value === void 0 || typeof value !== "object") {
22176
+ return false;
22177
+ }
22178
+ const structurallyShaped = "_getTracer" in value && typeof value._getTracer === "function" && "startSpan" in value && typeof value.startSpan === "function" && "startActiveSpan" in value && typeof value.startActiveSpan === "function";
22179
+ if (!structurallyShaped) {
22180
+ return false;
22181
+ }
22182
+ if (!Object.hasOwn(value, "_provider")) {
22183
+ return false;
22184
+ }
22185
+ return value._provider === ownerProvider;
22186
+ }
22187
+
22167
22188
  // src/otel-config.ts
22168
22189
  var resolvedApiKey = API_KEY_PENDING;
22169
22190
  var activeExporter = null;
@@ -22202,7 +22223,7 @@ async function configureOtel(config2, sessionManager) {
22202
22223
  });
22203
22224
  const existingProvider = trace.getTracerProvider();
22204
22225
  const probeTracer = existingProvider.getTracer("glasstrace-probe");
22205
- const anotherProviderRegistered = probeTracer.constructor.name !== "ProxyTracer";
22226
+ const anotherProviderRegistered = !isProxyTracerProvider(existingProvider) || !isProxyTracer(probeTracer, existingProvider);
22206
22227
  if (anotherProviderRegistered) {
22207
22228
  setCoexistenceState("coexisting");
22208
22229
  await runCoexistencePath(existingProvider, config2);
@@ -22680,7 +22701,7 @@ function registerGlasstrace(options) {
22680
22701
  setCoreState(CoreState.REGISTERING);
22681
22702
  startRuntimeStateWriter({
22682
22703
  projectRoot: process.cwd(),
22683
- sdkVersion: "1.3.4"
22704
+ sdkVersion: "1.3.5"
22684
22705
  });
22685
22706
  const config2 = resolveConfig(options);
22686
22707
  if (config2.verbose) {
@@ -22696,8 +22717,9 @@ function registerGlasstrace(options) {
22696
22717
  if (config2.verbose) {
22697
22718
  console.info("[glasstrace] Not production-disabled.");
22698
22719
  }
22699
- const existingProbe = trace.getTracerProvider().getTracer("glasstrace-probe");
22700
- const anotherProviderRegistered = existingProbe.constructor.name !== "ProxyTracer";
22720
+ const existingTracerProvider = trace.getTracerProvider();
22721
+ const existingProbe = existingTracerProvider.getTracer("glasstrace-probe");
22722
+ const anotherProviderRegistered = !isProxyTracerProvider(existingTracerProvider) || !isProxyTracer(existingProbe, existingTracerProvider);
22701
22723
  if (anotherProviderRegistered) {
22702
22724
  setCoexistenceState("coexisting");
22703
22725
  }
@@ -22846,8 +22868,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22846
22868
  if (config2.verbose) {
22847
22869
  console.info("[glasstrace] Background init firing.");
22848
22870
  }
22849
- const healthReport = collectHealthReport("1.3.4");
22850
- const initResult = await performInit(config2, anonKeyForInit, "1.3.4", healthReport);
22871
+ const healthReport = collectHealthReport("1.3.5");
22872
+ const initResult = await performInit(config2, anonKeyForInit, "1.3.5", healthReport);
22851
22873
  if (generation !== registrationGeneration) return;
22852
22874
  const currentState = getCoreState();
22853
22875
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22870,7 +22892,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22870
22892
  }
22871
22893
  maybeInstallConsoleCapture();
22872
22894
  if (didLastInitSucceed()) {
22873
- startHeartbeat(config2, anonKeyForInit, "1.3.4", generation, (newApiKey, accountId) => {
22895
+ startHeartbeat(config2, anonKeyForInit, "1.3.5", generation, (newApiKey, accountId) => {
22874
22896
  setAuthState(AuthState.CLAIMING);
22875
22897
  emitLifecycleEvent("auth:claim_started", { accountId });
22876
22898
  setResolvedApiKey(newApiKey);