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

feat: first iteration on datadog tracing with spans #374

Merged
merged 1 commit into from Jul 27, 2022

Conversation

pboros
Copy link
Contributor

@pboros pboros commented Jul 20, 2022

No description provided.

@pboros pboros added the debug image This PR will generate a debug image label Jul 20, 2022
@pboros pboros removed the debug image This PR will generate a debug image label Jul 20, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2022

Codecov Report

Merging #374 (2cb3c25) into main (45a7e5d) will decrease coverage by 0.59%.
The diff coverage is 13.53%.

@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
- Coverage   28.83%   28.24%   -0.60%     
==========================================
  Files          66       68       +2     
  Lines        7001     7144     +143     
==========================================
- Hits         2019     2018       -1     
- Misses       4754     4899     +145     
+ Partials      228      227       -1     
Impacted Files Coverage Δ
server/metrics/tenant.go 62.50% <ø> (ø)
server/metrics/tracing.go 0.00% <0.00%> (ø)
server/midddleware/middleware.go 0.00% <0.00%> (ø)
server/midddleware/tracing.go 0.00% <0.00%> (ø)
server/transaction/manager.go 1.69% <0.00%> (-1.13%) ⬇️
server/midddleware/metrics.go 16.12% <30.00%> (-13.42%) ⬇️
server/metrics/requests.go 63.09% <51.21%> (+3.09%) ⬆️
store/kv/kv.go 18.10% <100.00%> (+0.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 45a7e5d...2cb3c25. Read the comment docs.

@pboros pboros added the debug image This PR will generate a debug image label Jul 20, 2022
@pboros pboros added debug image This PR will generate a debug image and removed debug image This PR will generate a debug image labels Jul 20, 2022
@pboros pboros added debug image This PR will generate a debug image and removed debug image This PR will generate a debug image labels Jul 20, 2022
@pboros pboros added debug image This PR will generate a debug image and removed debug image This PR will generate a debug image labels Jul 21, 2022
@pboros pboros removed the debug image This PR will generate a debug image label Jul 25, 2022
@pboros pboros force-pushed the pboros/datadog-spans branch 3 times, most recently from 6ce0919 to b4dca20 Compare July 25, 2022 15:50
@pboros pboros added the debug image This PR will generate a debug image label Jul 25, 2022
@pboros pboros added debug image This PR will generate a debug image and removed debug image This PR will generate a debug image labels Jul 25, 2022
@pboros pboros marked this pull request as ready for review July 25, 2022 18:22
@pboros pboros requested review from rbarabas, himank and efirs and removed request for rbarabas and himank July 25, 2022 18:22
store/kv/kv.go Outdated Show resolved Hide resolved
store/search/ts.go Outdated Show resolved Hide resolved
server/main.go Outdated Show resolved Hide resolved
server/config/options.go Outdated Show resolved Hide resolved
server/config/options.go Outdated Show resolved Hide resolved
validatorStreamServerInterceptor(),
}

if config.DatadogTrace.Enabled {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we put this logic into the Interceptor and just pass out required components (Logger etc. Config is global so no need to pass that down)? Am I missing the benefit of having these interceptors exposed at this level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initializing the interceptor has a very visible cost according to the profiler. I think it's better only to initialize them when they are needed. What do you think?

}

if config.DatadogTrace.Enabled {
streamInterceptors = append(streamInterceptors, ddTraceStream())
}

if config.Metrics.Grpc.Enabled && config.Metrics.Grpc.ResponseTime {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's our goal with the "basic" GRPC interceptor? Do we still need it? Or is this in place to make the transition smoother?

}

if config.DatadogTrace.Enabled {
unaryInterceptors = append(unaryInterceptors, ddTraceUnary())
}

if config.Metrics.Grpc.Enabled && config.Metrics.Grpc.ResponseTime {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should put these Enabled flags under a single config structure and just case switch on them. WDYT?

@@ -118,6 +120,10 @@ func Get(config *config.Config, tenantMgr *metadata.TenantManager, txMgr *transa
}

unaryInterceptors = append(unaryInterceptors, []grpc.UnaryServerInterceptor{
//grpctrace.UnaryServerInterceptor(grpctrace.WithServiceName(util.Service)),
grpc_logging.UnaryServerInterceptor(grpc_zerolog.InterceptorLogger(sampledTaggedLogger)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we add a TODO to hook this up to the span IDs? Perhaps perform the logging in the code that manages the high level request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not something I changed, I just moved it in the initialization order. This and logs attached to spans are different.

store/kv/kv.go Outdated Show resolved Hide resolved
store/search/ts.go Outdated Show resolved Hide resolved
store/kv/kv.go Outdated
@@ -102,6 +103,17 @@ func measureLow(ctx context.Context, name string, f func() error) {
metrics.FdbRequests.Tagged(tags).Histogram("histogram", tally.DefaultBuckets)
defer metrics.FdbRequests.Tagged(tags).Histogram("histogram", tally.DefaultBuckets).Start().Stop()
}
if config.DefaultConfig.Tracing.Enabled {
Copy link
Contributor

@rbarabas rbarabas Jul 27, 2022

Choose a reason for hiding this comment

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

Would the following work?

closer, err := setTrace(ctx, name)
defer closer()

Above assumes no defer needs to be passed up but if you think you need the span later after L117 we can bring it back for Finish() or other things.

The config will be available as it's global so no need to pass that.

func setTrace(ctx context.Context, name string) (func f(), error) {
    if !config.DefaultConfig.Tracing.Enabled {
       return f(){}, nil
    }
    
    parentSpan, exists := tracer.SpenFromContext(ctx)
    if exists {
        ...
    }
    
    return f(){}, nil
}

Btw I don't see tags being used but if they are being used elsewhere we could pass those down also.

metrics.SearchRequests.Tagged(tags).Histogram("histogram", tally.DefaultBuckets)
defer metrics.SearchRequests.Tagged(tags).Histogram("histogram", tally.DefaultBuckets).Start().Stop()
}
if config.DefaultConfig.Tracing.Enabled {
Copy link
Contributor

@rbarabas rbarabas Jul 27, 2022

Choose a reason for hiding this comment

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

Perhaps we can do the same here as in kv:

span, err := setTrace(ctx, name)

Maybe tags will need to be added to the signature of setTrace() or whatever the name of the helper function would be.

@pboros pboros force-pushed the pboros/datadog-spans branch 2 times, most recently from d34300f to 0fc28e8 Compare July 27, 2022 16:08
@pboros pboros merged commit a4814e4 into main Jul 27, 2022
@pboros pboros deleted the pboros/datadog-spans branch July 27, 2022 16:52
@tigrisdata-argocd-bot
Copy link
Collaborator

🎉 This PR is included in version 1.0.0-alpha.25 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@tigrisdata-argocd-bot
Copy link
Collaborator

🎉 This PR is included in version 1.0.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants