Code Monkey home page Code Monkey logo

jaeger-client-go's Introduction

GoDoc Build Status Coverage Status OpenTracing 1.0 Enabled

๐Ÿ›‘ This library is DEPRECATED!

No new pull requests are accepted except for security fixes.

We urge all users to migrate to OpenTelemetry. Please refer to the notice in the documentation for details.

Jaeger Bindings for Go OpenTracing API

Instrumentation library that implements an OpenTracing Go Tracer for Jaeger (https://jaegertracing.io).

IMPORTANT: The library's import path is based on its original location under github.com/uber. Do not try to import it as github.com/jaegertracing, it will not compile. We might revisit this in the next major release.

  • โœ… import "github.com/uber/jaeger-client-go"
  • โŒ import "github.com/jaegertracing/jaeger-client-go"

How to Contribute

Please see CONTRIBUTING.md.

Installation

Preferred

Add github.com/uber/jaeger-client-go to go.mod.

Old way

We recommended using a dependency manager like dep and semantic versioning when including this library into an application. For example, Jaeger backend imports this library like this:

[[constraint]]
  name = "github.com/uber/jaeger-client-go"
  version = "2.17"

If you instead want to use the latest version in master, you can pull it via go get. Note that during go get you may see build errors due to incompatible dependencies, which is why we recommend using semantic versions for dependencies. The error may be fixed by running make install (it will install dep if you don't have it):

go get -u github.com/uber/jaeger-client-go/
cd $GOPATH/src/github.com/uber/jaeger-client-go/
git submodule update --init --recursive
make install

Initialization

See tracer initialization examples in godoc and config/example_test.go.

There are two ways to create a tracer:

  • Using Configuration struct that allows declarative configuration. For example, you can populate that struct from a YAML/JSON config, or ask it to initialize itself using environment variables (see next section).
  • Using NewTracer() function that allows for full programmatic control of configuring the tracer using TracerOptions.

Environment variables

The tracer can be initialized with values coming from environment variables, if it is built from a config that was created via FromEnv(). None of the env vars are required and all of them can be overridden via direct setting of the property on the configuration object.

Property Description
JAEGER_SERVICE_NAME The service name.
JAEGER_AGENT_HOST The hostname for communicating with agent via UDP (default localhost).
JAEGER_AGENT_PORT The port for communicating with agent via UDP (default 6831).
JAEGER_ENDPOINT The HTTP endpoint for sending spans directly to a collector, i.e. http://jaeger-collector:14268/api/traces. If specified, the agent host/port are ignored.
JAEGER_USER Username to send as part of "Basic" authentication to the collector endpoint.
JAEGER_PASSWORD Password to send as part of "Basic" authentication to the collector endpoint.
JAEGER_REPORTER_LOG_SPANS Whether the reporter should also log the spans" true or false (default false).
JAEGER_REPORTER_MAX_QUEUE_SIZE The reporter's maximum queue size (default 100).
JAEGER_REPORTER_FLUSH_INTERVAL The reporter's flush interval, with units, e.g. 500ms or 2s (valid units; default 1s).
JAEGER_REPORTER_ATTEMPT_RECONNECTING_DISABLED When true, disables udp connection helper that periodically re-resolves the agent's hostname and reconnects if there was a change (default false).
JAEGER_REPORTER_ATTEMPT_RECONNECT_INTERVAL Controls how often the agent client re-resolves the provided hostname in order to detect address changes (valid units; default 30s).
JAEGER_SAMPLER_TYPE The sampler type: remote, const, probabilistic, ratelimiting (default remote). See also https://www.jaegertracing.io/docs/latest/sampling/.
JAEGER_SAMPLER_PARAM The sampler parameter (number).
JAEGER_SAMPLER_MANAGER_HOST_PORT (deprecated) The HTTP endpoint when using the remote sampler.
JAEGER_SAMPLING_ENDPOINT The URL for the sampling configuration server when using sampler type remote (default http://127.0.0.1:5778/sampling).
JAEGER_SAMPLER_MAX_OPERATIONS The maximum number of operations that the sampler will keep track of (default 2000).
JAEGER_SAMPLER_REFRESH_INTERVAL How often the remote sampler should poll the configuration server for the appropriate sampling strategy, e.g. "1m" or "30s" (valid units; default 1m).
JAEGER_TAGS A comma separated list of name=value tracer-level tags, which get added to all reported spans. The value can also refer to an environment variable using the format ${envVarName:defaultValue}.
JAEGER_TRACEID_128BIT Whether to enable 128bit trace-id generation, true or false. If not enabled, the SDK defaults to 64bit trace-ids.
JAEGER_DISABLED Whether the tracer is disabled or not. If true, the opentracing.NoopTracer is used (default false).
JAEGER_RPC_METRICS Whether to store RPC metrics, true or false (default false).

By default, the client sends traces via UDP to the agent at localhost:6831. Use JAEGER_AGENT_HOST and JAEGER_AGENT_PORT to send UDP traces to a different host:port. If JAEGER_ENDPOINT is set, the client sends traces to the endpoint via HTTP, making the JAEGER_AGENT_HOST and JAEGER_AGENT_PORT unused. If JAEGER_ENDPOINT is secured, HTTP basic authentication can be performed by setting the JAEGER_USER and JAEGER_PASSWORD environment variables.

Closing the tracer via io.Closer

The constructor function for Jaeger Tracer returns the tracer itself and an io.Closer instance. It is recommended to structure your main() so that it calls the Close() function on the closer before exiting, e.g.

tracer, closer, err := cfg.NewTracer(...)
defer closer.Close()

This is especially useful for command-line tools that enable tracing, as well as for the long-running apps that support graceful shutdown. For example, if your deployment system sends SIGTERM instead of killing the process and you trap that signal to do a graceful exit, then having defer closer.Close() ensures that all buffered spans are flushed.

Metrics & Monitoring

The tracer emits a number of different metrics, defined in metrics.go. The monitoring backend is expected to support tag-based metric names, e.g. instead of statsd-style string names like counters.my-service.jaeger.spans.started.sampled, the metrics are defined by a short name and a collection of key/value tags, for example: name:jaeger.traces, state:started, sampled:y. See metrics.go file for the full list and descriptions of emitted metrics.

The monitoring backend is represented by the metrics.Factory interface from package "github.com/uber/jaeger-lib/metrics". An implementation of that interface can be passed as an option to either the Configuration object or the Tracer constructor, for example:

import (
    "github.com/uber/jaeger-client-go/config"
    "github.com/uber/jaeger-lib/metrics/prometheus"
)

    metricsFactory := prometheus.New()
    tracer, closer, err := config.Configuration{
        ServiceName: "your-service-name",
    }.NewTracer(
        config.Metrics(metricsFactory),
    )

By default, a no-op metrics.NullFactory is used.

Logging

The tracer can be configured with an optional logger, which will be used to log communication errors, or log spans if a logging reporter option is specified in the configuration. The logging API is abstracted by the Logger interface. A logger instance implementing this interface can be set on the Config object before calling the New method.

Besides the zap implementation bundled with this package there is also a go-kit one in the jaeger-lib repository.

Instrumentation for Tracing

Since this tracer is fully compliant with OpenTracing API 1.0, all code instrumentation should only use the API itself, as described in the opentracing-go documentation.

Features

Reporters

A "reporter" is a component that receives the finished spans and reports them to somewhere. Under normal circumstances, the Tracer should use the default RemoteReporter, which sends the spans out of process via configurable "transport". For testing purposes, one can use an InMemoryReporter that accumulates spans in a buffer and allows to retrieve them for later verification. Also available are NullReporter, a no-op reporter that does nothing, a LoggingReporter which logs all finished spans using their String() method, and a CompositeReporter that can be used to combine more than one reporter into one, e.g. to attach a logging reporter to the main remote reporter.

Span Reporting Transports

The remote reporter uses "transports" to actually send the spans out of process. Currently the supported transports include:

Sampling

The tracer does not record all spans, but only those that have the sampling bit set in the flags. When a new trace is started and a new unique ID is generated, a sampling decision is made whether this trace should be sampled. The sampling decision is propagated to all downstream calls via the flags field of the trace context. The following samplers are available:

  1. RemotelyControlledSampler uses one of the other simpler samplers and periodically updates it by polling an external server. This allows dynamic control of the sampling strategies.
  2. ConstSampler always makes the same sampling decision for all trace IDs. it can be configured to either sample all traces, or to sample none.
  3. ProbabilisticSampler uses a fixed sampling rate as a probability for a given trace to be sampled. The actual decision is made by comparing the trace ID with a random number multiplied by the sampling rate.
  4. RateLimitingSampler can be used to allow only a certain fixed number of traces to be sampled per second.

Delayed sampling

Version 2.20 introduced the ability to delay sampling decisions in the life cycle of the root span. It involves several features and architectural changes:

  • Shared sampling state: the sampling state is shared across all local (i.e. in-process) spans for a given trace.
  • New SamplerV2 API allows the sampler to be called at multiple points in the life cycle of a span:
    • on span creation
    • on overwriting span operation name
    • on setting span tags
    • on finishing the span
  • Final/non-final sampling state: the new SamplerV2 API allows the sampler to indicate if the negative sampling decision is final or not (positive sampling decisions are always final). If the decision is not final, the sampler will be called again on further span life cycle events, like setting tags.

These new features are used in the experimental x.TagMatchingSampler, which can sample a trace based on a certain tag added to the root span or one of its local (in-process) children. The sampler can be used with another experimental x.PrioritySampler that allows multiple samplers to try to make a sampling decision, in a certain priority order.

Baggage Injection

The OpenTracing spec allows for baggage, which are key value pairs that are added to the span context and propagated throughout the trace. An external process can inject baggage by setting the special HTTP Header jaeger-baggage on a request:

curl -H "jaeger-baggage: key1=value1, key2=value2" http://myhost.com

Baggage can also be programatically set inside your service:

if span := opentracing.SpanFromContext(ctx); span != nil {
    span.SetBaggageItem("key", "value")
}

Another service downstream of that can retrieve the baggage in a similar way:

if span := opentracing.SpanFromContext(ctx); span != nil {
    val := span.BaggageItem("key")
    println(val)
}

Debug Traces (Forced Sampling)

Programmatically

The OpenTracing API defines a sampling.priority standard tag that can be used to affect the sampling of a span and its children:

import (
    "github.com/opentracing/opentracing-go"
    "github.com/opentracing/opentracing-go/ext"
)

span := opentracing.SpanFromContext(ctx)
ext.SamplingPriority.Set(span, 1)

Via HTTP Headers

Jaeger Tracer also understands a special HTTP Header jaeger-debug-id, which can be set in the incoming request, e.g.

curl -H "jaeger-debug-id: some-correlation-id" http://myhost.com

When Jaeger sees this header in the request that otherwise has no tracing context, it ensures that the new trace started for this request will be sampled in the "debug" mode (meaning it should survive all downsampling that might happen in the collection pipeline), and the root span will have a tag as if this statement was executed:

span.SetTag("jaeger-debug-id", "some-correlation-id")

This allows using Jaeger UI to find the trace by this tag.

Zipkin HTTP B3 compatible header propagation

Jaeger Tracer supports Zipkin B3 Propagation HTTP headers, which are used by a lot of Zipkin tracers. This means that you can use Jaeger in conjunction with e.g. these OpenZipkin tracers.

However it is not the default propagation format, see here how to set it up.

SelfRef

Jaeger Tracer supports an additional span reference type call Self, which was proposed to the OpenTracing Specification (opentracing/specification#81) but not yet accepted. This allows the caller to provide an already created SpanContext when starting a new span. The Self reference bypasses trace and span id generation, as well as sampling decisions (i.e. the sampling bit in the SpanContext.flags must be set appropriately by the caller).

The Self reference supports the following use cases:

  • the ability to provide externally generated trace and span IDs
  • appending data to the same span from different processes, such as loading and continuing spans/traces from offline (ie log-based) storage

Usage requires passing in a SpanContext and the jaeger.Self reference type:

span := tracer.StartSpan(
    "continued_span",
    jaeger.SelfRef(yourSpanContext),
)
...
defer span.Finish()

License

Apache 2.0 License.

jaeger-client-go's People

Contributors

aaronjheng avatar albertteoh avatar bboreham avatar black-adder avatar bobrik avatar dieterbe avatar douglas-reid avatar eundoosong avatar funny-falcon avatar gouthamve avatar guanwenbogit avatar guo0693 avatar isaachier avatar jelgt2011 avatar joe-elliott avatar lastchiliarch avatar mkabischev avatar mpuncel avatar nabowler avatar nhatthm avatar nikokvcs avatar objectiser avatar pavolloffay avatar raidancampbell avatar sagikazarmark avatar skidder avatar thepaulm avatar vprithvi avatar yurishkuro avatar zcahana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jaeger-client-go's Issues

No span-id header definition available ?

Hi,
I want to use textMapPropagator to propagate span by HTTP call.
I can find "uber-trace-id" for present "trace-id" in opentracing-api,
but no available for "span-id".

Problems with 'glide get'

I have the problem with getting the package using glide get. It has some issues with VCS.

Using go get`` instead also doesn't work because there are compilation errors.

$ glide get github.com/uber/jaeger-client-go
[INFO]	Preparing to install 1 package.
[INFO]	Attempting to get package github.com/uber/jaeger-client-go
[INFO]	--> Gathering release information for github.com/uber/jaeger-client-go
[INFO]	The package github.com/uber/jaeger-client-go appears to have Semantic Version releases (http://semver.org). 
[INFO]	The latest release is v2.9.0. You are currently not using a release. Would you like
[INFO]	to use this release? Yes (Y) or No (N)
y
[INFO]	The package github.com/uber/jaeger-client-go appears to use semantic versions (http://semver.org).
[INFO]	Would you like to track the latest minor or patch releases (major.minor.patch)?
[INFO]	Tracking minor version releases would use '>= 2.9.0, < 3.0.0' ('^2.9.0'). Tracking patch version
[INFO]	releases would use '>= 2.9.0, < 2.10.0' ('~2.9.0'). For more information on Glide versions
[INFO]	and ranges see https://glide.sh/docs/versions
[INFO]	Minor (M), Patch (P), or Skip Ranges (S)?
p
[INFO]	--> Adding github.com/uber/jaeger-client-go to your configuration with the version ~2.9.0
[INFO]	Downloading dependencies. Please wait...
[INFO]	--> Fetching updates for github.com/uber/jaeger-client-go.
[INFO]	--> Fetching updates for github.com/koding/websocketproxy.
[INFO]	--> Fetching updates for bazil.org/fuse.
[INFO]	--> Fetching updates for github.com/pborman/uuid.
[INFO]	--> Fetching updates for github.com/olekukonko/ts.
[INFO]	--> Fetching updates for github.com/visionect/gotk3.
[INFO]	--> Fetching updates for github.com/gorilla/mux.
[INFO]	--> Fetching updates for golang.org/x/net.
[INFO]	--> Fetching updates for gopkg.in/check.v1.
[INFO]	--> Fetching updates for github.com/gorilla/websocket.
[INFO]	--> Fetching updates for github.com/ugorji/go.
[INFO]	--> Fetching updates for gopkg.in/v1/yaml.
[INFO]	--> Fetching updates for github.com/smartystreets/goconvey.
[INFO]	--> Fetching updates for launchpad.net/gocheck.
[INFO]	--> Fetching updates for github.com/ugorji/go-msgpack.
[INFO]	--> Fetching updates for github.com/stretchr/testify.
[INFO]	Resolving imports
[INFO]	--> Fetching updates for golang.org/x/sys.
[INFO]	--> Fetching updates for golang.org/x/text.
[INFO]	--> Fetching updates for github.com/alecthomas/units.
[INFO]	--> Fetching updates for github.com/nicksnyder/go-i18n.
[INFO]	Found Godeps.json file in /home/miha/.glide/cache/src/https-github.com-stretchr-testify
[INFO]	--> Parsing Godeps metadata...
[INFO]	--> Fetching updates for github.com/davecgh/go-spew.
[INFO]	--> Setting version for github.com/davecgh/go-spew to 6d212800a42e8ab5c146b8ace3490ee17e5225f9.
[INFO]	--> Fetching updates for github.com/pmezard/go-difflib.
[INFO]	--> Setting version for github.com/pmezard/go-difflib to d8ed2627bdf02c080bf22230dbb337003b7aba2d.
[INFO]	--> Fetching thrift.
[WARN]	Unable to checkout thrift
[ERROR]	Error looking for thrift: Cannot detect VCS
[INFO]	--> Fetching thrifttest.
[WARN]	Unable to checkout thrifttest
[ERROR]	Error looking for thrifttest: Cannot detect VCS
[INFO]	--> Fetching gen/stress.
[WARN]	Unable to checkout gen/stress
[ERROR]	Error looking for gen/stress: Cannot detect VCS
[INFO]	--> Fetching gen/thrifttest.
[WARN]	Unable to checkout gen/thrifttest
[ERROR]	Error looking for gen/thrifttest: Cannot detect VCS
[INFO]	--> Fetching shared.
[WARN]	Unable to checkout shared
[ERROR]	Error looking for shared: Cannot detect VCS
[INFO]	--> Fetching tutorial.
[WARN]	Unable to checkout tutorial
[ERROR]	Error looking for tutorial: Cannot detect VCS
[INFO]	--> Fetching updates for github.com/mattn/go-isatty.
[INFO]	--> Fetching updates for golang.org/x/tools.
[INFO]	--> Fetching updates for honnef.co/go/tools.
[INFO]	--> Fetching updates for github.com/kisielk/gotool.
[INFO]	--> Fetching container/vector.
[WARN]	Unable to checkout container/vector
[ERROR]	Error looking for container/vector: Cannot detect VCS
[INFO]	--> Fetching github.com/kless/freecrypto.
Username for 'https://github.com': ^C

Enviorment:

$ uname -a
Linux miha-work2 4.4.0-77-generic #98-Ubuntu SMP Wed Apr 26 08:34:02 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ go version
go version go1.9.1 linux/amd64
$ glide -v
glide version v0.12.3

Race condition when reporter is closed

Rebooking #239 / #241 as an issue.

There's a race condition in remoteReporter.Report() where if both r.closed and r.queue channels are closed, the switch stmt will pick one arbitrarily causing a panic if Report is called post close.

Did not Implement Reference 'FollowsFrom'?

Hi,
'FollowsFrom' is defined in opentracing's specification, but Jaeger-client only implemented 'ChildOf'.
I suggess the reason is zipkin's trace system do not support the reference.
Will it be implemented in future?

Version 2.6 release was not backwards compatible

I'd like us to be more careful when making changes and cutting releases as minor releases. Version 2.6 contained the following change:
#129

This change contains a renaming of ClientOptions to Options. I think the renaming was a good step, but when we make changes like this, we should bump the major version.

Can we enforce this in reviews @black-adder and @yurishkuro?

Integration with zap logger

The jaeger tracer defines a jaeger logger interface here https://github.com/uber/jaeger-client-go/blob/master/logger.go#L29.

Is there a plan to replace this with zap logger directly? For UberFx, I have a wrapper for jaeger logger that calls zap under the hood https://github.com/uber-go/fx/blob/master/tracing/tracer.go#L69. This also gets a bit messy because zap expects even arguments to the log message so I ended up appending a key string just to make it even.

@akshayjshah @sectioneight @anuptalwalkar @yurishkuro

Support Zipkin B3 propagation format

Does the Jaeger client support baggage headers set by an openzipkin agent? Namely:

'X-B3-TraceId',
'X-B3-SpanId',
'X-B3-ParentSpanId',
'X-B3-Sampled',
'X-B3-Flags'

Need interface to verify tracer implements Jaeger

In YARPC we need the ability to test whether the tracer obtained from a span implements jager.tracer, so that we can be sure that tchannel.InjectOutboundSpan will not panic when called, as opposed to NoopTracer or another.

SIGSEGV in jaeger-client-go/reporter.go

I was try to migrate from the zipkin backend to jaeger, so everything I need is to swap the tracer.

To init the tracer:

// Sample configuration for testing. Use constant sampling to sample every trace
// and enable LogSpan to log every span via configured Logger.
config := jaegercfg.Configuration{
	Sampler: &jaegercfg.SamplerConfig{
		Type:  jaeger.SamplerTypeConst,
		Param: 1,
	},
	Reporter: &jaegercfg.ReporterConfig{
	LogSpans: true,
		LocalAgentHostPort: "jaeger-all-in-one-agent.fission:5775",
	},
}
// Example logger and metrics factory. Use github.com/uber/jaeger-client-go/log
// and github.com/uber/jaeger-lib/metrics respectively to bind to real logging and metrics
// frameworks.
jLogger := jaegerlog.StdLogger
jMetricsFactory := metrics.NullFactory
// Initialize tracer with a logger and a metrics factory
closer, err := config.InitGlobalTracer(
	"router",
	jaegercfg.Logger(jLogger),
	jaegercfg.Metrics(jMetricsFactory),
)
if err != nil {
	log.Printf("Could not initialize jaeger tracer: %s", err.Error())
	return
}
defer closer.Close()

And then error occured:

2017-05-31T04:36:39.214604075Z panic: runtime error: invalid memory address or nil pointer dereference
2017-05-31T04:36:39.214734078Z [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x80492cc]
2017-05-31T04:36:39.214753293Z 
2017-05-31T04:36:39.214814925Z goroutine 16 [running]:
2017-05-31T04:36:39.214944289Z sync/atomic.AddUint64(0x19f3a424, 0xffffffff, 0xffffffff, 0x19b1c700, 0x1)
2017-05-31T04:36:39.215025990Z 	/home/yqf/bin/go/src/sync/atomic/asm_386.s:112 +0xc
2017-05-31T04:36:39.215083702Z github.com/fission/fission/vendor/github.com/uber/jaeger-client-go.(*remoteReporter).processQueue(0x19f3a400)
2017-05-31T04:36:39.215193739Z 	/home/yqf/dev/mygo/src/github.com/fission/fission/vendor/github.com/uber/jaeger-client-go/reporter.go:234 +0x107
2017-05-31T04:36:39.215252715Z created by github.com/fission/fission/vendor/github.com/uber/jaeger-client-go.NewRemoteReporter
2017-05-31T04:36:39.215361183Z 	/home/yqf/dev/mygo/src/github.com/fission/fission/vendor/github.com/uber/jaeger-client-go/reporter.go:200 

When the error occured, r.queueLength is 0.
Appreciate any helps.

errors when `go get`'ing library

~ โฏโฏโฏ go version                                                                                                                                                                             โŽ
go version go1.8.3 linux/amd64
~ โฏโฏโฏ go get -u github.com/uber/jaeger-client-go/
# github.com/uber/jaeger-client-go/thrift-gen/jaeger
go/src/github.com/uber/jaeger-client-go/thrift-gen/jaeger/agent.go:101: cannot use agentProcessorEmitBatch literal (type *agentProcessorEmitBatch) as type thrift.TProcessorFunction in assignment:
	*agentProcessorEmitBatch does not implement thrift.TProcessorFunction (wrong type for Process method)
		have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
		want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
go/src/github.com/uber/jaeger-client-go/thrift-gen/jaeger/agent.go:111: not enough arguments in call to processor.Process
	have (int32, thrift.TProtocol, thrift.TProtocol)
	want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)
# github.com/uber/jaeger-client-go/thrift-gen/sampling
go/src/github.com/uber/jaeger-client-go/thrift-gen/sampling/samplingmanager.go:147: cannot use samplingManagerProcessorGetSamplingStrategy literal (type *samplingManagerProcessorGetSamplingStrategy) as type thrift.TProcessorFunction in assignment:
	*samplingManagerProcessorGetSamplingStrategy does not implement thrift.TProcessorFunction (wrong type for Process method)
		have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
		want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
go/src/github.com/uber/jaeger-client-go/thrift-gen/sampling/samplingmanager.go:157: not enough arguments in call to processor.Process
	have (int32, thrift.TProtocol, thrift.TProtocol)
	want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)
# github.com/uber/jaeger-client-go/thrift-gen/zipkincore
go/src/github.com/uber/jaeger-client-go/thrift-gen/zipkincore/zipkincollector.go:147: cannot use zipkinCollectorProcessorSubmitZipkinBatch literal (type *zipkinCollectorProcessorSubmitZipkinBatch) as type thrift.TProcessorFunction in assignment:
	*zipkinCollectorProcessorSubmitZipkinBatch does not implement thrift.TProcessorFunction (wrong type for Process method)
		have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
		want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
go/src/github.com/uber/jaeger-client-go/thrift-gen/zipkincore/zipkincollector.go:157: not enough arguments in call to processor.Process
	have (int32, thrift.TProtocol, thrift.TProtocol)
	want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)

Support a limit on the number of logs

Cf. opentracing/basictracer-go#39

// MaxLogsPerSpan limits the number of Logs in a span if set to a non-zero
// value. If a span has more logs than this value, logs in the middle of the
// span timeline are dropped as necessary and replaced with a log describing
// how many were dropped.
//
// About half of the MaxLogPerSpan logs kept are the oldest logs, and about
// half are the newest logs.
func (tracerOptions) MaxLogsPerSpan(maxLogsPerSpan int) TracerOption {
    return func(tracer *tracer) {
        tracer.options.maxLogsPerSpan = maxLogsPerSpan
    }
}

Add an example about creating a new Tracer

Hey,
when I got started with this go lib I couldn't find any examples on how to create a new Tracer.
To get started I basically want to sample everything and send all traces to localhost.

I hope to achieve that with this code now:

tracerTransport, err := jaeger.NewUDPTransport("", 0)
if err != nil {
	return err
}
tracer, traceCloser := jaeger.NewTracer("api", jaeger.NewConstSampler(false), jaeger.NewRemoteReporter(tracerTransport))

I'm not really sure if that's correct.

I really dig Jaeger so far! Thanks!

initalizing package a bit tricky due to godoc

hello,
reading the readme at https://github.com/uber/jaeger-client-go,
it looks like after getting the library , the first thing to do is to write initializing code.
the readme links to examples at https://godoc.org/github.com/uber/jaeger-client-go/config#pkg-examples

note that those examples refer to imported packages like jaegerlog, jaegercfg, metrics. there is some friction here to get started with this example code as it's not clear where those imported packages come from, i resorted to go grepping around in the hotrod & jaeger repos to find out which packages contain the referenced things, so that I know which things to import and using which alias

e.g. it turns out something like:

	jaeger "github.com/uber/jaeger-client-go" // perhaps this one should be obvious
	jaegercfg "github.com/uber/jaeger-client-go/config" // not obvious
	jaegerlog "github.com/uber/jaeger-client-go/log" // not obvious

perhaps this can be streamlined to make onboarding of new users smoother.

crossdock client crashes

While writing crossdock tests for the C++ client, I came across this crash in the Go client:

โœ— [trace] goโ†’ (s1name=cpp s2name=cpp s2transport=http s3name=cpp s3transport=http sampled=false) โ‡’ runtime error: invalid memory address or nil pointer dereference
goroutine 17 [running]:
runtime/debug.Stack(0xc42005fc38, 0x748460, 0xc42000a030)
	/home/travis/.gimme/versions/go1.7.linux.amd64/src/runtime/debug/stack.go:24 +0x79
github.com/uber/jaeger-client-go/vendor/github.com/crossdock/crossdock-go.Run.func1.1(0xc42010e100, 0xc420138060)
	/home/travis/gopath/src/github.com/uber/jaeger-client-go/vendor/github.com/crossdock/crossdock-go/run.go:48 +0x78
panic(0x748460, 0xc42000a030)
	/home/travis/.gimme/versions/go1.7.linux.amd64/src/runtime/panic.go:458 +0x243
github.com/uber/jaeger-client-go/crossdock/client.(*Client).trace(0xc42011c050, 0x9557e0, 0xc42010e100)
	/home/travis/gopath/src/github.com/uber/jaeger-client-go/crossdock/client/trace.go:72 +0x738

some question with source code

Hi๏ผŒI have some doubt with jaeger.SpanID. See

package main
import (
	"fmt"
	"github.com/uber/jaeger-client-go"
)

type MySpanId uint64

func main()  {
	var i uint64
	i = 9871623611823

	fmt.Printf("jaeger.SpanID %+v \n", jaeger.SpanID(i))
	fmt.Printf("MySpanId %+v \n", MySpanId(i))
}

result :

jaeger.SpanID 8fa6a9e65af 
MySpanId 9871623611823 

Result is different.
How it work ? I want to know it and implementation with php.
I development php client for jaeger Jaeger-php and want tracing each other with go .
thinks.

Make tracing headers configurable

Please, allow to users configure tracing HTTP headers & rpc tracing fields.
Now them are hardcoded in constants, for example "uber-trace-id"

Wrong imports after repo move

~/.../github.com/jaegertracing/jaeger-client-go [jaeger-client-go:master]$ go build
baggage_setter.go:20:2: use of internal package not allowed
zipkin_thrift_span.go:24:2: use of internal package not allowed
~/.../github.com/jaegertracing/jaeger-client-go [jaeger-client-go:master]$ 

...because the import is still based on github.com/uber/jaeger-client-go

Do not send spans to the reporter after it's been closed

@kriskowal ran into an issue where Jaeger panics with "send on closed channel" because the span.Finish() -> tracer.Report() -> reporter.Report() chain is invoked after the tracer has been closed (due to async nature of tchannel handlers).

We could use a lock in the Tracer to avoid sending spans to the reporter once the reporter is closed. But it's rather an unfortunate performance hit for an issue that in practice only occurs in tests.

Why not tell the all logs on `OnFinish`?

jaeger-client-go/span.go

Lines 182 to 186 in b7bacc4

func (s *Span) FinishWithOptions(options opentracing.FinishOptions) {
if options.FinishTime.IsZero() {
options.FinishTime = s.tracer.timeNow()
}
s.observer.OnFinish(options)

Sometimes, we try to use OnSetTag to check whether we should do something.
If yes, we would get some logs to help doing in OnFinish.
So why not append FinishOptions.LogRecords with span.logs.

And there is no public method to get the span's logs.
Maybe public a method is the best choice.

import error

Simply importing the library causes this:

Go 1.9, Fedora 25.

# github.com/uber/jaeger-client-go/thrift-gen/sampling
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/sampling/samplingmanager.go:101:15: cannot assign 1 values to 2 variables
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/sampling/samplingmanager.go:147:44: cannot use samplingManagerProcessorGetSamplingStrategy literal (type *samplingManagerProcessorGetSamplingStrategy) as type thrift.TProcessorFunction in assignment:
        *samplingManagerProcessorGetSamplingStrategy does not implement thrift.TProcessorFunction (wrong type for Process method)
                have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
                want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/sampling/samplingmanager.go:157:27: not enough arguments in call to processor.Process
        have (int32, thrift.TProtocol, thrift.TProtocol)
        want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)
# github.com/uber/jaeger-client-go/thrift-gen/jaeger
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/jaeger/agent.go:101:34: cannot use agentProcessorEmitBatch literal (type *agentProcessorEmitBatch) as type thrift.TProcessorFunction in assignment:
        *agentProcessorEmitBatch does not implement thrift.TProcessorFunction (wrong type for Process method)
                have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
                want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/jaeger/agent.go:111:27: not enough arguments in call to processor.Process
        have (int32, thrift.TProtocol, thrift.TProtocol)
        want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)
# github.com/uber/jaeger-client-go/thrift-gen/zipkincore
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/zipkincore/zipkincollector.go:101:15: cannot assign 1 values to 2 variables
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/zipkincore/zipkincollector.go:147:42: cannot use zipkinCollectorProcessorSubmitZipkinBatch literal (type *zipkinCollectorProcessorSubmitZipkinBatch) as type thrift.TProcessorFunction in assignment:
        *zipkinCollectorProcessorSubmitZipkinBatch does not implement thrift.TProcessorFunction (wrong type for Process method)
                have Process(int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
                want Process(context.Context, int32, thrift.TProtocol, thrift.TProtocol) (bool, thrift.TException)
../../../gopath/src/github.com/uber/jaeger-client-go/thrift-gen/zipkincore/zipkincollector.go:157:27: not enough arguments in call to processor.Process
        have (int32, thrift.TProtocol, thrift.TProtocol)
        want (context.Context, int32, thrift.TProtocol, thrift.TProtocol)

Move to github.com/jaegertracing

Per jaegertracing/jaeger#409

  • Move the repo
  • Re-register the repo with Travis
  • Re-register the repo with Coveralls/CodeCov
  • Update the links to badges in the README
  • Add DCO file
  • Add sign-off checker bot
  • Update CONTRIBUTING instructions to require sign-off
  • Update to Apache license
    • Replace LICENSE file
    • Update CONTRIBUTING instructions and references to license in the README
    • Update the existing license headers (keep Uber copyright)
    • Update the check-license script (new files get The Jaeger Authors copyright)

Jaeger should create a root span for incoming requests with baggage but without a trace.

It is currently possible to use yab to submit baggage.

#!/bin/bash
TRACE=$(xxd -ps -l 8 < /dev/urandom)
SPAN=$(xxd -ps -l 8 < /dev/urandom)
PARENT=$(xxd -ps -l 8 < /dev/zero)
TRACEID="$TRACE:$SPAN:$PARENT:1"
UUID=$1
TENANCY=$2
yab yarpc-prober Prober::probe \
    -t /usr/share/uber-idl/code.uber.internal/infra/yarpc-prober/prober.thrift \
    --body '{"UUID":"'"$UUID"'"}' \
    --headers '{"$tracing$context-tenancy":"'"$TENANCY"'","$tracing$trace-id":"'"$TRACEID"'"}' \
| jq .

For tools like yab, and even simply curl for simple HTTP services, it should be simpler to submit baggage.

#!/bin/bash
UUID=$1
TENANCY=$2
yab yarpc-prober Prober::probe \
    -t /usr/share/uber-idl/code.uber.internal/infra/yarpc-prober/prober.thrift \
    --body '{"UUID":"'"$UUID"'"}' \
    --headers '{"$tracing$context-tenancy":"'"$TENANCY"'"}' \
| jq .
#!/bin/bash
UUID=$1
TENANCY=$2
curl hostport
    -H "Rpc-Procedure: Prober::probe" \
    -H "Rpc-Service: prober" \
    -H "Rpc-Caller: "$USER:curl" \
    -H "Context-TTL-MS: 100" \
    -H "Context-Tenancy: $TENANCY" \
    -d '{"UUID":"'"$UUID"'"}' \
| jq .

More Comperhensive Reporters

Currently, there is little visibility into an Span, even from a Reporter which ought to be able to report/persist a span in it's entirety.

The over all changes required to make reporters more useful (for example, make it possible to write a custom log reporter for use in development), the BuildJaegerThrift func should be possible outside of the jaeger package, in other words, all the information about a span that is required to make BuildJaegerThrift happen is most often needed in reporters and should be somehow exported.

I believe, BuildJaegerThrift should exist on it's own transport/thrift package, and that would dictate other design considerations.

Thoughts?

go get fails due to internal package use from github.com/uber

There is still references to uber repository even repository is now located in github.com/jaegertracing/. This will cause go get github.com/jaegertracing/jaeger-client-goto fail due to

jaeger-client-go/baggage_setter.go:20:2: use of internal package not allowed
jaeger-client-go/zipkin_thrift_span.go:24:2: use of internal package not allowed

As they still reference to github.com/uber/jaeger-client-go/internal/baggage and github.com/uber/jaeger-client-go/internal/spanlog.

Also at least README.md and CONTRIBUTING.md references still to github.com/uber.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.