0.0.37 • Published 8 months ago

fero-testing-otel v0.0.37

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

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

0.0.20

8 months ago

0.0.21

8 months ago

0.0.22

8 months ago

0.0.23

8 months ago

0.0.24

8 months ago

0.0.25

8 months ago

0.0.37

8 months ago

0.0.15

8 months ago

0.0.16

8 months ago

0.0.17

8 months ago

0.0.18

8 months ago

0.0.19

8 months ago

0.0.30

8 months ago

0.0.31

8 months ago

0.0.32

8 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.13

8 months ago

0.0.36

8 months ago

0.0.14

8 months ago

0.0.26

8 months ago

0.0.27

8 months ago

0.0.28

8 months ago

0.0.29

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago