Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
hawklyMiddleware
✓ import { hawklyMiddleware } from 'hawkly-grpc'
✗ const hawklyMiddleware = require('hawkly-grpc').hawklyMiddleware
Named export from ESM module.
createClient
✓ import { createClient } from 'hawkly-grpc'
✗ import createClient from 'hawkly-grpc'
Named export, not default. Returns object with tracer and client.
HawklyError
✓ import { HawklyError } from 'hawkly-grpc'
Error class for handling gRPC handler errors.
TracedUnaryRequest
✓ import type { TracedUnaryRequest } from 'hawkly-grpc'
✗ import { TracedUnaryRequest } from 'hawkly-grpc'
TypeScript type only. Use type import for isolated declarations.
Demonstrates server setup with hawklyMiddleware and client creation with createClient, including tracing span creation and usage.
import { createClient } from 'hawkly-grpc';
import Mali from 'mali';
import path from 'path';
// Server setup
const PROTO_PATH = path.join(__dirname, 'helloworld.proto');
const app = new Mali(PROTO_PATH);
const hawklyTracerOptions = {
accessToken: process.env.HAWKLY_ACCESS_TOKEN ?? '',
componentName: 'testServerComponent',
};
app.use(hawklyMiddleware(hawklyTracerOptions));
app.use({ sayHello: () => { /* handler */ } });
app.start('0.0.0.0:1000');
// Client setup
const grpcHost = '0.0.0.0:1000';
const { tracer, client } = createClient({
accessToken: process.env.HAWKLY_ACCESS_TOKEN ?? '',
componentName: 'myComponent',
host: grpcHost,
proto: PROTO_PATH,
name: 'Greeter',
});
const span = tracer.startSpan('requestSpan');
const result = await client.sayHello({ arg: { name: 'world' }, span });
span.finish();
console.log(result);
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'startSpan')
createClient returns an object with tracer and client. Destructuring incorrectly.
fixUse const { tracer, client } = createClient(...); Error: Cannot find module 'mali'
Mali is a peer dependency and must be installed explicitly.
fixRun npm install mali grpc
Error: PROTO_PATH is not defined
The proto file path must be an absolute path.
fixUse __dirname + '/relative/path/to/file.proto' or path.resolve()
Audit
Dependencies
malirequiredgRPC server framework that the middleware wraps
grpcrequiredcore gRPC library