@@ -29,9 +29,9 @@ import (
29
29
30
30
// Exporter is a helper to add observability to a component.Exporter.
31
31
type Exporter struct {
32
- level configtelemetry.Level
33
- exporterName string
34
- mutators []tag.Mutator
32
+ level configtelemetry.Level
33
+ spanNamePrefix string
34
+ mutators []tag.Mutator
35
35
}
36
36
37
37
// ExporterSettings are settings for creating an Exporter.
@@ -43,50 +43,50 @@ type ExporterSettings struct {
43
43
// NewExporter creates a new Exporter.
44
44
func NewExporter (cfg ExporterSettings ) * Exporter {
45
45
return & Exporter {
46
- level : cfg .Level ,
47
- exporterName : cfg .ExporterID .String (),
48
- mutators : []tag.Mutator {tag .Upsert (obsmetrics .TagKeyExporter , cfg .ExporterID .String (), tag .WithTTL (tag .TTLNoPropagation ))},
46
+ level : cfg .Level ,
47
+ spanNamePrefix : obsmetrics . ExporterPrefix + cfg .ExporterID .String (),
48
+ mutators : []tag.Mutator {tag .Upsert (obsmetrics .TagKeyExporter , cfg .ExporterID .String (), tag .WithTTL (tag .TTLNoPropagation ))},
49
49
}
50
50
}
51
51
52
- // StartTracesExportOp is called at the start of an Export operation.
52
+ // StartTracesOp is called at the start of an Export operation.
53
53
// The returned context should be used in other calls to the Exporter functions
54
54
// dealing with the same export operation.
55
- func (eor * Exporter ) StartTracesExportOp (ctx context.Context ) context.Context {
55
+ func (eor * Exporter ) StartTracesOp (ctx context.Context ) context.Context {
56
56
return eor .startSpan (ctx , obsmetrics .ExportTraceDataOperationSuffix )
57
57
}
58
58
59
- // EndTracesExportOp completes the export operation that was started with StartTracesExportOp .
60
- func (eor * Exporter ) EndTracesExportOp (ctx context.Context , numSpans int , err error ) {
59
+ // EndTracesOp completes the export operation that was started with StartTracesOp .
60
+ func (eor * Exporter ) EndTracesOp (ctx context.Context , numSpans int , err error ) {
61
61
numSent , numFailedToSend := toNumItems (numSpans , err )
62
62
eor .recordMetrics (ctx , numSent , numFailedToSend , obsmetrics .ExporterSentSpans , obsmetrics .ExporterFailedToSendSpans )
63
63
endSpan (ctx , err , numSent , numFailedToSend , obsmetrics .SentSpansKey , obsmetrics .FailedToSendSpansKey )
64
64
}
65
65
66
- // StartMetricsExportOp is called at the start of an Export operation.
66
+ // StartMetricsOp is called at the start of an Export operation.
67
67
// The returned context should be used in other calls to the Exporter functions
68
68
// dealing with the same export operation.
69
- func (eor * Exporter ) StartMetricsExportOp (ctx context.Context ) context.Context {
69
+ func (eor * Exporter ) StartMetricsOp (ctx context.Context ) context.Context {
70
70
return eor .startSpan (ctx , obsmetrics .ExportMetricsOperationSuffix )
71
71
}
72
72
73
- // EndMetricsExportOp completes the export operation that was started with
74
- // StartMetricsExportOp .
75
- func (eor * Exporter ) EndMetricsExportOp (ctx context.Context , numMetricPoints int , err error ) {
73
+ // EndMetricsOp completes the export operation that was started with
74
+ // StartMetricsOp .
75
+ func (eor * Exporter ) EndMetricsOp (ctx context.Context , numMetricPoints int , err error ) {
76
76
numSent , numFailedToSend := toNumItems (numMetricPoints , err )
77
77
eor .recordMetrics (ctx , numSent , numFailedToSend , obsmetrics .ExporterSentMetricPoints , obsmetrics .ExporterFailedToSendMetricPoints )
78
78
endSpan (ctx , err , numSent , numFailedToSend , obsmetrics .SentMetricPointsKey , obsmetrics .FailedToSendMetricPointsKey )
79
79
}
80
80
81
- // StartLogsExportOp is called at the start of an Export operation.
81
+ // StartLogsOp is called at the start of an Export operation.
82
82
// The returned context should be used in other calls to the Exporter functions
83
83
// dealing with the same export operation.
84
- func (eor * Exporter ) StartLogsExportOp (ctx context.Context ) context.Context {
84
+ func (eor * Exporter ) StartLogsOp (ctx context.Context ) context.Context {
85
85
return eor .startSpan (ctx , obsmetrics .ExportLogsOperationSuffix )
86
86
}
87
87
88
- // EndLogsExportOp completes the export operation that was started with StartLogsExportOp .
89
- func (eor * Exporter ) EndLogsExportOp (ctx context.Context , numLogRecords int , err error ) {
88
+ // EndLogsOp completes the export operation that was started with StartLogsOp .
89
+ func (eor * Exporter ) EndLogsOp (ctx context.Context , numLogRecords int , err error ) {
90
90
numSent , numFailedToSend := toNumItems (numLogRecords , err )
91
91
eor .recordMetrics (ctx , numSent , numFailedToSend , obsmetrics .ExporterSentLogRecords , obsmetrics .ExporterFailedToSendLogRecords )
92
92
endSpan (ctx , err , numSent , numFailedToSend , obsmetrics .SentLogRecordsKey , obsmetrics .FailedToSendLogRecordsKey )
@@ -95,7 +95,7 @@ func (eor *Exporter) EndLogsExportOp(ctx context.Context, numLogRecords int, err
95
95
// startSpan creates the span used to trace the operation. Returning
96
96
// the updated context and the created span.
97
97
func (eor * Exporter ) startSpan (ctx context.Context , operationSuffix string ) context.Context {
98
- spanName := obsmetrics . ExporterPrefix + eor .exporterName + operationSuffix
98
+ spanName := eor .spanNamePrefix + operationSuffix
99
99
ctx , _ = trace .StartSpan (ctx , spanName )
100
100
return ctx
101
101
}
0 commit comments