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

@infrastack/otel

v0.1.1

Published

[![npm](https://img.shields.io/npm/v/@infrastack/otel.svg)](https://www.npmjs.com/package/@infrastack/otel) ![npm](https://img.shields.io/npm/dm/@infrastack/otel)

Downloads

301

Readme

Infrastack Otel

infrastack.ai - Next-Gen Application Intelligence for Developers.

npm npm

GitHub

@infrastack/otel is a simple and easy-to-use open-source package which helps setting up OpenTelemetry tracing

⚡ Utilize this package to instrument your applications and get started with OpenTelemetry blazingly fast!

📦 Installation

$ npm install @infrastack/otel

Usage

To configure Infrastack SDK, call the init function in the instrumentation.ts:

import { startOtel } from "@infrastack/otel";
startOtel();

This will capture all the configurations from the .env file. This produces an output similar to below:

Exporter endpoint is set as: https://collector.infrastack.ai
Found an API Key: sk-1*****f5af
Service name is set as: fly-bright-dog
Service version is set as: 0.0.1
Application is now instrumented with infrastack.ai

Environment variables (.env)

INFRASTACK_LOGS_ENABLED=true/false # Enables or disables SDK startup logs
INFRASTACK_TAGS='[{"key": "key1", "value": "value1"}, {"key": "key2", "value": "value2"}]' # These tags are directly injected into ResourceAttributes of each span.
INFRASTACK_ENVIRONMENT=DEBUG/DEV/PROD 
INFRASTACK_API_KEY=YOUR_INFRASTACK_API_KEY

OTEL_EXPORTER_OTLP_ENDPOINT=YOUR_OTEL_EXPORTER_ENDPOINT
OTEL_EXPORTER_OTLP_HEADERS=YOUR_OTEL_EXPORTER_HEADERS # For infrastack.ai : "infrastack-api-key=sk-**********************"
OTEL_SERVICE_NAME=YOUR_SERVICE_NAME
OTEL_SERVICE_VERSION=YOUR_SERVICE_VERSION
OTEL_SERVICE_INSTANCE_ID=YOUR_SERVICE_INSTANCE_ID
OTEL_K8S_NAMESPACE=YOUR_K8S_POD_NAMESPACE
OTEL_K8S_POD_NAME=YOUR_K8S_POD_NAME

Initializing the SDK with configuration

You can initialize the SDK with configuration, which overrides the environment variables.

  1. First, gather the related imports from @infrastack/otel in your instrumentation.ts
import { startOtel, Instrumentation, Configuration, Environment, Tag } from "@infrastack/otel";
  1. Then, set up your SDK options.
const myTags : Tag[] = [
    {key: "aws-region", value: "us-west-2"},
    {key: "aws-account-id", value: "123456789012"}
]

const configuration : Configuration = {
    serviceName: "my-cool-service",
    serviceVersion: "1.0.0",
    environment: Environment.DEV,
    tags: myTags,
    logsEnabled: false,
    podNamespace: "my-cluster",
    podName: "my-pod"
}
  1. Initialize the Infrastack SDK
startOtel(configuration);

Partial configuration is also possible. For example:

const configuration : Configuration = {
    logsEnabled:false
}
startOtel(configuration);

This disables Infrastack SDK logs but collects the rest of the configuration from your .env file if available.


Custom spans

To produce manual spans in your code, you can seamlessly use the OpenTelemetry API:

import { trace } from "@opentelemetry/api";

const span = trace.getTracer("user-service").startSpan("fetch-user-data");

Troubleshooting

If you are having issues, feel free to contact us!

Contributing

@infrastack/otel is an open-source project and contributions are always welcomed! Here are some guidelines to the so:

  1. Clone the repository
$ git clone https://github.com/infrastackai/infrastack.git
  1. cd into the this package's directory
$ cd packages/javascript/otel
  1. Check out your feature branch
$ git checkout -b your-feature-branch
  1. Install the dependencies
$ npm i
  1. Implement your feature logic.
  2. Since we are using the tool called changeset to publish releases. Create a changeset and fill the prompted.
$ npx changeset
  1. Create a pull request in the repository from this URL and invite someone active from the repository.

We appreciate your help 😊


Visit the Changelog

References

infrastack.ai Docs

OpenTelemetry Javascript Docs