Opbeat HTTP Client

1.2.2 · abandoned · verified Wed Apr 22

The `opbeat-http-client` is a low-level HTTP client designed specifically for interacting with the Opbeat intake API, intended for developers building higher-level Opbeat integration modules rather than direct application usage. Its last published version is 1.2.2, which was released before Opbeat's acquisition by Elastic in June 2017. Following the acquisition, the standalone Opbeat service was transitioned into Elastic APM, and related Opbeat agents (like `opbeat-node`) were deprecated in favor of Elastic APM agents. Consequently, this client is no longer maintained and its target API is obsolete. It primarily differentiates itself by being a minimal, focused client for a specific (now defunct) APM service, in contrast to general-purpose HTTP clients like Axios or Node's built-in `http` module.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing the Opbeat HTTP client with required credentials and making a request to the 'errors' endpoint. This example highlights that the underlying Opbeat service is deprecated.

const opbeatHttpClientFactory = require('opbeat-http-client');

// NOTE: The Opbeat service is deprecated. This code will likely fail
// as the intake API endpoints are no longer active.
// Replace with your actual (historical) Opbeat credentials if attempting to run.
const client = opbeatHttpClientFactory({
  appId: process.env.OPBEAT_APP_ID ?? 'your-app-id',
  organizationId: process.env.OPBEAT_ORG_ID ?? 'your-organization-id',
  secretToken: process.env.OPBEAT_SECRET_TOKEN ?? 'your-secret-token',
  userAgent: 'my-custom-module/1.0.0'
});

const errorBody = {
  message: 'Simulated error from opbeat-http-client',
  culprit: 'example.js',
  timestamp: new Date().toISOString()
};

client.request('errors', errorBody, function (err, res, body) {
  if (err) {
    console.error('Failed to send error to Opbeat:', err.message);
    // Expected error: 'getaddrinfo ENOTFOUND intake.opbeat.com'
  } else if (res && res.statusCode !== 202) {
    console.error(`Opbeat responded with status ${res.statusCode}: ${body}`);
  } else {
    console.log('Successfully sent error to Opbeat:', body);
  }
});

console.log('Attempting to send data to deprecated Opbeat API...');

view raw JSON →