2020-03-24 07:41:10 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-09-09 23:59:39 +02:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package jaeger
|
|
|
|
|
|
|
|
import (
|
2019-10-08 20:56:58 +02:00
|
|
|
"context"
|
2019-10-23 08:01:33 +02:00
|
|
|
"encoding/binary"
|
2019-09-09 23:59:39 +02:00
|
|
|
|
|
|
|
"google.golang.org/api/support/bundler"
|
2019-09-25 22:22:33 +02:00
|
|
|
"google.golang.org/grpc/codes"
|
2019-09-09 23:59:39 +02:00
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
"go.opentelemetry.io/otel/api/global"
|
2020-06-09 02:05:16 +02:00
|
|
|
apitrace "go.opentelemetry.io/otel/api/trace"
|
2020-03-02 23:54:57 +02:00
|
|
|
gen "go.opentelemetry.io/otel/exporters/trace/jaeger/internal/gen-go/jaeger"
|
2020-08-18 05:25:03 +02:00
|
|
|
"go.opentelemetry.io/otel/label"
|
2019-11-05 23:08:55 +02:00
|
|
|
export "go.opentelemetry.io/otel/sdk/export/trace"
|
2020-03-10 22:58:45 +02:00
|
|
|
sdktrace "go.opentelemetry.io/otel/sdk/trace"
|
2019-09-09 23:59:39 +02:00
|
|
|
)
|
|
|
|
|
2020-09-03 16:22:05 +02:00
|
|
|
const (
|
|
|
|
defaultServiceName = "OpenTelemetry"
|
|
|
|
|
|
|
|
keyInstrumentationLibraryName = "otel.instrumentation_library.name"
|
|
|
|
keyInstrumentationLibraryVersion = "otel.instrumentation_library.version"
|
|
|
|
)
|
2019-09-09 23:59:39 +02:00
|
|
|
|
2019-10-04 21:07:42 +02:00
|
|
|
type Option func(*options)
|
2019-09-09 23:59:39 +02:00
|
|
|
|
2019-10-08 20:56:58 +02:00
|
|
|
// options are the options to be used when initializing a Jaeger export.
|
2019-10-04 21:07:42 +02:00
|
|
|
type options struct {
|
2019-09-09 23:59:39 +02:00
|
|
|
// Process contains the information about the exporting process.
|
|
|
|
Process Process
|
|
|
|
|
2020-06-09 02:05:16 +02:00
|
|
|
// BufferMaxCount defines the total number of traces that can be buffered in memory
|
2019-09-09 23:59:39 +02:00
|
|
|
BufferMaxCount int
|
2020-03-10 22:58:45 +02:00
|
|
|
|
2020-07-10 16:28:45 +02:00
|
|
|
// BatchMaxCount defines the maximum number of spans sent in one batch
|
|
|
|
BatchMaxCount int
|
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
Config *sdktrace.Config
|
|
|
|
|
2020-06-05 04:05:53 +02:00
|
|
|
Disabled bool
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
2019-10-04 21:07:42 +02:00
|
|
|
// WithProcess sets the process with the information about the exporting process.
|
2020-04-22 05:30:57 +02:00
|
|
|
func WithProcess(process Process) Option {
|
2019-10-04 21:07:42 +02:00
|
|
|
return func(o *options) {
|
|
|
|
o.Process = process
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-09 02:05:16 +02:00
|
|
|
// WithBufferMaxCount defines the total number of traces that can be buffered in memory
|
2020-04-22 05:30:57 +02:00
|
|
|
func WithBufferMaxCount(bufferMaxCount int) Option {
|
2019-10-04 21:07:42 +02:00
|
|
|
return func(o *options) {
|
|
|
|
o.BufferMaxCount = bufferMaxCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:28:45 +02:00
|
|
|
// WithBatchMaxCount defines the maximum number of spans in one batch
|
|
|
|
func WithBatchMaxCount(batchMaxCount int) Option {
|
|
|
|
return func(o *options) {
|
|
|
|
o.BatchMaxCount = batchMaxCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
// WithSDK sets the SDK config for the exporter pipeline.
|
2020-04-22 05:30:57 +02:00
|
|
|
func WithSDK(config *sdktrace.Config) Option {
|
2020-03-10 22:58:45 +02:00
|
|
|
return func(o *options) {
|
|
|
|
o.Config = config
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 20:57:48 +02:00
|
|
|
// WithDisabled option will cause pipeline methods to use
|
|
|
|
// a no-op provider
|
2020-06-05 04:05:53 +02:00
|
|
|
func WithDisabled(disabled bool) Option {
|
|
|
|
return func(o *options) {
|
|
|
|
o.Disabled = disabled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
// NewRawExporter returns a trace.Exporter implementation that exports
|
2019-09-09 23:59:39 +02:00
|
|
|
// the collected spans to Jaeger.
|
2020-06-09 02:05:16 +02:00
|
|
|
//
|
|
|
|
// It will IGNORE Disabled option.
|
2020-03-10 22:58:45 +02:00
|
|
|
func NewRawExporter(endpointOption EndpointOption, opts ...Option) (*Exporter, error) {
|
2020-06-09 02:05:16 +02:00
|
|
|
uploader, err := endpointOption()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-04 21:07:42 +02:00
|
|
|
o := options{}
|
2020-06-10 05:36:25 +02:00
|
|
|
opts = append(opts, WithProcessFromEnv())
|
2019-10-04 21:07:42 +02:00
|
|
|
for _, opt := range opts {
|
|
|
|
opt(&o)
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
2019-10-04 21:07:42 +02:00
|
|
|
|
2019-09-09 23:59:39 +02:00
|
|
|
service := o.Process.ServiceName
|
|
|
|
if service == "" {
|
|
|
|
service = defaultServiceName
|
|
|
|
}
|
2019-10-17 18:59:30 +02:00
|
|
|
tags := make([]*gen.Tag, 0, len(o.Process.Tags))
|
|
|
|
for _, tag := range o.Process.Tags {
|
|
|
|
t := keyValueToTag(tag)
|
|
|
|
if t != nil {
|
|
|
|
tags = append(tags, t)
|
|
|
|
}
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
e := &Exporter{
|
2019-10-04 21:07:42 +02:00
|
|
|
uploader: uploader,
|
2019-09-09 23:59:39 +02:00
|
|
|
process: &gen.Process{
|
|
|
|
ServiceName: service,
|
|
|
|
Tags: tags,
|
|
|
|
},
|
2020-03-10 22:58:45 +02:00
|
|
|
o: o,
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
bundler := bundler.NewBundler((*gen.Span)(nil), func(bundle interface{}) {
|
|
|
|
if err := e.upload(bundle.([]*gen.Span)); err != nil {
|
2020-06-02 21:30:55 +02:00
|
|
|
global.Handle(err)
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// Set BufferedByteLimit with the total number of spans that are permissible to be held in memory.
|
|
|
|
// This needs to be done since the size of messages is always set to 1. Failing to set this would allow
|
|
|
|
// 1G messages to be held in memory since that is the default value of BufferedByteLimit.
|
|
|
|
if o.BufferMaxCount != 0 {
|
|
|
|
bundler.BufferedByteLimit = o.BufferMaxCount
|
|
|
|
}
|
|
|
|
|
2020-07-10 16:28:45 +02:00
|
|
|
// The default value bundler uses is 10, increase to send larger batches
|
|
|
|
if o.BatchMaxCount != 0 {
|
|
|
|
bundler.BundleCountThreshold = o.BatchMaxCount
|
|
|
|
}
|
|
|
|
|
2019-09-09 23:59:39 +02:00
|
|
|
e.bundler = bundler
|
|
|
|
return e, nil
|
|
|
|
}
|
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
// NewExportPipeline sets up a complete export pipeline
|
|
|
|
// with the recommended setup for trace provider
|
2020-06-09 02:05:16 +02:00
|
|
|
func NewExportPipeline(endpointOption EndpointOption, opts ...Option) (apitrace.Provider, func(), error) {
|
|
|
|
o := options{}
|
2020-06-10 05:36:25 +02:00
|
|
|
opts = append(opts, WithDisabledFromEnv())
|
2020-06-09 02:05:16 +02:00
|
|
|
for _, opt := range opts {
|
|
|
|
opt(&o)
|
|
|
|
}
|
|
|
|
if o.Disabled {
|
2020-09-09 02:43:35 +02:00
|
|
|
return apitrace.NoopProvider(), func() {}, nil
|
2020-06-09 02:05:16 +02:00
|
|
|
}
|
|
|
|
|
2020-03-10 22:58:45 +02:00
|
|
|
exporter, err := NewRawExporter(endpointOption, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
syncer := sdktrace.WithSyncer(exporter)
|
|
|
|
tp, err := sdktrace.NewProvider(syncer)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
if exporter.o.Config != nil {
|
|
|
|
tp.ApplyConfig(*exporter.o.Config)
|
|
|
|
}
|
|
|
|
|
|
|
|
return tp, exporter.Flush, nil
|
|
|
|
}
|
|
|
|
|
2020-07-22 20:57:48 +02:00
|
|
|
// InstallNewPipeline instantiates a NewExportPipeline with the
|
|
|
|
// recommended configuration and registers it globally.
|
|
|
|
func InstallNewPipeline(endpointOption EndpointOption, opts ...Option) (func(), error) {
|
|
|
|
tp, flushFn, err := NewExportPipeline(endpointOption, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-08-31 19:02:04 +02:00
|
|
|
global.SetTracerProvider(tp)
|
2020-07-22 20:57:48 +02:00
|
|
|
return flushFn, nil
|
|
|
|
}
|
|
|
|
|
2019-09-09 23:59:39 +02:00
|
|
|
// Process contains the information exported to jaeger about the source
|
|
|
|
// of the trace data.
|
|
|
|
type Process struct {
|
|
|
|
// ServiceName is the Jaeger service name.
|
|
|
|
ServiceName string
|
|
|
|
|
|
|
|
// Tags are added to Jaeger Process exports
|
2020-08-18 05:25:03 +02:00
|
|
|
Tags []label.KeyValue
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
2020-04-22 05:34:53 +02:00
|
|
|
// Exporter is an implementation of trace.SpanSyncer that uploads spans to Jaeger.
|
2019-09-09 23:59:39 +02:00
|
|
|
type Exporter struct {
|
2019-10-04 21:07:42 +02:00
|
|
|
process *gen.Process
|
|
|
|
bundler *bundler.Bundler
|
|
|
|
uploader batchUploader
|
2020-03-10 22:58:45 +02:00
|
|
|
o options
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
2019-10-08 20:56:58 +02:00
|
|
|
var _ export.SpanSyncer = (*Exporter)(nil)
|
2019-09-09 23:59:39 +02:00
|
|
|
|
|
|
|
// ExportSpan exports a SpanData to Jaeger.
|
2019-10-08 20:56:58 +02:00
|
|
|
func (e *Exporter) ExportSpan(ctx context.Context, d *export.SpanData) {
|
|
|
|
_ = e.bundler.Add(spanDataToThrift(d), 1)
|
2019-09-09 23:59:39 +02:00
|
|
|
// TODO(jbd): Handle oversized bundlers.
|
|
|
|
}
|
|
|
|
|
2019-10-08 20:56:58 +02:00
|
|
|
func spanDataToThrift(data *export.SpanData) *gen.Span {
|
2019-09-09 23:59:39 +02:00
|
|
|
tags := make([]*gen.Tag, 0, len(data.Attributes))
|
2019-09-25 22:22:33 +02:00
|
|
|
for _, kv := range data.Attributes {
|
2019-10-17 18:59:30 +02:00
|
|
|
tag := keyValueToTag(kv)
|
|
|
|
if tag != nil {
|
|
|
|
tags = append(tags, tag)
|
|
|
|
}
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
2020-04-23 21:10:58 +02:00
|
|
|
// TODO (jmacd): OTel has a broad "last value wins"
|
|
|
|
// semantic. Should resources be appended before span
|
|
|
|
// attributes, above, to allow span attributes to
|
|
|
|
// overwrite resource attributes?
|
2020-03-17 01:38:21 +02:00
|
|
|
if data.Resource != nil {
|
2020-04-23 21:10:58 +02:00
|
|
|
for iter := data.Resource.Iter(); iter.Next(); {
|
|
|
|
if tag := keyValueToTag(iter.Attribute()); tag != nil {
|
2020-03-17 01:38:21 +02:00
|
|
|
tags = append(tags, tag)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 07:15:53 +02:00
|
|
|
if il := data.InstrumentationLibrary; il.Name != "" {
|
2020-09-03 16:22:05 +02:00
|
|
|
tags = append(tags, getStringTag(keyInstrumentationLibraryName, il.Name))
|
2020-06-10 07:15:53 +02:00
|
|
|
if il.Version != "" {
|
2020-09-03 16:22:05 +02:00
|
|
|
tags = append(tags, getStringTag(keyInstrumentationLibraryVersion, il.Version))
|
2020-06-10 07:15:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-07 20:38:59 +02:00
|
|
|
tags = append(tags,
|
|
|
|
getInt64Tag("status.code", int64(data.StatusCode)),
|
|
|
|
getStringTag("status.message", data.StatusMessage),
|
2020-02-01 00:03:04 +02:00
|
|
|
getStringTag("span.kind", data.SpanKind.String()),
|
2019-09-09 23:59:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Ensure that if Status.Code is not OK, that we set the "error" tag on the Jaeger span.
|
|
|
|
// See Issue https://github.com/census-instrumentation/opencensus-go/issues/1041
|
2020-03-07 20:38:59 +02:00
|
|
|
if data.StatusCode != codes.OK {
|
2019-09-25 22:22:33 +02:00
|
|
|
tags = append(tags, getBoolTag("error", true))
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var logs []*gen.Log
|
|
|
|
for _, a := range data.MessageEvents {
|
|
|
|
fields := make([]*gen.Tag, 0, len(a.Attributes))
|
|
|
|
for _, kv := range a.Attributes {
|
2019-10-17 18:59:30 +02:00
|
|
|
tag := keyValueToTag(kv)
|
2019-09-09 23:59:39 +02:00
|
|
|
if tag != nil {
|
|
|
|
fields = append(fields, tag)
|
|
|
|
}
|
|
|
|
}
|
2019-12-18 20:13:05 +02:00
|
|
|
fields = append(fields, getStringTag("name", a.Name))
|
2019-09-09 23:59:39 +02:00
|
|
|
logs = append(logs, &gen.Log{
|
2019-09-25 22:22:33 +02:00
|
|
|
Timestamp: a.Time.UnixNano() / 1000,
|
2019-09-09 23:59:39 +02:00
|
|
|
Fields: fields,
|
|
|
|
})
|
|
|
|
}
|
2019-10-07 18:40:36 +02:00
|
|
|
|
|
|
|
var refs []*gen.SpanRef
|
|
|
|
for _, link := range data.Links {
|
|
|
|
refs = append(refs, &gen.SpanRef{
|
2019-10-23 08:01:33 +02:00
|
|
|
TraceIdHigh: int64(binary.BigEndian.Uint64(link.TraceID[0:8])),
|
|
|
|
TraceIdLow: int64(binary.BigEndian.Uint64(link.TraceID[8:16])),
|
2019-10-28 19:05:06 +02:00
|
|
|
SpanId: int64(binary.BigEndian.Uint64(link.SpanID[:])),
|
2019-10-07 18:40:36 +02:00
|
|
|
// TODO(paivagustavo): properly set the reference type when specs are defined
|
|
|
|
// see https://github.com/open-telemetry/opentelemetry-specification/issues/65
|
|
|
|
RefType: gen.SpanRefType_CHILD_OF,
|
|
|
|
})
|
|
|
|
}
|
2019-09-09 23:59:39 +02:00
|
|
|
|
|
|
|
return &gen.Span{
|
2019-10-23 08:01:33 +02:00
|
|
|
TraceIdHigh: int64(binary.BigEndian.Uint64(data.SpanContext.TraceID[0:8])),
|
|
|
|
TraceIdLow: int64(binary.BigEndian.Uint64(data.SpanContext.TraceID[8:16])),
|
2019-10-28 19:05:06 +02:00
|
|
|
SpanId: int64(binary.BigEndian.Uint64(data.SpanContext.SpanID[:])),
|
|
|
|
ParentSpanId: int64(binary.BigEndian.Uint64(data.ParentSpanID[:])),
|
2019-09-09 23:59:39 +02:00
|
|
|
OperationName: data.Name, // TODO: if span kind is added then add prefix "Sent"/"Recv"
|
2019-09-25 23:37:36 +02:00
|
|
|
Flags: int32(data.SpanContext.TraceFlags),
|
2019-09-09 23:59:39 +02:00
|
|
|
StartTime: data.StartTime.UnixNano() / 1000,
|
|
|
|
Duration: data.EndTime.Sub(data.StartTime).Nanoseconds() / 1000,
|
|
|
|
Tags: tags,
|
|
|
|
Logs: logs,
|
2019-10-07 18:40:36 +02:00
|
|
|
References: refs,
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-18 05:25:03 +02:00
|
|
|
func keyValueToTag(keyValue label.KeyValue) *gen.Tag {
|
2019-09-25 22:22:33 +02:00
|
|
|
var tag *gen.Tag
|
2020-05-14 01:06:03 +02:00
|
|
|
switch keyValue.Value.Type() {
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.STRING:
|
2020-05-14 01:06:03 +02:00
|
|
|
s := keyValue.Value.AsString()
|
2019-09-25 22:22:33 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VStr: &s,
|
2019-09-25 22:22:33 +02:00
|
|
|
VType: gen.TagType_STRING,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.BOOL:
|
2020-05-14 01:06:03 +02:00
|
|
|
b := keyValue.Value.AsBool()
|
2019-09-25 22:22:33 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VBool: &b,
|
2019-09-25 22:22:33 +02:00
|
|
|
VType: gen.TagType_BOOL,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.INT32:
|
2020-05-14 01:06:03 +02:00
|
|
|
i := int64(keyValue.Value.AsInt32())
|
2019-09-25 22:22:33 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VLong: &i,
|
2019-09-25 22:22:33 +02:00
|
|
|
VType: gen.TagType_LONG,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.INT64:
|
2020-05-14 01:06:03 +02:00
|
|
|
i := keyValue.Value.AsInt64()
|
2019-10-31 00:01:19 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VLong: &i,
|
|
|
|
VType: gen.TagType_LONG,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.UINT32:
|
2020-07-17 18:00:58 +02:00
|
|
|
i := int64(keyValue.Value.AsUint32())
|
|
|
|
tag = &gen.Tag{
|
|
|
|
Key: string(keyValue.Key),
|
|
|
|
VLong: &i,
|
|
|
|
VType: gen.TagType_LONG,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.UINT64:
|
2020-07-17 18:00:58 +02:00
|
|
|
// we'll ignore the value if it overflows
|
|
|
|
if i := int64(keyValue.Value.AsUint64()); i >= 0 {
|
|
|
|
tag = &gen.Tag{
|
|
|
|
Key: string(keyValue.Key),
|
|
|
|
VLong: &i,
|
|
|
|
VType: gen.TagType_LONG,
|
|
|
|
}
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.FLOAT32:
|
2020-05-14 01:06:03 +02:00
|
|
|
f := float64(keyValue.Value.AsFloat32())
|
2019-10-31 00:01:19 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VDouble: &f,
|
|
|
|
VType: gen.TagType_DOUBLE,
|
|
|
|
}
|
2020-08-18 05:25:03 +02:00
|
|
|
case label.FLOAT64:
|
2020-05-14 01:06:03 +02:00
|
|
|
f := keyValue.Value.AsFloat64()
|
2019-09-25 22:22:33 +02:00
|
|
|
tag = &gen.Tag{
|
2020-05-14 01:06:03 +02:00
|
|
|
Key: string(keyValue.Key),
|
2019-10-31 00:01:19 +02:00
|
|
|
VDouble: &f,
|
2019-09-25 22:22:33 +02:00
|
|
|
VType: gen.TagType_DOUBLE,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return tag
|
|
|
|
}
|
|
|
|
|
|
|
|
func getInt64Tag(k string, i int64) *gen.Tag {
|
|
|
|
return &gen.Tag{
|
|
|
|
Key: k,
|
|
|
|
VLong: &i,
|
|
|
|
VType: gen.TagType_LONG,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getStringTag(k, s string) *gen.Tag {
|
|
|
|
return &gen.Tag{
|
|
|
|
Key: k,
|
|
|
|
VStr: &s,
|
|
|
|
VType: gen.TagType_STRING,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getBoolTag(k string, b bool) *gen.Tag {
|
|
|
|
return &gen.Tag{
|
|
|
|
Key: k,
|
|
|
|
VBool: &b,
|
|
|
|
VType: gen.TagType_BOOL,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 23:59:39 +02:00
|
|
|
// Flush waits for exported trace spans to be uploaded.
|
|
|
|
//
|
|
|
|
// This is useful if your program is ending and you do not want to lose recent spans.
|
|
|
|
func (e *Exporter) Flush() {
|
|
|
|
e.bundler.Flush()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Exporter) upload(spans []*gen.Span) error {
|
|
|
|
batch := &gen.Batch{
|
|
|
|
Spans: spans,
|
|
|
|
Process: e.process,
|
|
|
|
}
|
|
|
|
|
2019-10-04 21:07:42 +02:00
|
|
|
return e.uploader.upload(batch)
|
2019-09-09 23:59:39 +02:00
|
|
|
}
|