Skip to content

Commit 2154544

Browse files
AchoArnoldCopilot
andcommitted
feat: use separate Axiom datasets for traces/logs and metrics
Traces and logs go to AXIOM_TRACES_DATASET (events), metrics go to AXIOM_METRICS_DATASET (metrics). Replaces single AXIOM_DATASET. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f6d03a6 commit 2154544

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

api/.env.docker

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ UPTRACE_DSN=
6161
# Axiom observability configuration
6262
# API token for Axiom (required for logging, traces, and metrics in production)
6363
AXIOM_TOKEN=
64-
# Dataset name in Axiom where logs, traces, and metrics are sent
65-
AXIOM_DATASET=
64+
# Dataset for logs and traces (e.g. "events")
65+
AXIOM_TRACES_DATASET=
66+
# Dataset for metrics (e.g. "metrics")
67+
AXIOM_METRICS_DATASET=
6668

6769

6870
# [optional] Websocket configuration for https://pusher.com if you will like to frontend to update in real time

api/pkg/di/container.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,14 +1847,14 @@ func (container *Container) initializeGoogleTraceProvider(version string, namesp
18471847
func (container *Container) initializeAxiomTraceProvider(version string, namespace string) func() {
18481848
container.logger.Debug("initializing axiom trace provider")
18491849

1850-
headers := map[string]string{
1850+
traceHeaders := map[string]string{
18511851
"Authorization": "Bearer " + os.Getenv("AXIOM_TOKEN"),
1852-
"X-Axiom-Dataset": os.Getenv("AXIOM_DATASET"),
1852+
"X-Axiom-Dataset": os.Getenv("AXIOM_TRACES_DATASET"),
18531853
}
18541854

18551855
traceExporter, err := otlptracehttp.New(context.Background(),
18561856
otlptracehttp.WithEndpoint("us-east-1.aws.edge.axiom.co"),
1857-
otlptracehttp.WithHeaders(headers),
1857+
otlptracehttp.WithHeaders(traceHeaders),
18581858
)
18591859
if err != nil {
18601860
container.logger.Fatal(stacktrace.Propagate(err, "cannot create axiom OTLP trace exporter"))
@@ -1872,9 +1872,14 @@ func (container *Container) initializeAxiomTraceProvider(version string, namespa
18721872
propagation.Baggage{},
18731873
))
18741874

1875+
metricHeaders := map[string]string{
1876+
"Authorization": "Bearer " + os.Getenv("AXIOM_TOKEN"),
1877+
"X-Axiom-Dataset": os.Getenv("AXIOM_METRICS_DATASET"),
1878+
}
1879+
18751880
metricExporter, err := otlpmetrichttp.New(context.Background(),
18761881
otlpmetrichttp.WithEndpoint("us-east-1.aws.edge.axiom.co"),
1877-
otlpmetrichttp.WithHeaders(headers),
1882+
otlpmetrichttp.WithHeaders(metricHeaders),
18781883
)
18791884
if err != nil {
18801885
container.logger.Fatal(stacktrace.Propagate(err, "cannot create axiom OTLP metric exporter"))
@@ -1969,7 +1974,7 @@ func axiomLogger(skipFrameCount int) *zerodriver.Logger {
19691974
zerolog.TimeFieldFormat = time.RFC3339Nano
19701975

19711976
axiomWriter, err := axiomzerolog.New(
1972-
axiomzerolog.SetDataset(os.Getenv("AXIOM_DATASET")),
1977+
axiomzerolog.SetDataset(os.Getenv("AXIOM_TRACES_DATASET")),
19731978
)
19741979
if err != nil {
19751980
// Fall back to stderr JSON if Axiom is not configured

0 commit comments

Comments
 (0)