Axiom adapter for Zap
This page explains how to send logs generated by the uber-go/zap library to Axiom.
Use the adapter of the Axiom Go SDK to send logs generated by the uber-go/zap library to Axiom.
The Axiom Go SDK is an open-source project and welcomes your contributions. For more information, see the GitHub repository.
Prerequisites
- Create an Axiom account.
- Create a dataset in Axiom where you send your data.
- Create an API token in Axiom with permissions to update the dataset you have created.
Set up SDK
-
Install the Axiom Go SDK and configure your environment as explained in Send data from Go app to Axiom.
-
In your Go app, import the
zap
package. It is imported as anadapter
so that it doesn’t conflict with theuber-go/zap
package.Alternatively, configure the adapter using options passed to the New function:
Replace
DATASET_NAME
with the name of the Axiom dataset where you want to send data.
Configure client
To configure the underlying client manually, choose one of the following:
-
Use SetClient to pass in the client you have previously created with Send data from Go app to Axiom.
-
Use SetClientOptions to pass client options to the adapter.
The adapter uses a buffer to batch events before sending them to Axiom. Flush this buffer explicitly by calling Sync. For more information, see the zap documentation and the example in GitHub.
Reference
For a full reference of the adapter’s functions, see the Go Packages page.
Was this page helpful?