Skip to content
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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> 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;
Expand Down Expand Up @@ -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());
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion middleware-react-native.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 9 additions & 2 deletions src/middlewareRum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}`
Expand All @@ -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,
Expand All @@ -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(
`${
Expand Down
12 changes: 11 additions & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"exclude": ["node_modules", "lib", "example/node_modules"],
"compilerOptions": {
"rootDir": ".",
"paths": {
Expand Down
Loading