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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@sap/e2e-trace

v5.3.0

Published

Provides functionalities for handling SAP Passports

Downloads

141,192

Readme

@sap/e2e-trace

Node.js package with end to end tracing capabilities.

Overview

SAP Passport

SAP Passports allow to identify a specific request in an end-to-end scenario involving several components communicating with each other. This is especially helpful in the task of following the state of a business transaction across different systems. To achieve that, the client should send a special header ('sap-passport') containing the SAP Passport to the first component. The SAP Passport is a hex string with a special structure. The client can send one via a browser plugin or via SAPUI5 application frontend. Whenever an SAP Passport comes into a component, this component should also include the unique identifiers of the SAP Passport in its logs/traces, update it with component specific data and then forward it to the next system.

See the diagram below:

SAP Passport overview diagram

An application receives an SAP Passport in the 'sap-passport' header. The same header is used when the SAP Passport is getting forwarded over the HTTP protocol to another system. If it is being sent to HANA, the SAP Passport should be set as the 'SAP_PASSPORT' session variable of the database connection.

API

  • Loading the package:
var SAPPassport = require('@sap/e2e-trace').Passport;
  • Creating an SAP Passport instance
function requestHandler(req, res) {
  var encodedPassport = req.headers[SAPPassport.HEADER_NAME];
  if (encodedPassport) {
    var passport = new SAPPassport(encodedPassport);
  }
}

The library provides a constant for the 'sap-passport' header: SAPPassport.HEADER_NAME.

The passport variable is an instance with which you may read/modify the SAP Passport in your component.

  • Reading the unique identifiers of an SAP Passport
var identifiers = passport.readUniqueIdentifiers();

The returned value (assigned to the identifiers variable) is an object that has the following properties: transactionID, rootContextID, connectionID, connectionCounter. These SAP Passport fields got to be present in the logs/traces of the component. If you are using the sap-logging library, refer to its documentation to check whether the specific version is capable of handling SAP Passports or not.

  • Updating the SAP Passport - this is done right before forwarding it to the next component.
passport.update({
  previousComponent: 'my-application',
  connectionID: '00112233445566778899AABBCCDDEEFF',
  connectionCounter: 36
});

This method takes an object with the following properties:

Property | Value | Mandatory | Semantics ------------- | ---------- | --------- | -------------------------- previousComponent | ASCII string. Up to 32 characters. | | This is the name of the current component which is about to make an outbound connection to another component. Defaults to XSA Node.js. connectionID | GUID, 16-byte hex | yes | Every connection between the current component and the next component should have an ID which is passed as that property. connectionCounter| Positive integer, up to 4 bytes | yes | States for which time the connection with the given connectionID is being reused.

  • Compacting the SAP Passport - HANA DB has a limitation over the SAP Passport size. This is why it is recommended to call the method compact before forwarding an SAP Passport to HANA.
passport.compact();
  • Generating a hex string out of the updated SAP Passport - the SAP Passport can be send to other components in this format.
var http = require('http');
var url = require('url');

var encodedPassport = passport.serialize();

var options = url.parse('http://my-host:1234/my/path');
options.headers = {};
options.headers[SAPPassport.HEADER_NAME] = encodedPassport;

var request = http.request(options);
request.on('error', function (err) { /* ... */ });
request.on('response', function (response) { /* ... */ });
request.end();

DSR records

Distributed Statistics Records contain statistical information regarding an incoming request. The library writes every record on the standard output in a JSON format. Gathering DSR statistics is triggered when a request containing an SAP passport is received.

API

var connect = require('connect');
var createDsrMiddleware = require('@sap/e2e-trace').createDsrMiddleware;

var app = connect();

app.use(createDsrMiddleware());
app.use('/path', function (req, res, next) {
  // ...
});

The DSR middleware (can be used with frameworks like connect and express) should be the first middleware in the request processing flow.

Example DSR record:

{"action":"https://host:5555/path?a=1&b=2","receivedBytes":1230,"sentBytes":110,"respTime":18,"transId":"104A7DB661D31EE69DE912281546ED81","userId":"n.a.","startTime":1473506434377}

Properties in a DSR record:

Property | Description ------------- | ----------- startTime | Time at which request processing starts (milliseconds elapsed since 1 January 1970 00:00:00 UTC). action | The requested URL. receivedBytes | Number of bytes the incoming HTTP request contains (lengths of request line, headers section and body included). Note: due to a bug in Node.js, this field might be 0 in some runtime versions. Refer to the engines/node property in package.json for recommended Node.js versions. sentBytes | Number of bytes the outgoing HTTP response contains (lengths of status line, headers section and body included). respTime | Number of milliseconds spent in request processing (until the whole outgoing HTTP response has been handed off to the operating system for transmission over the network). transId | The Transaction ID field of the SAP Passport that has triggered the DSR record. userId | User ID of the current user taken from the request object. Defaults to n.a..