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

Datadog support APM #100

Closed
fenriz07 opened this issue Sep 3, 2021 · 0 comments
Closed

Datadog support APM #100

fenriz07 opened this issue Sep 3, 2021 · 0 comments

Comments

@fenriz07
Copy link

fenriz07 commented Sep 3, 2021

Hello. I'm working in a suport for Datadog APM

I have this:

func Datadog(ctx gearbox.Context) {

	method := string(ctx.Context().Method())

	opts := []ddtrace.StartSpanOption{
		tracer.SpanType(ext.SpanTypeWeb),
		//tracer.ServiceName(cfg.serviceName)
		tracer.Tag(ext.HTTPMethod, method),
		tracer.Tag(ext.HTTPURL, ctx.Context().URI().String()),
		tracer.Measured(),
	}

	span, ctxOfSpan := tracer.StartSpanFromContext(context.Background(), "http.request", opts...)
	defer span.Finish()

	ctx.Next()

	span.SetTag(ext.ResourceName, string(ctx.Context().URI().Path()))

	status := ctx.Context().Response.StatusCode()

	span.SetTag(ext.HTTPCode, status)

	if status == gearbox.StatusInternalServerError {

		b := string(ctx.Context().Response.Body())
		span.SetTag(ext.Error, true)
		span.SetTag(ext.ErrorMsg, b)
	}
}

This a example in "go-chi" https://github.com/DataDog/dd-trace-go/blob/v1/contrib/go-chi/chi/chi.go

I have one problem need pass a my handler ctxOfSpan this variable is type context.Context. I have been thinking in a possible solution like this:

ctx.NextWithCtx(ctxOfSpan)

You have a better idea?

Thank you for you important time. Regards

@fenriz07 fenriz07 closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant