This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.GlobalTracer; | |
public static void Main() { | |
// Don't create any extra objects, unless needed. | |
GlobalTracer.registerIfAbsent(TracerCallable.INSTANCE); | |
Span span = GlobalTracer.get().buildSpan("myOperation").start(); | |
} | |
class TracerCallable implements Callable<Tracer> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
py37-test-api run-test: commands[0] | pytest | |
=================================================================================== test session starts ==================================================================================== | |
platform darwin -- Python 3.7.4, pytest-6.1.0, py-1.9.0, pluggy-0.13.1 -- /development/opentelemetry-python/.tox/py37-test-api/bin/python | |
cachedir: .tox/py37-test-api/.pytest_cache | |
rootdir: /development/opentelemetry-python, configfile: pyproject.toml | |
collected 0 items / 1 error | |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
Traceback (most recent call last): | |
File "/development/opentelemetry-python/.tox/py37-test-api/bin/pytest", line 11, in <module> | |
sys.exit(console_main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import opentelemetry.context.Scope; | |
import opentelemetry.trace.Tracer; | |
import opentelemetry.trace.Span; | |
# No imports on Brave | |
// Start a new trace or a span within an existing trace representing an operation | |
Span span = tracer.spanBuilder("encode").startSpan(); | |
// Put the span in "scope" so that downstream code such as loggers can see trace IDs | |
try (Scope scope = tracer.withSpan(span)) { | |
return encoder.encode(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the ls-examples repo | |
git clone https://github.com/lightstep/ls-examples | |
cd ls-examples | |
# Use the launcher-java branch | |
git checkout otel-launcher-java | |
# Jump to the specific example | |
cd java/launcher |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2019, OpenTelemetry Authors | |
* | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------- Context API -------------- | |
// Based on top of grpc.Context | |
// (We could also use it directly and add the automatic Scope handling). | |
// Note: Cannot use String directly for the keys, as an imposition done | |
// by grpc.Context. | |
// Questions: | |
// - Should we allow some form of extensibility to allow | |
// users to provide logic/storage? | |
public final class Context { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FOLLOWS_FROM use scenario. | |
public class Promise<T> { | |
public Promise() { | |
// 1. Capture the active Span. | |
this.parentSpan = tracer.activeSpan(); | |
} | |
// 2. Add callacks that will be invoked asynchronously | |
// upon success. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Span context = span.context(); | |
String traceId = context.toTraceId(); | |
String spanId = context.toSpanId(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] BUILD FAILURE | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 17.340 s | |
[INFO] Finished at: 2019-02-26T19:52:21+01:00 | |
[INFO] ------------------------------------------------------------------------ | |
[ERROR] Failed to execute goal on project opentracing-specialagent: Could not resolve dependencies for project io.opentracing.contrib:opentracing-specialagent:jar:0.0.1-SNAPSHOT: Could not find artifact io.opentracing.contrib:opentracing-specialagent-jms2:jar:0.0.1-SNAPSHOT -> [Help 1] | |
[ERROR] | |
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. | |
[ERROR] Re-run Maven using the -X switch to enable full debug logging. | |
[ERROR] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Scope scope = null; | |
try { | |
scope = tracer.buildSpan("foo").startActive(); | |
} catch (Exception exc) { | |
Tags.ERROR.set(scope.span(), true); | |
scope.span().log(ImmutableMap.Builder<String, Object>() | |
.put("event", "error") | |
.put("error.object", exc) | |
.build()); |
NewerOlder