https://github.com/paulmorar/dynatrace-data-sdk
This is a package that simplifies sending various types of data into your Dynatrace tenant.
https://github.com/paulmorar/dynatrace-data-sdk
Last synced: 3 months ago
JSON representation
This is a package that simplifies sending various types of data into your Dynatrace tenant.
- Host: GitHub
- URL: https://github.com/paulmorar/dynatrace-data-sdk
- Owner: paulmorar
- License: mit
- Created: 2023-09-28T19:03:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-17T22:44:00.000Z (4 months ago)
- Last Synced: 2025-01-17T23:29:14.576Z (4 months ago)
- Language: TypeScript
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynatrace-data-sdk
## Introduction
This package aims at simplifying data interactions with your Dynatrace tenant using the JavaScript SDK. It can be used directly in any JavaScript application or Node.js server-side application. The SDK provides a set of tools to send logs and metrics to your Dynatrace environment, making it easier to monitor and analyze your application's performance.
## Getting started
Install the SDK using your package manager of choice:
```sh
// npm example
npm install dynatrace-data-sdk// yarn example
yarn add dynatrace-data-sdk// pnpm example
pnpm install dynatrace-data-sdk
```### SDK initialization
To initialize the SDK, import the `initialize` function and configure it with your tenant ID and token:
```js
import initialize from "dynatrace-data-sdk";const client = initialize({ tenantId: TENANT_ID, token: YOUR_ID_TOKEN });
// Example usage
client
.sendLog({
content: "This is a log message",
"log.source": "example-source",
loglevel: "INFO",
"dt.entity.custom_device": "CUSTOM_DEVICE_ID",
})
.then(() => {
console.log("Log sent successfully");
})
.catch((error) => {
console.error("Error sending log:", error);
});
```You are now left with various interactions that fit your needs. After initialization, the client exposes functions that return a promise.
## TypeScript
This package also provides TypeScript definitions for the following:
```ts
import { SDKClient, ClientConfig, Log, Metric } from "dynatrace-data-sdk";type SDKClient = {
sendLog: (log: Log) => Promise;
sendLogs: (log: Log[]) => Promise;
sendMetric: (metric: Metric) => Promise;
sendMetrics: (metrics: Metric[]) => Promise;
};type ClientConfig = {
tenantId: string;
token: string;
};type Log = {
content: string;
["log.source"]: string;
loglevel: string;
["dt.entity.custom_device"]: string;
};type Metric = string;
```