Skip to content

Instantly share code, notes, and snippets.

@tedsuo
tedsuo / node_span_basics.js
Created November 11, 2020 23:09
node_span_basics.js
const app = express();
app.get('/hello', (req, res) => {
// access the span created by express instrumentation
span = tracer.getCurrentSpan();
// add an attribute to segment your data by projectID
span.setAttribute('projectID', '123');
// log an event and include some structured data.
span.addEvent('setting timeout', { sleep: 300 });
@tedsuo
tedsuo / node_create_tracer.js
Created November 11, 2020 23:08
node_create_tracer.js
const opentelemetry = require('@opentelemetry/api');
const express = require('express');
// create a tracer and name it after your package
const tracer = opentelemetry.trace.getTracer('@otel-node-basics/server');
const app = express();
@tedsuo
tedsuo / node_server_init.js
Created November 11, 2020 23:07
node_server_init.js
const { lightstep } = require('lightstep-opentelemetry-launcher-node');
const sdk = lightstep.configureOpenTelemetry({
accessToken: '<ACCESS_TOKEN>',
serviceName: 'hello-server-1',
serviceVersion: 'v1.2.3',
propagators: 'tracecontext,b3',
});
sdk.start().then(() => {
@tedsuo
tedsuo / node_basic_client.js
Created November 11, 2020 21:48
node_basic_client.js
const http = require('http');
function makeRequest() {
http.get({
host: 'localhost',
port: 9000,
path: '/hello',
}, (response) => {
const body = [];
response.on('data', (chunk) => body.push(chunk));
@tedsuo
tedsuo / node_basic_server.js
Created November 11, 2020 21:48
node_basic_server.js
const express = require('express');
const app = express();
app.get('/hello', (req, res) => {
res.status(200).send('Hello World');
});
app.listen(9000);
@tedsuo
tedsuo / otel_example.go
Created September 29, 2020 03:09
OTel Go current LS setup
func main() {
// configure headers
headers := map[string]string{
"lightstep-access-token": "ls-access-token",
}
// configure TLS credentials
secureOption := otlp.WithTLSCredentials(credentials.NewClientTLSFromCert())
//configure an OTLP exporter
exporter, err := otlp.NewExporter(
@tedsuo
tedsuo / otel_laucher_go_example.go
Last active September 29, 2020 02:33
OTel Launcher Go Example
import "github.com/lightstep/otel-launcher-go/launcher"
func main() {
otel := launcher.ConfigureOpentelemetry(
launcher.WithServiceName("robochef9000"),
launcher.WithServiceVersion("v1.2.3"),
launcher.WithAccessToken("ls-access-token"),
)
defer otel.Shutdown()
}
@tedsuo
tedsuo / excerpt.md
Last active June 9, 2018 01:09
An Excerpt from "Letter from a Birmingham Jail"

I must make two honest confessions to you, my Christian and Jewish brothers. First, I must confess that over the past few years I have been gravely disappointed with the white moderate. I have almost reached the regrettable conclusion that the Negro's great stumbling block in his stride toward freedom is not the White Citizen's Counciler or the Ku Klux Klanner, but the white moderate, who is more devoted to "order" than to justice; who prefers a negative peace which is the absence of tension to a positive peace which is the presence of justice; who constantly says: "I agree with you in the goal you seek, but I cannot agree with your methods of direct action"; who paternalistically believes he can set the timetable for another man's freedom; who lives by a mythical concept of time and who constantly advises the Negro to wait for a "more convenient season." Shallow understanding from people of good will is more frustrating than absolute misunderstanding from people of ill will. Lukewarm acceptance is much more

@tedsuo
tedsuo / ot-rc1.md
Last active September 14, 2017 18:39
ot-rc1

Scope Proposal Release Candidate 1

This Release Candidate proposes an approach to managed Span propagation without enforcing Span lifetime handling through (in-code) reference counting.

Release Candidate objectives

  • Decouple active Span propagation from Span.finish().
  • Remove ActiveSpan/ActiveSpanManager reference counting.

Approach

@tedsuo
tedsuo / client.go
Created August 26, 2016 15:26
Example Cell API v1.0
package cell
import "io"
type Client interface {
Query(QueryRequest) (QueryResponse, error)
Allocate(AllocationRequest) (AllocationResponse, error)
Run(RunRequest) (RunResponse, error)
Stop(StopRequest) (StopResponse, error)
Delete(DeleteRequest) (DeleteResponse, error)