Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[opentracing] add Compatibility Layer #126

Merged
merged 18 commits into from
Dec 5, 2017

Conversation

palazzem
Copy link
Contributor

@palazzem palazzem commented Dec 4, 2017

Overview

Compatibility layer for OpenTracing specification. The PR implements:

  • a OT-compatible Tracer
  • a Configuration struct to configure a Datadog Tracer
  • the Span and SpanContext implementation
  • the compatibility layer for OpenTracing Tags

This PR is an initial work to support entirely OpenTracing. In the current state, the OT-compatible Tracer wraps our previous implementation, so internals are the same. To set the Datadog Tracer as a GlobalTracer, you should add the following code to initialize the Tracer:

import (
    // datadog namespace is suggested
    datadog "github.com/DataDog/dd-trace-go/opentracing"
    opentracing "github.com/opentracing/opentracing-go"
)

func Example_initialization() {
    // create a Tracer configuration
    config := datadog.NewConfiguration()
    config.ServiceName = "api-intake"
    config.AgentHostname = "ddagent.consul.local"

    // initialize a Tracer and ensure a graceful shutdown
    // using the `closer.Close()`
    tracer, closer, err := datadog.NewTracer(config)
    if err != nil {
        // handle the configuration error
    }
    defer closer.Close()

    // set the Datadog tracer as a GlobalTracer
    opentracing.SetGlobalTracer(tracer)
}

Default values for Configuration are provided, and if you don't set a ServiceName, the binary name is used.

@palazzem palazzem added this to the 0.6.0 milestone Dec 4, 2017
Copy link

@masci masci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a couple of nits

// The initialization returns a `io.Closer` that can be used to graceful
// shutdown the tracer. If the configuration object defines a disabled
// Tracer, a no-op implementation is returned.
func NewTracer(config *Configuration) (ot.Tracer, io.Closer, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this live in tracer.go?

assert.Equal(false, config.Debug)
assert.Equal("opentracing.test", config.ServiceName)
assert.Equal("localhost", config.AgentHostname)
assert.Equal("8126", config.AgentPort)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.SampleRate is missing

assert.Nil(err)
}

func TestTracerConstructor(t *testing.T) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically does all that TestConfiguration seems to do, let's merge the two?

// TODO: implementation missing
func (s *Span) FinishWithOptions(options ot.FinishOptions) {
if options.FinishTime.IsZero() {
options.FinishTime = time.Now().UTC()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why this is the only place where timezone is explicitly set to UTC?

@palazzem palazzem merged commit 298b717 into master Dec 5, 2017
@palazzem palazzem deleted the palazzem/opentracing-compatibility branch December 5, 2017 11:58
jdgordon pushed a commit to jdgordon/dd-trace-go that referenced this pull request May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants