Giter VIP home page Giter VIP logo

opentracing-tutorial's Introduction

OpenTracing Tutorials

A collection of tutorials for the OpenTracing API (https://opentracing.io).

Update (Dec 8 2022): Since OpenTracing has been officially retired, I have archived this repository. The tutorials here are still useful when learning about distributed tracing, but using the OpenTelemetry API should be preferred over the OpenTracing API for new applications.

The blog post "Migrating from Jaeger client to OpenTelemetry SDK" can also be used as a reference on how to use the OpenTelemetry SDK as an OpenTracing tracer implementation.

Tutorials by Language

Also check out examples from the book Mastering Distributed Tracing:

Prerequisites

The tutorials are using CNCF Jaeger (https://jaegertracing.io) as the tracing backend. For this tutorial, we'll start Jaeger via Docker with the default in-memory storage, exposing only the required ports. We'll also enable "debug" level logging:

docker run \
  --rm \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 16686:16686 \
  jaegertracing/all-in-one:1.7 \
  --log-level=debug

Alternatively, Jaeger can be downloaded as a binary called all-in-one for different platforms from https://jaegertracing.io/download/.

Once the backend starts, the Jaeger UI will be accessible at http://localhost:16686.

opentracing-tutorial's People

Contributors

albertteoh avatar amiedeep avatar black-adder avatar dependabot[bot] avatar eest avatar flands avatar harnitsignalfx avatar impactmass avatar istrel avatar itsderek23 avatar jeehwancho avatar jordo1138 avatar jpkrohling avatar junminstorage avatar justinclift avatar lingnanlu avatar liurui-1 avatar marckk avatar navneetkatiyar avatar nickollascoelho avatar safris avatar saschaholesch avatar smlobo avatar swallowstalker avatar tiffon avatar tsl-karlp avatar vprithvi avatar wfhu avatar yaojingguo avatar yurishkuro 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

opentracing-tutorial's Issues

Make install failed

Hi,

Very cool material. I hope that I can use it to better understand Jaeger and opentracing.

However, I just tried it and got these errors when I run the make install. Seem like something wrong with using glide to install jaeger-go-client?

[INFO]	Downloading dependencies. Please wait...
[INFO]	--> Found desired version locally github.com/apache/thrift b2a4d4ae21c789b689dd162deb819665567f481c!
[INFO]	--> Found desired version locally github.com/codahale/hdrhistogram f8ad88b59a584afeee9d334eff879b104439117b!
[INFO]	--> Found desired version locally github.com/opentracing/opentracing-go 1949ddbfd147afd4d964a9f00b24eb291e0e7c38!
[INFO]	--> Found desired version locally github.com/uber/jaeger-client-go 3e3870040def0ebdaf65a003863fa64f5cb26139!
[INFO]	--> Found desired version locally github.com/uber/jaeger-lib 3b2a9ad2a045881ab7a0f81d465be54c8292ee4f!
[INFO]	--> Found desired version locally golang.org/x/net 3b993948b6f0e651ffb58ba135d8538a68b1cddf!
[INFO]	Setting references.
[INFO]	--> Setting version for github.com/codahale/hdrhistogram to f8ad88b59a584afeee9d334eff879b104439117b.
[INFO]	--> Setting version for github.com/uber/jaeger-client-go to 3e3870040def0ebdaf65a003863fa64f5cb26139.
[INFO]	--> Setting version for github.com/apache/thrift to b2a4d4ae21c789b689dd162deb819665567f481c.
[INFO]	--> Setting version for github.com/opentracing/opentracing-go to 1949ddbfd147afd4d964a9f00b24eb291e0e7c38.
[INFO]	--> Setting version for github.com/uber/jaeger-lib to 3b2a9ad2a045881ab7a0f81d465be54c8292ee4f.
[INFO]	--> Setting version for golang.org/x/net to 3b993948b6f0e651ffb58ba135d8538a68b1cddf.
[INFO]	Exporting resolved dependencies...
[INFO]	--> Exporting github.com/apache/thrift
[INFO]	--> Exporting github.com/opentracing/opentracing-go
[INFO]	--> Exporting github.com/uber/jaeger-lib
[INFO]	--> Exporting github.com/uber/jaeger-client-go
[INFO]	--> Exporting github.com/codahale/hdrhistogram
[INFO]	--> Exporting golang.org/x/net
[ERROR]	Export failed for github.com/uber/jaeger-client-go: Error while exporting submodule sources
[ERROR]	Unable to export dependencies to vendor directory: Error while exporting submodule sources

The system I am using is Ubuntu 17.04

The program of [java lesson 3 solution] is defective.

The source of the following "Formatter.java" is a problem.
If you look at the UI after execution, only three spans will be displayed.
It is necessary to display 5 spans.

Formatter.java

    try (JaegerTracer tracer = Tracing.init("formatter")) {
        new Formatter(tracer).run(args);
    }

By implementing it as described in the Readme, you can see five spans.

Tracer tracer = Tracing.init("formatter");
new Formatter(tracer).run(args);

The same applies to "Publisher.java".

Sincerely yours,
Kazuya Nishikura

Latest version of jaeger-client and opentracing for Java

Hi, I noticed that the versions of opentracing and jaeger-client being used is quite old. A lot of methods have changed and/or depricated.
I have successfully ported most of the methods to latest version but extract method, used in lib/Tracing.java is giving me issue -

ERROR] /home/prateek/workspace/research/opentracing-tutorial/java/src/main/java/lib/Tracing.java:[52,47] method extract in interface io.opentracing.Tracer cannot be applied to given types;
  required: io.opentracing.propagation.Format<C>,C
  found: io.opentracing.propagation.Format<io.opentracing.propagation.TextMap>,io.opentracing.propagation.TextMapExtractAdapter
  reason: inference variable C has incompatible bounds
    equality constraints: io.opentracing.propagation.TextMap
    lower bounds: io.opentracing.propagation.TextMapExtractAdapter

Could you update the tutorial to latest versions and/or help me with the issue?

set_tag is not updating tags and duration

New to opentracing, Try to explore opentracing and jaeger UI.
After gone through the lessons, With help of lesson01 solution https://github.com/yurishkuro/opentracing-tutorial/tree/master/python/lesson01/solution tried to include some logic with sleep to add some tags.

Recently added tags are not listed in jaeger UI.
When i use span.finish(), Recently added tags and duration works fine. But it shows two span with same name.

Sample program:-
    child_span = create_child_span( exec_name );
    with span_in_context(child_span):
        child_span.set_tag('testing',get_current_time());
        time.sleep(10)
        ##os.system('echo In-progress '+exec_name+' ');
        time.sleep(10)
        child_span.set_tag('end_time',get_current_time());
        ## by commenting finish, recently added tags are not listing with proper duration of span
        ## by uncommenting, It shows one more same tag with recently added tags and duration
        #child_span.finish(); ## by commenting end_time or any tag is not listing as well as duration of span
        return child_span

Python tutorial ImportError: No module named concurrent.futures

I attempted to follow the Python tutorial, but am unable to get lesson1 to work following the directions provided.

pip install -r requirements.txt
mkdir lesson01/exercise
touch lesson01/exercise/__init__.py
...
python -m lesson01.exercise.hello Steve
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/flands/sandbox/opentracing-tutorial/python/lesson01/exercise/hello.py", line 5, in <module>
    from jaeger_client import Config
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/__init__.py", line 27, in <module>
    from .config import Config  # noqa
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/config.py", line 24, in <module>
    from .local_agent_net import LocalAgentSender
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/local_agent_net.py", line 17, in <module>
    from threadloop import ThreadLoop
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/threadloop/__init__.py", line 3, in <module>
    from threadloop.threadloop import ThreadLoop  # noqa
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/threadloop/threadloop.py", line 4, in <module>
    from concurrent.futures import Future
ImportError: No module named concurrent.futures

Solution appears to be adding futures to the requirements file -- I will submit a pull request shortly.

Cant get the install working

pip install -r requirements.txt
Collecting opentracing<3,>=2 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/33/25/56d29df57d9cb700eab7ed3bae447ce9b7031e5a10c16a4c558eb0a06c7b/opentracing-2.0.0.tar.gz
Obtaining jaeger-client from git+https://github.com/yurishkuro/jaeger-client-python.git@d631596415cb549a4e8314cc25d6c53fab710528#egg=jaeger-client (from -r requirements.txt (line 6))
  Cloning https://github.com/yurishkuro/jaeger-client-python.git (to revision d631596415cb549a4e8314cc25d6c53fab710528) to ./env/src/jaeger-client
fatal: unable to access 'https://github.com/yurishkuro/jaeger-client-python.git/': Could not resolve host: github.com
Command "git clone -q https://github.com/yurishkuro/jaeger-client-python.git /Users/bensunderland/Documents/GitHub/opentracing-tutorial/python/env/src/jaeger-client" failed with error code 128 in None

Add missing import to tutorial for `lesson03`

Here's a missing import that would help newbies!

(Should be added at the #add-some-imports section for lesson03 for the Formatter and Publisher classes)

import javax.ws.rs.core.Context;

And some imports for the Hello class:

import io.opentracing.tag.Tags;
import io.opentracing.propagation.Format;

Tracing async goroutine and child daemon process

Trace is by itself a directional acrylic graph of spans. But if I have a main processes that spawns off a goroutine that periodic pull data from say AWS? The main program sends the goroutine the target ID via a channel; and the goroutine reports the result back via a channel. How can I trace that from main? But the childspans started within the goroutine never close unless interrupted or errored out.

C# Too out of date

In your c# tutorials you are instructing readers to use opentracing.tutorial.library that no longer exists, and there are many steps missing, and the explanation is not detailed enough to be able to infer what needs to be done to do what is needed. ie should any code be replaced, or should new code just be added, and where it should be added.

github.com/golang/[email protected]/gps/constraint.go:103:21: cannot use sv (type *semver.Version) as type semver.Version in field value

$  cd $GOPATH/src/github.com/yurishkuro/opentracing-tutorial/go
$ make install
......
/home/hzy/go/pkg/mod/github.com/golang/[email protected]/gps/constraint.go:103:21: cannot use sv (type *semver.Version) as type semver.Version in field value
/home/hzy/go/pkg/mod/github.com/golang/[email protected]/gps/constraint.go:122:16: invalid type assertion: c.(semver.Version) (non-interface type *semver.Constraints on left)
/home/hzy/go/pkg/mod/github.com/golang/[email protected]/gps/constraint.go:149:4: undefined: semver.Constraint
Makefile:3: recipe for target 'install' failed
make: *** [install] Error 2

No step to set environment variables

After lesson 1 I see no changes in yaeger UI. I think it is because we don't set environment variables that are taken by tracer - JAEGER_SAMPLER_TYPE, JAEGER_SAMPLER_PARAM, JAEGER_SAMPLER_MANAGER_HOST_PORT and they are null.
Also, I run docker for Windows and yaeger is Launched on 192.168.99.100 instead of localhost, please provide appropriate data if you edit.

Don't know how to upload spans when Yaeger is on remote host

Probably this is not the problem of tutorial, but rather the situation I am facing. I don't know how to connect to Jaeger that is launched via openshift on remote host. I followed steps from https://github.com/jaegertracing/jaeger-openshift to start jaeger in openshift. I successfully installed it, and was able to see Jaeger ui on host - http://jaeger-query-adc-jaeger.apps.test-ose.ca.sbrf.ru . My testing app is executed outside openshift. I try lesson 1 from tutorial, with adding steps to set jaeger host and port. No matter what I try, I don't see my spans on the UI. I tried following lines of code to insert in main method before the tutorial code:
System.setProperty("JAEGER_ENDPOINT", "http://jaeger-query-adc-jaeger.apps.test-ose.ca.sbrf.ru");
Also tried following:
System.setProperty("JAEGER_AGENT_HOST", "jaeger-query-adc-jaeger.apps.test-ose.ca.sbrf.ru");
System.setProperty("JAEGER_AGENT_PORT", "14267");

Then I created routing for jaeger-collector with command -
oc create route edge --service=jaeger-collector --port 14267 --insecure-policy=Allow

And oc get route jaeger-collector outputs -
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
jaeger-collector jaeger-collector-adc-jaeger.apps.test-ose.ca.sbrf.ru jaeger-collector 14267 edge/Allow None

So I also tried -
System.setProperty("JAEGER_ENDPOINT", "https://jaeger-collector-adc-jaeger.apps.test-ose.ca.sbrf.ru:14267/api/traces");
But no result.

How should I configure system variables to be able to connect to Jaeger, that is executed remotely in Openshift?

No startActive function

I am using jaeger client 0.32 and do not even have a startActive function ??

try (Scope scope = tracer.buildSpan("say-hello").startActive(true)) {
            scope.span().setTag("hello-to", helloTo);

            String helloStr = formatString(helloTo);
            printHello(helloStr);
        }

Was it removed? Am I using the incorrect version?

Defect in lession03 Publisher.java and Formatter.java in “solution” folder

There is a defect in lession03 Publisher.java and Formatter.java in “solution” folder. The following code makes tracer object to be closed soon in the beginning. And the server-side tracing does not work.

try (JaegerTracer tracer = Tracing.init("publisher")) {
  new Publisher(tracer).run(args); //This is asynchronous!
}

Lesson 1 - path to Hello.java is wrong

It says lesson01/exercise/Hello.java, but should be exercise/Hello.java (relative to the "current lesson"), so that the file is created at src/main/java/lesson01/exercise/Hello.java, relative to the tutorial root

Edit nodejs tutorial

The nodejs tutorial should more closely match the python tutorial, which is excellent.

See WIP.

go-lesson03: Client instrumentation unclear

Hello again,

Thanks for the quick handling of the previous issues I raised! Here is another issue I noticed:
The lesson tells you to instrument the client with this snippet:

ext.SpanKindRPCClient.Set(span)
ext.HTTPUrl.Set(span, url)
ext.HTTPMethod.Set(span, "GET")
span.Tracer().Inject(
    span.Context(),
    opentracing.HTTPHeaders,
    opentracing.HTTPHeadersCarrier(req.Header),
)

The first problem with this is that "ext" is not imported at this point in the example (and its existence is not mentioned). Looking at the solution you can tell an import of "github.com/opentracing/opentracing-go/ext" is missing. You might want to add the equivalent of "Add some imports" as is done when instrumenting the servers further down.

Finally, when the snippet calls ext.HTTPUrl.Set(span, url) there is no url variable in scope, but it is present in the solution like so:

url := "http://localhost:8081/format?" + v.Encode()

Maby the baseline exercise code should be updated to use that variable so you don't have to stop and figure out what "url" is when following along? Since net/url is imported it is even more confusing since you might think "url" refers to that package and not a missing variable.

I really appreciate this tutorial by the way, thanks a lot for putting it out there!

Node.js Lesson 2 code does not produce multiple spans

After working through the lesson and then adapting the solution's code over my own, it seems that multiple spans are not produced from the code in lesson 2. I don't know exactly why but I wanted to surface the issue here.

Screenshots

image

image

go-lesson02: Unclear ChildOf() code

The lesson text uses this code to show usage of ChildOf():

span = rootSpan.Tracer().StartSpan(
    "formatString",
    opentracing.ChildOf(span.Context()),
)

It is not obvious how that should be used. The = assignment suggests that "span" is already declared which means it should be used after the short assignment statement (:=) that already exists, like this:

span := rootSpan.Tracer().StartSpan("formatString")
span = rootSpan.Tracer().StartSpan(
    "formatString",
    opentracing.ChildOf(span.Context()),
)

I'm guessing this is not what is intended, and running the code it is clear a unique trace is still being created. I think that example should be updated to this:

span := rootSpan.Tracer().StartSpan(
    "formatString",
    opentracing.ChildOf(rootSpan.Context()),
)

That is, use := assignment and replace span.Context() with rootSpan.Context().

Desire to translate the Python part to Chinese

Hello dear authors:
I'm a TA from the University of Sydney.
I had already read the Python part of this tutorial and run all of the codes. I think this tutorial is so useful that I want to translate all of the Python lessons to Chinese to help more Chinese distributed tracing developers(including my students) read easily and also to expanse your influence among Chinese readers. This week is my academic vacation so I have enough time.
Hope you can give me this chance.
Contact me at any time. My academic email: [email protected]
Kind regards, Tian

Run Opentracing Java tutorial on Windows

Through the run.sh script all the Java samples are running well on Linux.
Is there an equivalent run.bat for Windows environments (which sets up the classpath etc) ?

Documentation Inconsistencies on this repo vs https://opentracing.io/

In this section of the repo documentation

https://github.com/yurishkuro/opentracing-tutorial/tree/master/java/src/main/java/lesson03#extract-the-span-context-from-the-incoming-request-using-tracerextract

It suggests using the TextMapAdapter

while on this section of opentracing.io documentation

https://opentracing.io/guides/java/inject-extract/#extracting-the-span-s-context-from-incoming-request

It suggests using the TextMapExtractAdapter

I believe the documentation of this repository to be correct, but the opentracing.io examples seem to have a much higher google page rank, which might cause some confusion.

Regards

Install for python requirements.txt not working

$ pip install -r requirements.txt 
You are using pip version 6.0.8, however version 19.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting opentracing<3,>=2 (from -r requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/94/9f/289424136addf621fb4c75624ef9a3a80e8575da3993a87950c57e93217e/opentracing-2.2.0.tar.gz
    /tmp/pip-build-iBcehI/opentracing/setup.py:12: DeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
      url='https://github.com/opentracing/opentracing-python',
Obtaining jaeger-client from git+https://github.com/yurishkuro/jaeger-client-python.git@d631596415cb549a4e8314cc25d6c53fab710528#egg=jaeger-client (from -r requirements.txt (line 6))
  Cloning https://github.com/yurishkuro/jaeger-client-python.git (to d631596415cb549a4e8314cc25d6c53fab710528) to ./env/src/jaeger-client
  Could not find a tag or branch 'd631596415cb549a4e8314cc25d6c53fab710528', assuming commit.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
    error in jaeger-client setup command: Invalid environment marker: python_version<"3"
    Complete output from command python setup.py egg_info:
    error in jaeger-client setup command: Invalid environment marker: python_version<"3"
    
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in ./env/src/jaeger-client```

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.