Registry / devops / hawkly-grpc

hawkly-grpc

JSON →
library0.0.1jsnpmunverified

A gRPC wrapper for JavaScript/TypeScript that adds OpenTracing compatible tracing via Hawkly's tracer and async/await support. Status: active (work in progress). Built on top of Mali (gRPC framework) and grpc-caller. Ships TypeScript types. Key differentiators: automatic span creation for outgoing calls, custom HawklyError for server-side errors, and a createClient helper that returns both tracer and client. Release cadence: single 0.0.1 release.

npm install hawkly-grpc
INSTALL
IMPORT
SIG · HAWKLY-GRPC
H
hawkly-grpc
devopsjavascriptv0.0.1
harness data pending
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);
Debug
Known issues
gotchaMali does not support ESM imports in version 0.x. Use CommonJS require for Mali and gRPC.
fix
Use const Mali = require('mali'); instead of import.
affects: >=0.0.1
gotchacreateClient expects a proto file path and a service name. The proto must be compiled and accessible.
fix
Ensure PROTO_PATH points to a valid .proto file on disk.
affects: >=0.0.1
gotchaThe client methods return a Promise even without async/await. Forgetting await can lead to unhandled promises.
fix
Always await client calls.
affects: >=0.0.1
deprecatedThe library is in very early stage (0.0.1). API may change without notice.
fix
Pin exact version and review changelog before upgrading.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'startSpan')
createClient returns an object with tracer and client. Destructuring incorrectly.
fix
Use const { tracer, client } = createClient(...);
Error: Cannot find module 'mali'
Mali is a peer dependency and must be installed explicitly.
fix
Run npm install mali grpc
Error: PROTO_PATH is not defined
The proto file path must be an absolute path.
fix
Use __dirname + '/relative/path/to/file.proto' or path.resolve()
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
malirequiredgRPC server framework that the middleware wraps
grpcrequiredcore gRPC library
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources
hawkly-grpc — npm install hawkly-grpc · libregistry