npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sendlab/otel-react-native

v0.5.1

Published

HyperDX distribution of Open Telemetry for react native.

Downloads

7

Readme

HyperDX Distribution of OpenTelemetry for React Native

:construction: This project is currently Experimental. Do not use it in production environments.

Overview

This library lets you autoinstrument React Native applications. Minimum supported React Native version is 0.68. To instrument applications running on React Native versions lower than 0.68, see Instrument lower versions.

Get started

To instrument your React Native application, follow these steps.

  1. Install the library using either npm or yarn:
# npm
npm install @hyperdx/otel-react-native

# yarn
yarn add @hyperdx/otel-react-native
  1. Initialize the library as early in your app lifecycle as possible:
import { HyperDXRum } from '@hyperdx/otel-react-native';

HyperDXRum.init({
  service: 'my-rn-app',
  apiKey: '<YOUR_API_KEY_HERE>',
  tracePropagationTargets: [/api.myapp.domain/i], // Set to link traces from frontend to backend requests
  networkHeadersCapture: false,
});
  1. Customize the initialization parameters to specify:
  • apiKey: Your HyperDX Ingestion API key. You can find it here.
  • service: Name of your application. Set it to distinguish your app from others in HyperDX.
  • tracePropagationTargets: A list of regular expressions that match the URLs of your backend services. Set it to link traces from frontend to backend requests.
  • networkHeadersCapture: networkHeadersCapture is a flag that allows the option to capture header information, with the default flag being false.

(Optional) Attach User Information or Metadata

Attaching user information will allow you to search/filter sessions and events in HyperDX. This can be called at any point during the client session. The current client session and all events sent after the call will be associated with the user information.

userEmail, userName, and teamName will populate the sessions UI with the corresponding values, but can be omitted. Any other additional values can be specified and used to search for events.

HyperDXRum.setGlobalAttributes({
  userEmail: user.email,
  userName: user.name,
  teamName: user.team.name,
  // Other custom properties...
});

Instrument lower versions

To instrument applications running on React Native versions lower than 0.68, edit your metro.config.js file to force metro to use browser specific packages. For example:

const defaultResolver = require('metro-resolver');

module.exports = {
  resolver: {
    resolveRequest: (context, realModuleName, platform, moduleName) => {
      const resolved = defaultResolver.resolve(
        {
          ...context,
          resolveRequest: null,
        },
        moduleName,
        platform
      );

      if (
        resolved.type === 'sourceFile' &&
        resolved.filePath.includes('@opentelemetry')
      ) {
        resolved.filePath = resolved.filePath.replace(
          'platform\\node',
          'platform\\browser'
        );
        return resolved;
      }

      return resolved;
    },
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

View navigation

react-navigation version 5 and 6 are supported.

The following example shows how to instrument navigation:

import { startNavigationTracking } from '@hyperdx/otel-react-native';

export default function App() {
  const navigationRef = useNavigationContainerRef();
  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={() => {
        startNavigationTracking(navigationRef);
      }}
    >
      <Stack.Navigator>...</Stack.Navigator>
    </NavigationContainer>
  );
}

Data collection

The library exports data using the Zipkin exporter. Adding your own exporters and processors isn't supported yet.

Supported features:

  • Autoinstrumented HTTP requests
  • Autoinstrumented JS Error tracking
  • Autoinstrumented navigation tracking for react-navigation
  • Session tracking
  • Custom instrumentation using Opentelemetry
  • Capturing native crashes

For more information about how this library uses Opentelemetry and about future plans check CONTRIBUTING.md.

License

https://github.com/signalfx/splunk-otel-react-native#license