From cf036f60b3c05a02d0f8d3f41f838e8d5d0564e5 Mon Sep 17 00:00:00 2001 From: Archish Date: Fri, 18 Sep 2026 14:41:50 +0530 Subject: [PATCH 1/3] chore: :art: updated attributes to latest as per otel --- .../MiddlewareReactNativeModule.java | 18 +++++++++++++++++- package.json | 2 +- src/middlewareRum.ts | 11 +++++++++-- tsconfig.build.json | 12 +++++++++++- tsconfig.json | 1 + 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java index 6a9930a..1536596 100644 --- a/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java +++ b/android/src/main/java/com/middlewarereactnative/MiddlewareReactNativeModule.java @@ -21,10 +21,14 @@ import com.facebook.react.module.annotations.ReactModule; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Set; import io.middleware.android.sdk.Middleware; import io.middleware.android.sdk.builders.MiddlewareBuilder; @@ -47,6 +51,18 @@ @ReactModule(name = MiddlewareReactNativeModule.NAME) public class MiddlewareReactNativeModule extends ReactContextBaseJavaModule { public static final String NAME = "MiddlewareReactNative"; + /** + * Numeric attributes that semantic conventions define as integers. JS has no + * integer type, so every number crossing the bridge would otherwise be + * exported as a double (a status of 200 arriving as 200.0). The JS + * instrumentation sends the current HTTP names; http.status_code stays for + * any JS bundle still on the deprecated ones. + */ + private static final Set INTEGER_ATTRIBUTE_KEYS = + Collections.unmodifiableSet( + new HashSet<>( + Arrays.asList( + "http.response.status_code", "server.port", "http.status_code"))); private final long moduleStartTime; private MiddlewareSpanExporter middlewareSpanExporter; private String nativeSessionId; @@ -439,7 +455,7 @@ private Attributes attributesFromMap(@Nullable ReadableMap attributeMap) { if (value instanceof String) { builder.put(entry.getKey(), (String) value); } else if (value instanceof Number) { - if ("http.status_code".equals(entry.getKey())) { + if (INTEGER_ATTRIBUTE_KEYS.contains(entry.getKey())) { builder.put(entry.getKey(), ((Number) value).intValue()); } else { builder.put(entry.getKey(), ((Number) value).doubleValue()); diff --git a/package.json b/package.json index 96bb6fd..7fda164 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@middleware.io/middleware-react-native", - "version": "2.1.7", + "version": "2.1.8", "description": "Middleware React Native real user monitoring SDK", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/src/middlewareRum.ts b/src/middlewareRum.ts index 3bbd461..dd6a9af 100644 --- a/src/middlewareRum.ts +++ b/src/middlewareRum.ts @@ -388,6 +388,11 @@ export const MiddlewareRum: MiddlewareRumType = { // request made with XMLHttpRequest. Since in this demo calls to /api/ are made using fetch, turn off // instrumentation for that path to avoid the extra spans. const xhrInstrumentation = new XMLHttpRequestInstrumentation({ + // Emit the current HTTP semantic conventions (url.full, + // http.request.method, http.response.status_code, server.address) instead + // of the deprecated http.url / http.method / http.status_code the + // instrumentation defaults to. 'http' sends the new names only. + semconvStabilityOptIn: 'http', propagateTraceHeaderCorsUrls: tracePropagationTargets, clearTimingResources: false, ignoreUrls: DEFAULT_IGNORE_URLS, @@ -458,7 +463,7 @@ export const MiddlewareRum: MiddlewareRumType = { } }); const httpURL = (span as unknown as { attributes: Attributes }) - ?.attributes?.['http.url']; + ?.attributes?.['url.full']; if (httpURL) { span.updateName( `${(span as unknown as { name: string }).name} ${httpURL}` @@ -469,6 +474,8 @@ export const MiddlewareRum: MiddlewareRumType = { }, }); const fetchInstrumentation = new FetchInstrumentation({ + // Same as XHR above: current HTTP semantic conventions only. + semconvStabilityOptIn: 'http', propagateTraceHeaderCorsUrls: tracePropagationTargets, clearTimingResources: false, ignoreUrls: DEFAULT_IGNORE_URLS, @@ -482,7 +489,7 @@ export const MiddlewareRum: MiddlewareRumType = { const span = s as Span; const httpURL = ( s as { span: Span; attributes: Attributes; name: string } - ).attributes?.['http.url']; + ).attributes?.['url.full']; if (httpURL) { span.updateName( `${ diff --git a/tsconfig.build.json b/tsconfig.build.json index 2a21c28..d4ea858 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,14 @@ { "extends": "./tsconfig", - "exclude": ["example"] + // `exclude` replaces the base rather than adding to it, so the base entries + // are repeated here. Tests are excluded so the published package carries no + // declarations for them: those are what collided with the sources. + "exclude": [ + "node_modules", + "lib", + "example", + "**/__tests__/**", + "**/*.test.ts", + "**/*.test.tsx" + ] } diff --git a/tsconfig.json b/tsconfig.json index 416501f..5a30f86 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,5 @@ { + "exclude": ["node_modules", "lib", "example/node_modules"], "compilerOptions": { "rootDir": ".", "paths": { From ed11d0f76d4dc33a7aacce6006cd99fa7e713fbf Mon Sep 17 00:00:00 2001 From: Archish Date: Fri, 18 Sep 2026 14:50:31 +0530 Subject: [PATCH 2/3] chore: :art: updated android ios packages --- android/build.gradle | 2 +- middleware-react-native.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index d5c99c8..cb9ceaf 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -83,7 +83,7 @@ dependencies { //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // Stable native SDK (main branch). 3.1.0 adds startRecording/stopRecording/isRecording. - implementation 'io.github.middleware-labs:android-sdk:3.1.4' + implementation 'io.github.middleware-labs:android-sdk:3.1.5' coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4" // Compile-visible OTel for the JS-span reconstruction (SpanData etc.); // runtime classes come transitively from android-sdk. Keep aligned with diff --git a/middleware-react-native.podspec b/middleware-react-native.podspec index da3a929..2955563 100644 --- a/middleware-react-native.podspec +++ b/middleware-react-native.podspec @@ -18,7 +18,7 @@ Pod::Spec.new do |s| # Stable native SDK (2.1+ adds setNativeSession + exportRawSpans); brings # PLCrashReporter/DeviceKit/SwiftProtobuf/SWCompression/Reachability transitively. - s.dependency "MiddlewareRum", "~> 2.2.3" + s.dependency "MiddlewareRum", "~> 2.2.4" # React dependencies. `install_modules_dependencies` (react_native_pods.rb, # RN >= 0.71) wires the right pods for whichever architecture the host app From 247868cedaad5faacf27a5169eb92006c3d5cd5b Mon Sep 17 00:00:00 2001 From: Archish Date: Fri, 18 Sep 2026 16:21:56 +0530 Subject: [PATCH 3/3] chore: updated pod.lock --- example/ios/Podfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 5e56859..3ba7948 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -13,12 +13,12 @@ PODS: - ReactCommon/turbomodule/core (= 0.73.1) - fmt (6.2.1) - glog (0.3.5) - - middleware-react-native (2.1.7): + - middleware-react-native (2.1.8): - glog - - MiddlewareRum (~> 2.2.3) + - MiddlewareRum (~> 2.2.4) - RCT-Folly (= 2022.05.16.00) - React-Core - - MiddlewareRum (2.2.3): + - MiddlewareRum (2.2.4): - DeviceKit (~> 5.4) - PLCrashReporter (~> 1.11) - Reachability (~> 3.7) @@ -1266,8 +1266,8 @@ SPEC CHECKSUMS: FBReactNativeSpec: df0ebe69acd14ce0be0269cf75b6e338a727259b fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 - middleware-react-native: 61652c9f2561c75b2ef318a73d8786a4db3b4209 - MiddlewareRum: 4d487f4e9978ee36a77a6d8983d83c7174a05fd2 + middleware-react-native: 4304cf58832da37c54ad9616b494c27b36d604f2 + MiddlewareRum: a03dcfabaefd8dfd5aaa022227fe1ced442c44c5 PLCrashReporter: db59ef96fa3d25f3650040d02ec2798cffee75f2 RCT-Folly: cd21f1661364f975ae76b3308167ad66b09f53f5 RCTRequired: 6dda55e483f75d2b43781d8ad5bd7df276a50981