Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace READMEs with link to the docs #221

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ and our

## Projects

This is a monorepo, for specific documentation, check out the different projects:
This is a monorepo consisting of the following projects:

* [`@axiomhq/js`](./packages/js): Official API bindings that let you ingest or query your data.
* [`@axiomhq/winston`](./packages/winston): A [winston](https://github.com/winstonjs/winston) transport which sends logs to Axiom.
Expand Down
81 changes: 3 additions & 78 deletions packages/js/README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,5 @@
## Javascript SDK for Axiom
# Axiom JavaScript SDK

## Quickstart
The Axiom JavaScript SDK allows you to send data from a JavaScript app to Axiom.

Install using `npm install`:

```shell
npm install @axiomhq/js
```

If you use the [Axiom CLI](https://github.com/axiomhq/cli), run `eval $(axiom config export -f)` to configure your environment variables.

Otherwise create a new token in [the Axiom settings](https://app.axiom.co/api-tokens) and export it as `AXIOM_TOKEN`.

You can also configure the client using options passed to the constructor of the Client:

```ts
import { Axiom } from '@axiomhq/js';

const axiom = new Axiom({
token: process.env.AXIOM_TOKEN,
});
```

You can then ingest data like this:

```ts
axiom.ingest('my-dataset', [{ foo: 'bar' }]);
await axiom.flush();
```

> **Note** that the client is automatically batching events in the background, in most cases you'll only want to call `flush()` before your application exits.

And query data like this:

```ts
const res = await axiom.query(`['my-dataset'] | where foo == 'bar' | limit 100`);
console.log(res);
```

For further examples, head over to the [examples](../../examples/js) directory.


## Capture Errors

To capture errors, you can pass a method `onError` to the client:

```ts
let client = new Axiom({
token: '',
...,
onError: (err) => {
console.error('ERROR:', err);
}
});
```
by default `onError` is set to `console.error`.


## Annotations

Starting from `v1.0.0` the SDK supports the [Annotations API](https://axiom.co/docs/restapi/endpoints/createAnnotation). You can create annotations like this:

```ts
// import the annotations module
import { annotations } from '@axiomhq/js';
// create a client
const client = new annotations.Service({ token: process.env.AXIOM_TOKEN });
```

Then create an annotation like this:

```ts
await annotations.create({
type: 'deployment',
datasets: ['dataset_name'],
title: 'New deployment',
description: 'Deployed version 1.0.0 with fixes for ...',
})
```
For more information about how to set up and use the Axiom JavaScript SDK, see the [Axiom documentation](https://axiom.co/docs/guides/javascript).
41 changes: 3 additions & 38 deletions packages/pino/README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,5 @@
# Axiom Transport for Pino logger
# Axiom transport for Pino logger

This is the official Axiom transport for Pino.
The Axiom transport for Pino logger allows you to send data from a Node.js app to Axiom through Pino.

## Quickstart

Install using `npm install`:

```shell
npm install @axiomhq/pino
```

create a pino logger with Axiom configured:

```ts
import pino from 'pino';

const logger = pino(
{ level: 'info' },
pino.transport({
target: '@axiomhq/pino',
options: {
dataset: process.env.AXIOM_DATASET,
token: process.env.AXIOM_TOKEN,
},
}),
);
```

then you can use the logger as usual:

```js
logger.info('Hello from pino!');
```

For further examples, head over to the [examples](../../examples/pino) directory.

## License

Distributed under the [MIT License](../../LICENSE).
For more information about how to set up and use the Axiom transport for Pino logger, see the [Axiom documentation](https://axiom.co/docs/guides/pino).
89 changes: 3 additions & 86 deletions packages/winston/README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,5 @@
# Axiom Transport for Winston logger
# Axiom transport for Winston logger

You can use Winston logger to send logs to Axiom. First, install the winston and @axiomhq/winston packages, then create an instance of the logger with the AxiomTransport.
The Axiom transport for Winston logger allows you to send data from a Node.js app to Axiom through Winston.

## Quickstart

Install using `npm install`:

```shell
npm install @axiomhq/winston
```

import the axiom transport for winston:

```js
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
```

create a winston logger instance with axiom transport:

```js
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
// You can pass an option here, if you don't the transport is configured automatically
// using environment variables like `AXIOM_DATASET` and `AXIOM_TOKEN`
new AxiomTransport({
dataset: 'my-dataset',
token: 'my-token',
}),
],
});
```

then you can use the logger as usual:

```js
logger.log({
level: 'info',
message: 'Logger successfully setup',
});
```

### Error, exception and rejection handling

If you want to log `Error`s, we recommend using the
[`winston.format.errors`](https://github.com/winstonjs/logform#errors)
formatter, for example like this:

```ts
import winston from 'winston';
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
const { combine, errors, stack } = winston.format;
const axiomTransport = new AxiomTransport({ ... });
const logger = winston.createLogger({
// 8<----snip----
format: combine(errors({ stack: true }), json()),
// 8<----snip----
});
```

To automatically log exceptions and rejections, add the Axiom transport to the
[`exceptionHandlers`](https://github.com/winstonjs/winston#exceptions) and
[`rejectionHandlers`](https://github.com/winstonjs/winston#rejections) like
this:

```ts
import winston from 'winston';
import { WinstonTransport as AxiomTransport } from '@axiomhq/winston';
const axiomTransport = new AxiomTransport({ ... });
const logger = winston.createLogger({
// 8<----snip----
transports: [axiomTransport],
exceptionHandlers: [axiomTransport],
rejectionHandlers: [axiomTransport],
// 8<----snip----
});
```

:warning: Running on Edge runtime is not supported at the moment.

For further examples, head over to the [examples](../../examples/winston/) directory.

## License

Distributed under the [MIT License](../../LICENSE).
For more information about how to set up and use the Axiom transport for Winston logger, see the [Axiom documentation](https://axiom.co/docs/guides/winston).
Loading