(version string, namespace string)
| 1835 | } |
| 1836 | |
| 1837 | func (container *Container) initializeAxiomTraceProvider(version string, namespace string) func() { |
| 1838 | container.logger.Debug("initializing axiom trace provider") |
| 1839 | |
| 1840 | traceHeaders := map[string]string{ |
| 1841 | "Authorization": "Bearer " + os.Getenv("AXIOM_TOKEN"), |
| 1842 | "X-Axiom-Dataset": os.Getenv("AXIOM_DATASET_EVENTS"), |
| 1843 | } |
| 1844 | |
| 1845 | traceExporter, err := otlptracehttp.New( |
| 1846 | context.Background(), |
| 1847 | otlptracehttp.WithEndpoint("us-east-1.aws.edge.axiom.co"), |
| 1848 | otlptracehttp.WithHeaders(traceHeaders), |
| 1849 | ) |
| 1850 | if err != nil { |
| 1851 | container.logger.Fatal(stacktrace.Propagate(err, "cannot create axiom OTLP trace exporter")) |
| 1852 | } |
| 1853 | |
| 1854 | tp := trace.NewTracerProvider( |
| 1855 | trace.WithBatcher(traceExporter), |
| 1856 | trace.WithSampler(trace.AlwaysSample()), |
| 1857 | trace.WithResource(container.OtelResources(version, namespace)), |
| 1858 | ) |
| 1859 | otel.SetTracerProvider(tp) |
| 1860 | |
| 1861 | otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator( |
| 1862 | propagation.TraceContext{}, |
| 1863 | propagation.Baggage{}, |
| 1864 | )) |
| 1865 | |
| 1866 | metricHeaders := map[string]string{ |
| 1867 | "Authorization": "Bearer " + os.Getenv("AXIOM_TOKEN"), |
| 1868 | "X-Axiom-Dataset": os.Getenv("AXIOM_DATASET_METRICS"), |
| 1869 | } |
| 1870 | |
| 1871 | metricExporter, err := otlpmetrichttp.New( |
| 1872 | context.Background(), |
| 1873 | otlpmetrichttp.WithEndpoint("us-east-1.aws.edge.axiom.co"), |
| 1874 | otlpmetrichttp.WithHeaders(metricHeaders), |
| 1875 | ) |
| 1876 | if err != nil { |
| 1877 | container.logger.Fatal(stacktrace.Propagate(err, "cannot create axiom OTLP metric exporter")) |
| 1878 | } |
| 1879 | |
| 1880 | meterProvider := metric.NewMeterProvider( |
| 1881 | metric.WithReader(metric.NewPeriodicReader(metricExporter)), |
| 1882 | metric.WithResource(container.OtelResources(version, namespace)), |
| 1883 | ) |
| 1884 | otel.SetMeterProvider(meterProvider) |
| 1885 | |
| 1886 | return func() { |
| 1887 | if err := tp.Shutdown(context.Background()); err != nil { |
| 1888 | container.logger.Error(stacktrace.Propagate(err, "cannot shutdown axiom trace provider")) |
| 1889 | } |
| 1890 | if err := meterProvider.Shutdown(context.Background()); err != nil { |
| 1891 | container.logger.Error(stacktrace.Propagate(err, "cannot shutdown axiom meter provider")) |
| 1892 | } |
| 1893 | } |
| 1894 | } |
no test coverage detected