-
Notifications
You must be signed in to change notification settings - Fork 0
/
exporter.go
56 lines (50 loc) · 1.46 KB
/
exporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
/*
import (
"context"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/encoding/gzip"
)
func newTraceExporter(c Config, headerName string) (*otlptrace.Exporter, error) {
secureOption := otlptracegrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
if c.SpanExporterEndpointInsecure {
secureOption = otlptracegrpc.WithInsecure()
}
return otlptrace.New(
context.Background(),
otlptracegrpc.NewClient(
secureOption,
otlptracegrpc.WithEndpoint(c.SpanExporterEndpoint),
otlptracegrpc.WithHeaders(
map[string]string{
headerName: c.AccessToken,
},
),
otlptracegrpc.WithCompressor(gzip.Name),
),
)
}
func newMetricsExporter(c Config, headerName string) (*otlpmetric.Exporter, error) {
secureOption := otlpmetricgrpc.WithTLSCredentials(credentials.NewClientTLSFromCert(nil, ""))
if c.MetricExporterEndpointInsecure {
secureOption = otlpmetricgrpc.WithInsecure()
}
return otlpmetric.New(
context.Background(),
otlpmetricgrpc.NewClient(
secureOption,
otlpmetricgrpc.WithEndpoint(c.MetricExporterEndpoint),
otlpmetricgrpc.WithHeaders(
map[string]string{
headerName: c.AccessToken,
},
),
otlpmetricgrpc.WithCompressor(gzip.Name),
),
)
}
*/